Skip to content

Commit 6c8d8d6

Browse files
committed
Fix test call for error case
1 parent 2b8e2f8 commit 6c8d8d6

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/libcore/tests/nonzero.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use core::convert::TryFrom;
2-
use core::num::{IntErrorKind, NonZeroI32, NonZeroI8, NonZeroU32, NonZeroU8, TryFromIntError};
2+
use core::num::{IntErrorKind, NonZeroI32, NonZeroI8, NonZeroU32, NonZeroU8};
33
use core::option::Option::{self, None, Some};
44
use std::mem::size_of;
55

@@ -180,18 +180,18 @@ fn test_nonzero_bitor_assign() {
180180

181181
#[test]
182182
fn test_nonzero_from_int_on_success() {
183-
assert_eq!(NonZeroU8::try_from(5), Ok(NonZeroU8::new(5)));
184-
assert_eq!(NonZeroU32::try_from(5), Ok(NonZeroU32::new(5)));
183+
assert_eq!(NonZeroU8::try_from(5), Ok(NonZeroU8::new(5).unwrap()));
184+
assert_eq!(NonZeroU32::try_from(5), Ok(NonZeroU32::new(5).unwrap()));
185185

186-
assert_eq!(NonZeroI8::try_from(-5), Ok(NonZeroI8::new(-5)));
187-
assert_eq!(NonZeroI32::try_from(-5), Ok(NonZeroI32::new(-5)));
186+
assert_eq!(NonZeroI8::try_from(-5), Ok(NonZeroI8::new(-5).unwrap()));
187+
assert_eq!(NonZeroI32::try_from(-5), Ok(NonZeroI32::new(-5).unwrap()));
188188
}
189189

190190
#[test]
191191
fn test_nonzero_from_int_on_err() {
192-
assert_eq!(NonZeroU8::try_from(0), Err(TryFromIntError(())));
193-
assert_eq!(NonZeroU32::try_from(0), Err(TryFromIntError(())));
192+
assert!(NonZeroU8::try_from(0).is_err());
193+
assert!(NonZeroU32::try_from(0).is_err());
194194

195-
assert_eq!(NonZeroI8::try_from(0), Err(TryFromIntError(())));
196-
assert_eq!(NonZeroI32::try_from(0), Err(TryFromIntError(())));
195+
assert!(NonZeroI8::try_from(0).is_err());
196+
assert!(NonZeroI32::try_from(0).is_err());
197197
}

0 commit comments

Comments
 (0)