Add test for precise algorithm used

This commit is contained in:
Jacob Pratt 2023-02-19 22:59:22 +00:00
parent 20282c1b20
commit ab4c0dd137
No known key found for this signature in database
GPG Key ID: 6E2E55C5F9ABB247

View File

@ -68,3 +68,13 @@ fn test_find_best_match_for_name() {
);
})
}
#[test]
fn test_precise_algorithm() {
// Not Levenshtein distance.
assert_ne!(edit_distance("ab", "ba", usize::MAX), Some(2));
// Not unrestricted Damerau-Levenshtein distance.
assert_ne!(edit_distance("abde", "bcaed", usize::MAX), Some(3));
// The current implementation is a restricted Damerau-Levenshtein distance.
assert_eq!(edit_distance("abde", "bcaed", usize::MAX), Some(4));
}