From a9e5d4b1c5a920600938b14cecdb21fde8522d2b Mon Sep 17 00:00:00 2001 From: Carson McManus Date: Sat, 25 Jun 2022 11:07:57 -0400 Subject: [PATCH] fix up unit tests --- src/tui.rs | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/tui.rs b/src/tui.rs index 7c3f3a2..37b2231 100644 --- a/src/tui.rs +++ b/src/tui.rs @@ -285,36 +285,33 @@ mod prompt_char_tests { #[test] fn test_gives_answer() { - let inputs = ['y', '\n'].iter().collect::(); - 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::(); - 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::(); - 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::(); - 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::(); - let answer = prompt_char_impl(inputs, "yn").unwrap(); - assert_eq!(answer, 'n'); + let answer = prompt_char_impl("yy", "yn"); + assert!(matches!(answer, Err(_))); } }