File tree 3 files changed +44
-0
lines changed
3 files changed +44
-0
lines changed Original file line number Diff line number Diff line change 1
1
module github.com/gohugoio/hashstructure
2
2
3
3
go 1.18
4
+
5
+ require github.com/AdaLogics/go-fuzz-headers v0.0.0-20240806141605-e8a1dd7889d6 // indirect
Original file line number Diff line number Diff line change
1
+ github.com/AdaLogics/go-fuzz-headers v0.0.0-20240806141605-e8a1dd7889d6 h1:He8afgbRMd7mFxO99hRNu+6tazq8nFF9lIwo9JFroBk =
2
+ github.com/AdaLogics/go-fuzz-headers v0.0.0-20240806141605-e8a1dd7889d6 /go.mod h1:8o94RPi1/7XTJvwPpRSzSUedZrtlirdB3r9Z20bi2f8 =
Original file line number Diff line number Diff line change
1
+ package hashstructure
2
+
3
+ import (
4
+ "testing"
5
+ "time"
6
+
7
+ fuzz "github.com/AdaLogics/go-fuzz-headers"
8
+ )
9
+
10
+ func FuzzHash (f * testing.F ) {
11
+ type Test struct {
12
+ Str string
13
+ Int int
14
+ In64 int64
15
+ Float64 float64
16
+ MapStr map [string ]string
17
+ MapStruct map [string ]Test
18
+ SliceStr []string
19
+ SliceStrSet []string `hash:"set"`
20
+ SliceByte []byte
21
+ StrPtr * string
22
+ IntPtr * int
23
+ Time time.Time
24
+ Duration time.Duration
25
+ UUID string `hash:"ignore"`
26
+ }
27
+
28
+ f .Fuzz (func (t * testing.T , data []byte ) {
29
+ fuzzConsumer := fuzz .NewConsumer (data )
30
+ targetStruct := & Test {}
31
+ err := fuzzConsumer .GenerateStruct (targetStruct )
32
+ if err != nil {
33
+ return
34
+ }
35
+ _ , err = Hash (targetStruct , nil )
36
+ if err != nil {
37
+ t .Fatal (err )
38
+ }
39
+ })
40
+ }
You can’t perform that action at this time.
0 commit comments