Skip to content

Commit 89d593d

Browse files
committed
Add test coverage for FindNoSort
1 parent babd0e2 commit 89d593d

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

fuzzy_test.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,29 @@ func (e employees) Values() iter.Seq[string] {
155155
}
156156
}
157157

158+
func TestFindNoSort(t *testing.T) {
159+
// The higher-scoring match ("my name is_Ramsey", 36) comes second in the
160+
// input, so preserving input order proves results are returned unsorted.
161+
want := fuzzy.Matches{
162+
{
163+
Str: "moduleNameResolver.ts",
164+
Index: 0,
165+
MatchedIndexes: []int{0, 6, 10},
166+
Score: 32,
167+
},
168+
{
169+
Str: "my name is_Ramsey",
170+
Index: 1,
171+
MatchedIndexes: []int{0, 3, 11},
172+
Score: 36,
173+
},
174+
}
175+
got := fuzzy.FindNoSort("mnr", []string{"moduleNameResolver.ts", "my name is_Ramsey"})
176+
if diff := pretty.Compare(want, got); diff != "" {
177+
t.Errorf("%v", diff)
178+
}
179+
}
180+
158181
func TestFindFromSource(t *testing.T) {
159182
emps := employees{
160183
{

0 commit comments

Comments
 (0)