Skip to content

Commit

Permalink
Changes for test passing
Browse files Browse the repository at this point in the history
  • Loading branch information
milinddethe15 committed Oct 1, 2023
1 parent 10c7cc4 commit 65db8bf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,19 +164,22 @@ mod tests {

assert_eq!(config.duration, Duration::from_secs(30));
assert_eq!(config.numbers, false);
assert_eq!(config.numbers_ratio, 0.05);
}

#[test]
fn should_create_new_with_default_values() {
let args = Args {
duration: None,
numbers: None,
numbers_ratio: None,
dictionary_path: None,
};
let config = Config::new(args, PathBuf::new()).expect("Unable to create config");

assert_eq!(config.duration, Duration::from_secs(30));
assert_eq!(config.numbers, false);
assert_eq!(config.numbers_ratio, 0.05);
}

#[test]
Expand All @@ -189,26 +192,30 @@ mod tests {
let args = Args {
duration: None,
numbers: None,
numbers_ratio: None,
dictionary_path: None,
};
let config =
Config::new(args, config_file.path().to_path_buf()).expect("Unable to create config");

assert_eq!(config.duration, Duration::from_secs(10));
assert_eq!(config.numbers, true);
assert_eq!(config.numbers_ratio, 0.05);
}

#[test]
fn should_create_new_with_argument_values() {
let args = Args {
duration: Some(10),
numbers: Some(true),
numbers_ratio: None,
dictionary_path: None,
};
let config = Config::new(args, PathBuf::new()).expect("Unable to create config");

assert_eq!(config.duration, Duration::from_secs(10));
assert_eq!(config.numbers, true);
assert_eq!(config.numbers_ratio, 0.05);
}

#[test]
Expand All @@ -221,13 +228,15 @@ mod tests {
let args = Args {
duration: Some(20),
numbers: Some(false),
numbers_ratio: None,
dictionary_path: Some(String::from("/etc/dict/words")),
};
let config =
Config::new(args, config_file.path().to_path_buf()).expect("Unable to create config");

assert_eq!(config.duration, Duration::from_secs(20));
assert_eq!(config.numbers, false);
assert_eq!(config.numbers_ratio, 0.05);
assert_eq!(config.dictionary_path, PathBuf::from("/etc/dict/words"));
}
}
1 change: 1 addition & 0 deletions src/expected_input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ mod tests {
let config = Config {
duration: Duration::from_secs(30),
numbers: false,
numbers_ratio: 0.05,
dictionary_path: config_file.path().to_path_buf(),
};

Expand Down

0 comments on commit 65db8bf

Please sign in to comment.