-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstring_slice_test.go
More file actions
45 lines (39 loc) · 892 Bytes
/
string_slice_test.go
File metadata and controls
45 lines (39 loc) · 892 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package puzzle
import (
"strings"
"testing"
"github.com/brianvoe/gofakeit/v7"
)
func fakeStringSlice(v uint8) []string {
out := make([]string, 0)
// out = append(out, gofakeit.Name())
generators := []func() string{
gofakeit.Adjective,
gofakeit.Noun,
gofakeit.Verb,
gofakeit.Color,
gofakeit.Word,
gofakeit.Interjection,
gofakeit.FarmAnimal,
}
for i, g := range generators {
if (v & (1 << i)) != 0 {
out = append(out, g())
}
}
return out
}
func testStringSliceConverter(t *testing.T, x uint8) {
// for _, value := range testValues {
value := fakeStringSlice(x)
if err := testConverterAny(StringSliceConverter, strings.Join(value, ","), value, sliceEqualFactory(value)); err != nil {
t.Error(err)
}
// }
}
func FuzzStringSliceConverter(f *testing.F) {
for i := 0; i < FUZZ_SIZE; i++ {
f.Add(gofakeit.Uint8())
}
f.Fuzz(testStringSliceConverter)
}