Skip to content

Commit

Permalink
added test for duplicate keys
Browse files Browse the repository at this point in the history
since only implement Eq and not Ord for Glob, inspects all pairs.
Fails on first duplicate found as wouldn't expect to be adding large
number of syntaxes at once and emits the glob string pattern duplicated.
  • Loading branch information
YeungOnion committed Aug 12, 2023
1 parent a8691b7 commit 3f8b7e9
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/syntax_mapping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,4 +286,20 @@ mod tests {
Some(MappingTarget::MapToUnknown)
);
}

#[test]
/// verifies that SyntaxMapping::builtin() doesn't repeat `Glob`-based keys
fn no_duplicate_builtin_keys() {
let mappings = SyntaxMapping::builtin().mappings;
for i in 0..mappings.len() {
let mut tail = mappings[i + 1..].into_iter();
match tail.find(|item| item.0.glob() == mappings[i].0.glob()) {
Some(duplicate) => panic!(
"duplicate in SyntaxMapping::builtin() for glob {}",
duplicate.0.glob().glob()
),
None => (),
}
}
}
}

0 comments on commit 3f8b7e9

Please sign in to comment.