From 45e173176a0d4b44c9b1bf3cc7a880929d1360a6 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Mon, 1 Oct 2018 01:42:18 +0200 Subject: Fill in `action_parses_map_with_simple_characters()` test A simple test to check parsing of a simple string without any special keys or modifiers. --- src/parser.rs | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/parser.rs b/src/parser.rs index 51e15d8..a84aba1 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -580,7 +580,57 @@ mod tests { #[test] fn action_parses_map_with_simple_characters() { - // "type hello!" + let text = "type hello!"; + + let expected = Action::Map(vec![ + KeyboardKeyWithModifiers::new( + KeyboardKey::Character(Character::new('t')), + None, + ), + KeyboardKeyWithModifiers::new( + KeyboardKey::Character(Character::new('y')), + None, + ), + KeyboardKeyWithModifiers::new( + KeyboardKey::Character(Character::new('p')), + None, + ), + KeyboardKeyWithModifiers::new( + KeyboardKey::Character(Character::new('e')), + None, + ), + KeyboardKeyWithModifiers::new( + KeyboardKey::Character(Character::new(' ')), + None, + ), + KeyboardKeyWithModifiers::new( + KeyboardKey::Character(Character::new('h')), + None, + ), + KeyboardKeyWithModifiers::new( + KeyboardKey::Character(Character::new('e')), + None, + ), + KeyboardKeyWithModifiers::new( + KeyboardKey::Character(Character::new('l')), + None, + ), + KeyboardKeyWithModifiers::new( + KeyboardKey::Character(Character::new('l')), + None, + ), + KeyboardKeyWithModifiers::new( + KeyboardKey::Character(Character::new('o')), + None, + ), + KeyboardKeyWithModifiers::new( + KeyboardKey::Character(Character::new('!')), + None, + ), + ]); + let result = action_map().easy_parse(text).map(|t| t.0); + + assert_eq!(result, Ok(expected)); } #[test] -- cgit v1.2.3