summaryrefslogtreecommitdiffstats
path: root/CLI/rust/src/game_of_life.rs
diff options
context:
space:
mode:
Diffstat (limited to 'CLI/rust/src/game_of_life.rs')
-rw-r--r--CLI/rust/src/game_of_life.rs13
1 files changed, 5 insertions, 8 deletions
diff --git a/CLI/rust/src/game_of_life.rs b/CLI/rust/src/game_of_life.rs
index affe003..1f8a2a9 100644
--- a/CLI/rust/src/game_of_life.rs
+++ b/CLI/rust/src/game_of_life.rs
@@ -86,6 +86,7 @@ pub(crate) fn app() -> App<'static> {
mod app {
use super::*;
use mocktopus::mocking::*;
+ use terminal_size::{Height, Width};
#[test]
fn no_options() {
@@ -119,33 +120,29 @@ mod app {
#[test]
fn valid_width() {
+ opts::terminal_size_wrapper.mock_safe(|| MockResult::Return((Width(42), Height(42))));
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() {
+ opts::terminal_size_wrapper.mock_safe(|| MockResult::Return((Width(42), Height(42))));
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() {
+ opts::terminal_size_wrapper.mock_safe(|| MockResult::Return((Width(42), Height(42))));
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() {
+ opts::terminal_size_wrapper.mock_safe(|| MockResult::Return((Width(42), Height(42))));
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());
}