aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/go-faster/city/fuzz_test.go
blob: ac82644e5286d4460cbcb3b61b8fe8489e6e80bf (plain) (blame)
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
//go:build go1.18
// +build go1.18

package city

import (
	"bytes"
	"testing"
)

var _defaultCorpus = [][]byte{
	nil,
	{},
	{1, 2, 3},
	{1, 2, 3, 4, 5, 6},
	[]byte("hello"),
	[]byte("hello world"),
	bytes.Repeat([]byte("hello"), 100),
}

func FuzzHash128(f *testing.F) {
	for _, s := range _defaultCorpus {
		f.Add(s)
	}
	f.Fuzz(func(t *testing.T, data []byte) {
		Hash128(data)
	})
}

func FuzzHash64(f *testing.F) {
	for _, s := range _defaultCorpus {
		f.Add(s)
	}
	f.Fuzz(func(t *testing.T, data []byte) {
		Hash64(data)
	})
}

func FuzzHash32(f *testing.F) {
	for _, s := range _defaultCorpus {
		f.Add(s)
	}
	f.Fuzz(func(t *testing.T, data []byte) {
		Hash32(data)
	})
}

func FuzzCH64(f *testing.F) {
	for _, s := range _defaultCorpus {
		f.Add(s)
	}
	f.Fuzz(func(t *testing.T, data []byte) {
		CH64(data)
	})
}

func FuzzCH128(f *testing.F) {
	for _, s := range _defaultCorpus {
		f.Add(s)
	}
	f.Fuzz(func(t *testing.T, data []byte) {
		CH128(data)
	})
}