diff options
Diffstat (limited to 'src/libstd/num/uint_macros.rs')
| -rw-r--r-- | src/libstd/num/uint_macros.rs | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/libstd/num/uint_macros.rs b/src/libstd/num/uint_macros.rs index 82c55d7b5b8..4cd6391318f 100644 --- a/src/libstd/num/uint_macros.rs +++ b/src/libstd/num/uint_macros.rs @@ -20,7 +20,7 @@ mod tests { use num::FromStrRadix; fn from_str<T: ::str::FromStr>(t: &str) -> Option<T> { - ::str::FromStr::from_str(t) + ::str::FromStr::from_str(t).ok() } #[test] @@ -38,15 +38,15 @@ mod tests { #[test] pub fn test_parse_bytes() { - assert_eq!(FromStrRadix::from_str_radix("123", 10), Some(123u as $T)); - assert_eq!(FromStrRadix::from_str_radix("1001", 2), Some(9u as $T)); - assert_eq!(FromStrRadix::from_str_radix("123", 8), Some(83u as $T)); - assert_eq!(FromStrRadix::from_str_radix("123", 16), Some(291u as u16)); - assert_eq!(FromStrRadix::from_str_radix("ffff", 16), Some(65535u as u16)); - assert_eq!(FromStrRadix::from_str_radix("z", 36), Some(35u as $T)); - - assert_eq!(FromStrRadix::from_str_radix("Z", 10), None::<$T>); - assert_eq!(FromStrRadix::from_str_radix("_", 2), None::<$T>); + assert_eq!(FromStrRadix::from_str_radix("123", 10), Ok(123u as $T)); + assert_eq!(FromStrRadix::from_str_radix("1001", 2), Ok(9u as $T)); + assert_eq!(FromStrRadix::from_str_radix("123", 8), Ok(83u as $T)); + assert_eq!(FromStrRadix::from_str_radix("123", 16), Ok(291u as u16)); + assert_eq!(FromStrRadix::from_str_radix("ffff", 16), Ok(65535u as u16)); + assert_eq!(FromStrRadix::from_str_radix("z", 36), Ok(35u as $T)); + + assert_eq!(FromStrRadix::from_str_radix("Z", 10).ok(), None::<$T>); + assert_eq!(FromStrRadix::from_str_radix("_", 2).ok(), None::<$T>); } #[test] |
