Created
September 24, 2022 19:54
-
-
Save st3fan/2b665344ab3c3e601fb183cd6379bfc1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[cfg(test)] | |
mod tests { | |
use std::convert::TryInto; | |
use std::num::TryFromIntError; | |
#[test] | |
fn it_works() { | |
let a = 1i16; | |
let b: Result<i8, TryFromIntError> = a.try_into(); | |
assert!(b.is_ok()); | |
} | |
#[test] | |
fn overflow() { | |
let a = 256i16; | |
let b: Result<i8, TryFromIntError> = a.try_into(); | |
assert!(b.is_err()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment