Skip to content

Commit

Permalink
test(search-algo): ✅ Add test case for ordering matches
Browse files Browse the repository at this point in the history
  • Loading branch information
Blakeinstein committed Oct 2, 2023
1 parent 852da9d commit 790d776
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"conventionalCommits.scopes": [
"search-algo"
]
}
25 changes: 25 additions & 0 deletions src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,28 @@ fn multibyte_chars_indices() {

assert_eq!(&s[r.start..r.end], needle);
}

#[test]
fn full_match_higher() {
let s = &[
"Syrup",
"Syrup2",
"Live",
"Live2",
"Live3",
];

let fuse = Fuse::default();

let result1 = fuse.search_text_in_iterable("Syrup", s.iter());

assert_eq!(result1.len(), 2);
assert_eq!(result1[0].index, 0);
assert_eq!(result1[1].index, 1);

let result2 = fuse.search_text_in_iterable("live", s.iter());

assert_eq!(result2.len(), 3);
assert_eq!(result2[0].index, 2);
assert_eq!(result2[1].score, result2[2].score);
}

0 comments on commit 790d776

Please sign in to comment.