Skip to content

Commit ab4c0dd

Browse files
committed
Add test for precise algorithm used
1 parent 20282c1 commit ab4c0dd

File tree

1 file changed

+10
-0
lines changed
  • compiler/rustc_span/src/edit_distance

1 file changed

+10
-0
lines changed

compiler/rustc_span/src/edit_distance/tests.rs

+10
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,13 @@ fn test_find_best_match_for_name() {
6868
);
6969
})
7070
}
71+
72+
#[test]
73+
fn test_precise_algorithm() {
74+
// Not Levenshtein distance.
75+
assert_ne!(edit_distance("ab", "ba", usize::MAX), Some(2));
76+
// Not unrestricted Damerau-Levenshtein distance.
77+
assert_ne!(edit_distance("abde", "bcaed", usize::MAX), Some(3));
78+
// The current implementation is a restricted Damerau-Levenshtein distance.
79+
assert_eq!(edit_distance("abde", "bcaed", usize::MAX), Some(4));
80+
}

0 commit comments

Comments
 (0)