Skip to content

Commit

Permalink
fix adjacency tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Lia committed Mar 5, 2024
1 parent 62329ca commit 380eb66
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions src/matching/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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),
Expand Down

0 comments on commit 380eb66

Please sign in to comment.