summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CLI/rust/src/game_of_life/opts.rs52
1 files changed, 52 insertions, 0 deletions
diff --git a/CLI/rust/src/game_of_life/opts.rs b/CLI/rust/src/game_of_life/opts.rs
index a0ed34b..9f612c1 100644
--- a/CLI/rust/src/game_of_life/opts.rs
+++ b/CLI/rust/src/game_of_life/opts.rs
@@ -20,6 +20,32 @@ pub(crate) mod validators {
}
}
+ #[cfg(test)]
+ mod is_fitting_term_width {
+ use super::*;
+
+ #[test]
+ fn positive_value() {
+ assert!(is_fitting_term_width("13").is_ok());
+ }
+
+
+ #[test]
+ fn value_too_large() {
+ assert!(is_fitting_term_width("1337").is_err());
+ }
+
+ #[test]
+ fn negative_value() {
+ assert!(is_fitting_term_width("-13").is_err());
+ }
+
+ #[test]
+ fn string_value() {
+ assert!(is_fitting_term_width("not a number").is_err());
+ }
+ }
+
/// Validator to check if height configuration can be used
///
/// The maximum height allowed is the current terminal window height - 2
@@ -38,6 +64,32 @@ pub(crate) mod validators {
}
}
+ #[cfg(test)]
+ mod is_fitting_term_height {
+ use super::*;
+
+ #[test]
+ fn positive_value() {
+ assert!(is_fitting_term_height("13").is_ok());
+ }
+
+
+ #[test]
+ fn value_too_large() {
+ assert!(is_fitting_term_height("1337").is_err());
+ }
+
+ #[test]
+ fn negative_value() {
+ assert!(is_fitting_term_height("-13").is_err());
+ }
+
+ #[test]
+ fn string_value() {
+ assert!(is_fitting_term_height("not a number").is_err());
+ }
+ }
+
/// Validator to check if delay value is positive
pub(crate) fn is_positive(val: &str) -> Result<(), String> {
match val.parse::<i16>() {