From 567a66d30fb86ad144e3deec256e27d05a611c2d Mon Sep 17 00:00:00 2001 From: Ben Morrison Date: Wed, 4 Sep 2019 22:04:18 -0400 Subject: error helper test --- src/error.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/error.rs b/src/error.rs index 3265271..032e2c2 100644 --- a/src/error.rs +++ b/src/error.rs @@ -10,3 +10,22 @@ where } } } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn shouldnt_panic() { + let ok: Result<&str, &str> = Ok("okay"); + let rhs = helper(ok); + assert_eq!("okay", rhs); + } + + #[test] + #[should_panic] + fn should_panic() { + let err: Result<&str, &str> = Err("oops"); + helper(err); + } +} -- cgit 1.4.1-2-gfad0