Add tests for std::num::Wrapping impls

This commit is contained in:
David Tolnay 2017-10-31 09:32:58 -07:00
parent 501aa3ee1d
commit 9b08915a18
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82
2 changed files with 21 additions and 0 deletions

View File

@ -17,6 +17,7 @@ use std::default::Default;
use std::ffi::{CString, OsString}; use std::ffi::{CString, OsString};
use std::rc::Rc; use std::rc::Rc;
use std::sync::Arc; use std::sync::Arc;
use std::num::Wrapping;
#[cfg(feature = "unstable")] #[cfg(feature = "unstable")]
use std::ffi::CStr; use std::ffi::CStr;
@ -762,6 +763,14 @@ declare_tests! {
Token::Bool(true), Token::Bool(true),
], ],
} }
test_wrapping {
Wrapping(1usize) => &[
Token::U32(1),
],
Wrapping(1usize) => &[
Token::U64(1),
],
}
} }
declare_tests! { declare_tests! {
@ -1169,4 +1178,10 @@ declare_error_tests! {
], ],
"invalid type: sequence, expected unit struct UnitStruct", "invalid type: sequence, expected unit struct UnitStruct",
} }
test_wrapping_overflow<Wrapping<u16>> {
&[
Token::U32(65536),
],
"invalid value: integer `65536`, expected u16",
}
} }

View File

@ -16,6 +16,7 @@ use std::time::{Duration, UNIX_EPOCH};
use std::ffi::CString; use std::ffi::CString;
use std::rc::Rc; use std::rc::Rc;
use std::sync::Arc; use std::sync::Arc;
use std::num::Wrapping;
#[cfg(unix)] #[cfg(unix)]
use std::str; use std::str;
@ -399,6 +400,11 @@ declare_tests! {
Token::Bool(true), Token::Bool(true),
], ],
} }
test_wrapping {
Wrapping(1usize) => &[
Token::U64(1),
],
}
} }
declare_tests! { declare_tests! {