From 380eb662d9b2275463e510afdb3969178e06d5ab Mon Sep 17 00:00:00 2001 From: Lia Date: Tue, 5 Mar 2024 14:04:34 +0100 Subject: [PATCH] fix adjacency tests --- src/matching/mod.rs | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/src/matching/mod.rs b/src/matching/mod.rs index 78a5a51..455a9f3 100644 --- a/src/matching/mod.rs +++ b/src/matching/mod.rs @@ -1108,8 +1108,26 @@ mod tests { } #[test] - fn test_matches_spatial_patterns_surrounded_by_non_spatial_patterns() { - let password = "6tfGHJ"; + fn test_matches_spatial_patterns_surrounded_by_non_spatial_patterns_qwertz() { + let password = "6zhGHJ"; + let m = (matching::SpatialMatch {}) + .get_matches(password, &HashMap::new()) + .into_iter() + .find(|m| m.token == *password) + .unwrap(); + let p = if let MatchPattern::Spatial(ref p) = m.pattern { + p + } else { + panic!("Wrong match pattern") + }; + assert_eq!(p.graph, "qwertz".to_string()); + assert_eq!(p.turns, 3); + assert_eq!(p.shifted_count, 3); + } + + #[test] + fn test_matches_spatial_patterns_surrounded_by_non_spatial_patterns_qwerty() { + let password = "6YhJkL"; let m = (matching::SpatialMatch {}) .get_matches(password, &HashMap::new()) .into_iter() @@ -1134,6 +1152,12 @@ mod tests { ("hGFd", "qwerty", 1, 2), ("/;p09876yhn", "qwerty", 3, 0), ("Xdr%", "qwerty", 1, 2), + ("1\"345", "qwertz", 1, 1), + ("@WSY", "qwertz", 3, 3), + ("6tfGHJ", "qwertz", 2, 3), + ("hGFd", "qwertz", 1, 2), + ("äölölkm", "qwertz", 4, 0), + ("xdr%", "qwertz", 1, 1), ("159-", "keypad", 1, 0), ("*84", "keypad", 1, 0), ("/8520", "keypad", 1, 0),