From 06ff6562c1107da65bc99b7f0abd1d5e6abf43fb Mon Sep 17 00:00:00 2001 From: projectmoon Date: Tue, 1 Sep 2020 08:17:59 +0000 Subject: [PATCH] Add more tests for handling weird input. --- src/commands/parser.rs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/commands/parser.rs b/src/commands/parser.rs index d04e09d..3ad9c6a 100644 --- a/src/commands/parser.rs +++ b/src/commands/parser.rs @@ -87,11 +87,26 @@ mod tests { } #[test] - fn just_exclamation_point_test() { + fn just_exclamation_mark_test() { let result = parse_command("!"); 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] fn basic_command_test() { assert_eq!(