Add tests for Option::ok_or_errkind() extension function

This commit is contained in:
Matthias Beyer 2016-06-25 18:51:43 +02:00
parent 5c8dbac34d
commit 7ffd28b592

View file

@ -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),
}
}
}