summaryrefslogtreecommitdiffstats
path: root/CLI
diff options
context:
space:
mode:
authora14m <[email protected]>2021-04-01 23:47:57 +0200
committera14m <[email protected]>2021-04-01 23:47:57 +0200
commit0d5ce2fa0624d46d7673506c76534dc840b755cc (patch)
treefc8e6e0ec8d303fbbecc219ec17ea9d69f0852ea /CLI
parent7dce9b1c8acb4a57390a037d23e8cd4ce01dd914 (diff)
Add the testing of is_positive
Diffstat (limited to 'CLI')
-rw-r--r--CLI/rust/src/game_of_life/opts.rs20
1 files changed, 20 insertions, 0 deletions
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());
+ }
+ }
}