Skip to content

Commit

Permalink
Merge pull request #56 from josharian/fuzz-tests
Browse files Browse the repository at this point in the history
add simple fuzz test
  • Loading branch information
lithammer authored May 9, 2023
2 parents 24e57ae + 675978e commit e05c30e
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions fuzzy/fuzz_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package fuzzy

import (
"sort"
"testing"
)

func FuzzFind(f *testing.F) {
f.Fuzz(func(t *testing.T, n string, h []byte) {
s := make([]string, len(h))
for i, b := range h {
s[i] = string(b)
}
Find(n, s)
FindFold(n, s)
FindNormalized(n, s)
FindNormalizedFold(n, s)
r := RankFind(n, s)
sort.Sort(r)
// No need to sort the other Rank calls;
// assume first sort can catch any bugs.
RankFindFold(n, s)
RankFindNormalized(n, s)
RankFindNormalizedFold(n, s)
if len(s) > 0 {
x := s[0]
LevenshteinDistance(n, x)
Match(n, x)
MatchFold(n, x)
MatchNormalized(n, x)
MatchNormalizedFold(n, x)
}
})
}

0 comments on commit e05c30e

Please sign in to comment.