From 0d5ce2fa0624d46d7673506c76534dc840b755cc Mon Sep 17 00:00:00 2001 From: a14m Date: Thu, 1 Apr 2021 23:47:57 +0200 Subject: Add the testing of is_positive --- CLI/rust/src/game_of_life/opts.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/CLI/rust/src/game_of_life/opts.rs b/CLI/rust/src/game_of_life/opts.rs index 5e52715..a0ed34b 100644 --- a/CLI/rust/src/game_of_life/opts.rs +++ b/CLI/rust/src/game_of_life/opts.rs @@ -46,4 +46,24 @@ pub(crate) mod validators { Err(e) => Err(e.to_string()), } } + + #[cfg(test)] + mod is_positive { + use super::*; + + #[test] + fn positive_value() { + assert!(is_positive("1337").is_ok()); + } + + #[test] + fn negative_value() { + assert!(is_positive("-1337").is_err()); + } + + #[test] + fn string_value() { + assert!(is_positive("not a number").is_err()); + } + } } -- cgit v1.2.3