Add tests for Option::ok_or_errkind() extension function
This commit is contained in:
parent
5c8dbac34d
commit
7ffd28b592
1 changed files with 24 additions and 0 deletions
|
@ -368,4 +368,28 @@ mod test {
|
|||
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_error_option_good() {
|
||||
use self::error::{OkOrErr, MapErrInto};
|
||||
use self::error::TestErrorKind;
|
||||
|
||||
let something = Some(1);
|
||||
match something.ok_or_errkind(TestErrorKind::TestErrorKindA) {
|
||||
Ok(1) => assert!(true),
|
||||
_ => assert!(false),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_error_option_bad() {
|
||||
use self::error::{OkOrErr, MapErrInto};
|
||||
use self::error::TestErrorKind;
|
||||
|
||||
let something : Option<i32> = None;
|
||||
match something.ok_or_errkind(TestErrorKind::TestErrorKindA) {
|
||||
Ok(_) => assert!(false),
|
||||
Err(e) => assert!(true),
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue