fix up unit tests
This commit is contained in:
parent
15349156db
commit
a9e5d4b1c5
1 changed files with 8 additions and 11 deletions
19
src/tui.rs
19
src/tui.rs
|
@ -285,36 +285,33 @@ mod prompt_char_tests {
|
|||
|
||||
#[test]
|
||||
fn test_gives_answer() {
|
||||
let inputs = ['y', '\n'].iter().collect::<String>();
|
||||
let answer = prompt_char_impl(inputs, "yn").unwrap();
|
||||
let answer = prompt_char_impl("y", "yn").unwrap();
|
||||
assert_eq!(answer, 'y');
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_gives_default() {
|
||||
let inputs = ['\n'].iter().collect::<String>();
|
||||
let answer = prompt_char_impl(inputs, "Yn").unwrap();
|
||||
let answer = prompt_char_impl("", "Yn").unwrap();
|
||||
assert_eq!(answer, 'y');
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_should_not_give_default() {
|
||||
let inputs = ['n', '\n'].iter().collect::<String>();
|
||||
let answer = prompt_char_impl(inputs, "Yn").unwrap();
|
||||
let answer = prompt_char_impl("n", "Yn").unwrap();
|
||||
assert_eq!(answer, 'n');
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_should_not_give_invalid() {
|
||||
let inputs = ['g', '\n', 'n', '\n'].iter().collect::<String>();
|
||||
let answer = prompt_char_impl(inputs, "yn").unwrap();
|
||||
let answer = prompt_char_impl("g", "yn");
|
||||
assert!(matches!(answer, Err(_)));
|
||||
let answer = prompt_char_impl("n", "yn").unwrap();
|
||||
assert_eq!(answer, 'n');
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_should_not_give_multichar() {
|
||||
let inputs = ['y', 'y', '\n', 'n', '\n'].iter().collect::<String>();
|
||||
let answer = prompt_char_impl(inputs, "yn").unwrap();
|
||||
assert_eq!(answer, 'n');
|
||||
let answer = prompt_char_impl("yy", "yn");
|
||||
assert!(matches!(answer, Err(_)));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue