Skip to content

Commit

Permalink
Add tests for std::num::Wrapping impls
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Oct 31, 2017
1 parent 501aa3e commit 9b08915
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
15 changes: 15 additions & 0 deletions test_suite/tests/test_de.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use std::default::Default;
use std::ffi::{CString, OsString};
use std::rc::Rc;
use std::sync::Arc;
use std::num::Wrapping;

#[cfg(feature = "unstable")]
use std::ffi::CStr;
Expand Down Expand Up @@ -762,6 +763,14 @@ declare_tests! {
Token::Bool(true),
],
}
test_wrapping {
Wrapping(1usize) => &[
Token::U32(1),
],
Wrapping(1usize) => &[
Token::U64(1),
],
}
}

declare_tests! {
Expand Down Expand Up @@ -1169,4 +1178,10 @@ declare_error_tests! {
],
"invalid type: sequence, expected unit struct UnitStruct",
}
test_wrapping_overflow<Wrapping<u16>> {
&[
Token::U32(65536),
],
"invalid value: integer `65536`, expected u16",
}
}
6 changes: 6 additions & 0 deletions test_suite/tests/test_ser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use std::time::{Duration, UNIX_EPOCH};
use std::ffi::CString;
use std::rc::Rc;
use std::sync::Arc;
use std::num::Wrapping;

#[cfg(unix)]
use std::str;
Expand Down Expand Up @@ -399,6 +400,11 @@ declare_tests! {
Token::Bool(true),
],
}
test_wrapping {
Wrapping(1usize) => &[
Token::U64(1),
],
}
}

declare_tests! {
Expand Down

0 comments on commit 9b08915

Please sign in to comment.