From 7ffd28b5927994af6839010860bd9994950f9a47 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 25 Jun 2016 18:51:43 +0200 Subject: [PATCH] Add tests for Option::ok_or_errkind() extension function --- libimagerror/src/error_gen.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/libimagerror/src/error_gen.rs b/libimagerror/src/error_gen.rs index 61540b36..3a84fd90 100644 --- a/libimagerror/src/error_gen.rs +++ b/libimagerror/src/error_gen.rs @@ -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 = None; + match something.ok_or_errkind(TestErrorKind::TestErrorKindA) { + Ok(_) => assert!(false), + Err(e) => assert!(true), + } + } + }