summaryrefslogtreecommitdiffstats
path: root/CLI/rust/src
diff options
context:
space:
mode:
Diffstat (limited to 'CLI/rust/src')
-rw-r--r--CLI/rust/src/game_of_life/generators/input.rs26
1 files changed, 10 insertions, 16 deletions
diff --git a/CLI/rust/src/game_of_life/generators/input.rs b/CLI/rust/src/game_of_life/generators/input.rs
index ee41de5..07ab43a 100644
--- a/CLI/rust/src/game_of_life/generators/input.rs
+++ b/CLI/rust/src/game_of_life/generators/input.rs
@@ -34,18 +34,21 @@ mod new {
}
}
- #[test]
- fn with_url() {
- let opts = Opts {
- seed: 1337,
- input: Some(String::from("https://example.com")),
+ fn opts(input: Option<String>) -> Opts {
+ Opts {
+ input,
width: 13,
height: 13,
+ seed: 1337,
live_cell: 'L',
dead_cell: 'D',
delay: 13,
- };
+ }
+ }
+ #[test]
+ fn with_url() {
+ let opts = opts(Some(String::from("https://example.com")));
generate_file_data.mock_safe(|_| panic!());
generate_url_data.mock_safe(|opts| MockResult::Return(Ok(universe_mock(opts))));
let universe = new(opts.clone()).unwrap();
@@ -54,16 +57,7 @@ mod new {
#[test]
fn with_file() {
- let opts = Opts {
- seed: 1337,
- input: Some(String::from("./example.txt")),
- width: 13,
- height: 13,
- live_cell: 'L',
- dead_cell: 'D',
- delay: 13,
- };
-
+ let opts = opts(Some(String::from("./example.txt")));
generate_file_data.mock_safe(|opts| MockResult::Return(Ok(universe_mock(opts))));
generate_url_data.mock_safe(|_| panic!());
let universe = new(opts.clone()).unwrap();