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]
|
#[test]
|
||||||
fn test_gives_answer() {
|
fn test_gives_answer() {
|
||||||
let inputs = ['y', '\n'].iter().collect::<String>();
|
let answer = prompt_char_impl("y", "yn").unwrap();
|
||||||
let answer = prompt_char_impl(inputs, "yn").unwrap();
|
|
||||||
assert_eq!(answer, 'y');
|
assert_eq!(answer, 'y');
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_gives_default() {
|
fn test_gives_default() {
|
||||||
let inputs = ['\n'].iter().collect::<String>();
|
let answer = prompt_char_impl("", "Yn").unwrap();
|
||||||
let answer = prompt_char_impl(inputs, "Yn").unwrap();
|
|
||||||
assert_eq!(answer, 'y');
|
assert_eq!(answer, 'y');
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_should_not_give_default() {
|
fn test_should_not_give_default() {
|
||||||
let inputs = ['n', '\n'].iter().collect::<String>();
|
let answer = prompt_char_impl("n", "Yn").unwrap();
|
||||||
let answer = prompt_char_impl(inputs, "Yn").unwrap();
|
|
||||||
assert_eq!(answer, 'n');
|
assert_eq!(answer, 'n');
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_should_not_give_invalid() {
|
fn test_should_not_give_invalid() {
|
||||||
let inputs = ['g', '\n', 'n', '\n'].iter().collect::<String>();
|
let answer = prompt_char_impl("g", "yn");
|
||||||
let answer = prompt_char_impl(inputs, "yn").unwrap();
|
assert!(matches!(answer, Err(_)));
|
||||||
|
let answer = prompt_char_impl("n", "yn").unwrap();
|
||||||
assert_eq!(answer, 'n');
|
assert_eq!(answer, 'n');
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_should_not_give_multichar() {
|
fn test_should_not_give_multichar() {
|
||||||
let inputs = ['y', 'y', '\n', 'n', '\n'].iter().collect::<String>();
|
let answer = prompt_char_impl("yy", "yn");
|
||||||
let answer = prompt_char_impl(inputs, "yn").unwrap();
|
assert!(matches!(answer, Err(_)));
|
||||||
assert_eq!(answer, 'n');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue