Skip to content

Commit

Permalink
Fix test call for error case
Browse files Browse the repository at this point in the history
  • Loading branch information
poliorcetics committed Jun 8, 2020
1 parent 2b8e2f8 commit 6c8d8d6
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/libcore/tests/nonzero.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use core::convert::TryFrom;
use core::num::{IntErrorKind, NonZeroI32, NonZeroI8, NonZeroU32, NonZeroU8, TryFromIntError};
use core::num::{IntErrorKind, NonZeroI32, NonZeroI8, NonZeroU32, NonZeroU8};
use core::option::Option::{self, None, Some};
use std::mem::size_of;

Expand Down Expand Up @@ -180,18 +180,18 @@ fn test_nonzero_bitor_assign() {

#[test]
fn test_nonzero_from_int_on_success() {
assert_eq!(NonZeroU8::try_from(5), Ok(NonZeroU8::new(5)));
assert_eq!(NonZeroU32::try_from(5), Ok(NonZeroU32::new(5)));
assert_eq!(NonZeroU8::try_from(5), Ok(NonZeroU8::new(5).unwrap()));
assert_eq!(NonZeroU32::try_from(5), Ok(NonZeroU32::new(5).unwrap()));

assert_eq!(NonZeroI8::try_from(-5), Ok(NonZeroI8::new(-5)));
assert_eq!(NonZeroI32::try_from(-5), Ok(NonZeroI32::new(-5)));
assert_eq!(NonZeroI8::try_from(-5), Ok(NonZeroI8::new(-5).unwrap()));
assert_eq!(NonZeroI32::try_from(-5), Ok(NonZeroI32::new(-5).unwrap()));
}

#[test]
fn test_nonzero_from_int_on_err() {
assert_eq!(NonZeroU8::try_from(0), Err(TryFromIntError(())));
assert_eq!(NonZeroU32::try_from(0), Err(TryFromIntError(())));
assert!(NonZeroU8::try_from(0).is_err());
assert!(NonZeroU32::try_from(0).is_err());

assert_eq!(NonZeroI8::try_from(0), Err(TryFromIntError(())));
assert_eq!(NonZeroI32::try_from(0), Err(TryFromIntError(())));
assert!(NonZeroI8::try_from(0).is_err());
assert!(NonZeroI32::try_from(0).is_err());
}

0 comments on commit 6c8d8d6

Please sign in to comment.