-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Diacritics substitution in prompt (#7205)
- Loading branch information
1 parent
8b2cea1
commit 7cfbf47
Showing
5 changed files
with
169 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package prompter | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestFilterDiacritics(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
filter string | ||
value string | ||
want bool | ||
}{ | ||
{ | ||
name: "exact match no diacritics", | ||
filter: "Mikelis", | ||
value: "Mikelis", | ||
want: true, | ||
}, | ||
{ | ||
name: "exact match no diacritics", | ||
filter: "Mikelis", | ||
value: "Mikelis", | ||
want: true, | ||
}, | ||
{ | ||
name: "exact match diacritics", | ||
filter: "Miķelis", | ||
value: "Miķelis", | ||
want: true, | ||
}, | ||
{ | ||
name: "partial match diacritics", | ||
filter: "Miķe", | ||
value: "Miķelis", | ||
want: true, | ||
}, | ||
{ | ||
name: "exact match diacritics in value", | ||
filter: "Mikelis", | ||
value: "Miķelis", | ||
want: true, | ||
}, | ||
{ | ||
name: "partial match diacritics in filter", | ||
filter: "Miķe", | ||
value: "Miķelis", | ||
want: true, | ||
}, | ||
{ | ||
name: "no match when removing diacritics in filter", | ||
filter: "Mielis", | ||
value: "Mikelis", | ||
want: false, | ||
}, | ||
{ | ||
name: "no match when removing diacritics in value", | ||
filter: "Mikelis", | ||
value: "Mielis", | ||
want: false, | ||
}, | ||
{ | ||
name: "no match diacritics in filter", | ||
filter: "Miķelis", | ||
value: "Mikelis", | ||
want: false, | ||
}, | ||
} | ||
|
||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
assert.Equal(t, LatinMatchingFilter(tt.filter, tt.value, 0), tt.want) | ||
}) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters