mirror of
https://github.com/crate-ci/typos.git
synced 2024-11-28 20:11:05 -05:00
test: Add some tests for dict processing logic
This commit is contained in:
parent
49a0eaab7b
commit
89d5a97a8a
1 changed files with 38 additions and 0 deletions
|
@ -145,6 +145,44 @@ fn process<S: Into<String>>(
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_merge_duplicates() {
|
||||||
|
assert_eq!(
|
||||||
|
process([("foo", ["bar"]), ("foo", ["baz"])]),
|
||||||
|
dict_from_iter([("foo", ["bar", "baz"])])
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_duplicate_correction_removal() {
|
||||||
|
let dict = process([("foo", ["bar", "bar"])]);
|
||||||
|
assert_eq!(dict, dict_from_iter([("foo", ["bar"])]));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_cycle_removal() {
|
||||||
|
assert!(process([("foo", ["bar"]), ("bar", ["foo"])]).is_empty());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_varcon_removal() {
|
||||||
|
assert!(process([("colour", ["color"])]).is_empty());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_varcon_best_match() {
|
||||||
|
assert_eq!(
|
||||||
|
process([(
|
||||||
|
"neighourhood", // note the missing 'b'
|
||||||
|
["neighborhood"],
|
||||||
|
)]),
|
||||||
|
dict_from_iter([(
|
||||||
|
"neighourhood",
|
||||||
|
["neighbourhood"] // note that 'bor' has become 'bour' to match the typo
|
||||||
|
)])
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
fn is_word(word: &str) -> bool {
|
fn is_word(word: &str) -> bool {
|
||||||
word.chars().all(|c| c.is_alphabetic())
|
word.chars().all(|c| c.is_alphabetic())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue