Add more tests for handling weird input.

This commit is contained in:
projectmoon 2020-09-01 08:17:59 +00:00
parent 33c41bce7e
commit 06ff6562c1
1 changed files with 16 additions and 1 deletions

View File

@ -87,11 +87,26 @@ mod tests {
} }
#[test] #[test]
fn just_exclamation_point_test() { fn just_exclamation_mark_test() {
let result = parse_command("!"); let result = parse_command("!");
assert!(result.is_err()); assert!(result.is_err());
} }
#[test]
fn word_with_exclamation_mark_test() {
let result1 = parse_command("hello !notacommand");
assert!(result1.is_ok());
assert!(result1.unwrap().1.is_none());
let result2 = parse_command("hello!");
assert!(result2.is_ok());
assert!(result2.unwrap().1.is_none());
let result3 = parse_command("hello!notacommand");
assert!(result3.is_ok());
assert!(result3.unwrap().1.is_none());
}
#[test] #[test]
fn basic_command_test() { fn basic_command_test() {
assert_eq!( assert_eq!(