summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CLI/rust/src/game_of_life.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/CLI/rust/src/game_of_life.rs b/CLI/rust/src/game_of_life.rs
index 383d564..affe003 100644
--- a/CLI/rust/src/game_of_life.rs
+++ b/CLI/rust/src/game_of_life.rs
@@ -85,6 +85,7 @@ pub(crate) fn app() -> App<'static> {
#[cfg(test)]
mod app {
use super::*;
+ use mocktopus::mocking::*;
#[test]
fn no_options() {
@@ -119,24 +120,32 @@ mod app {
#[test]
fn valid_width() {
let matches = app().get_matches_from(vec!["", "--width=13"]);
+ validators::is_fitting_term_width.mock_safe(|_| MockResult::Return(Ok(())));
+ validators::is_fitting_term_height.mock_safe(|_| MockResult::Return(Ok(())));
assert_eq!(matches.value_of("width"), Some("13"));
}
#[test]
fn valid_height() {
let matches = app().get_matches_from(vec!["", "--height=13"]);
+ validators::is_fitting_term_width.mock_safe(|_| MockResult::Return(Ok(())));
+ validators::is_fitting_term_height.mock_safe(|_| MockResult::Return(Ok(())));
assert_eq!(matches.value_of("height"), Some("13"));
}
#[test]
fn invalid_width() {
let matches = app().try_get_matches_from(vec!["", "--width=1337"]);
+ validators::is_fitting_term_width.mock_safe(|_| MockResult::Return(Err(String::from("Invalid"))));
+ validators::is_fitting_term_height.mock_safe(|_| MockResult::Return(Ok(())));
assert!(matches.is_err());
}
#[test]
fn invalid_height() {
let matches = app().try_get_matches_from(vec!["", "--height=1337"]);
+ validators::is_fitting_term_width.mock_safe(|_| MockResult::Return(Ok(())));
+ validators::is_fitting_term_height.mock_safe(|_| MockResult::Return(Err(String::from("Invalid"))));
assert!(matches.is_err());
}