Skip to content

Commit

Permalink
test: add more valid inputs for BoolInput
Browse files Browse the repository at this point in the history
  • Loading branch information
wangl-cc committed Nov 24, 2023
1 parent dee09cb commit 7ddc515
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions maa-cli/src/config/task/value/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,19 @@ mod tests {
assert!(value.ask(&mut output, input_invalid).unwrap());
assert_output_then_clear!(output, b"Invalid input, please input y/n: ");
assert!(matches!(value.get(), Err(Error::DefaultNotSet)));

// test other valid inputs
let value: BoolInput = BoolInput::new::<&str>(None, None);
assert!(value.ask(&mut output, &b"y\n"[..]).unwrap());
assert!(value.ask(&mut output, &b"Y\n"[..]).unwrap());
assert!(value.ask(&mut output, &b"yes\n"[..]).unwrap());
assert!(value.ask(&mut output, &b"Yes\n"[..]).unwrap());
assert!(value.ask(&mut output, &b"YES\n"[..]).unwrap());
assert!(!value.ask(&mut output, &b"n\n"[..]).unwrap());
assert!(!value.ask(&mut output, &b"N\n"[..]).unwrap());
assert!(!value.ask(&mut output, &b"no\n"[..]).unwrap());
assert!(!value.ask(&mut output, &b"No\n"[..]).unwrap());
assert!(!value.ask(&mut output, &b"NO\n"[..]).unwrap());
}

#[test]
Expand Down

0 comments on commit 7ddc515

Please sign in to comment.