forked from hamba/avro
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfuzz_schema_test.go
More file actions
46 lines (41 loc) · 1.11 KB
/
Copy pathfuzz_schema_test.go
File metadata and controls
46 lines (41 loc) · 1.11 KB
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
package avro_test
import (
"testing"
"github.com/iskorotkov/avro/v2"
)
func FuzzSchemaParse(f *testing.F) {
defer ConfigTeardown()
seeds := []string{
`"null"`,
`"int"`,
`"string"`,
`{"type":"int"}`,
`{"type":"bytes","logicalType":"decimal","precision":4,"scale":2}`,
`{"type":"long","logicalType":"timestamp-micros"}`,
`{"type":"fixed","name":"F","size":12,"logicalType":"duration"}`,
`{"type":"enum","name":"E","symbols":["A","B","C"],"default":"A"}`,
`{"type":"array","items":"long"}`,
`{"type":"map","values":"string"}`,
`["null","int","string"]`,
`{"type":"record","name":"R","fields":[
{"name":"a","type":"long"},
{"name":"b","type":["null","string"],"default":null},
{"name":"c","type":{"type":"array","items":"int"},"default":[]}
]}`,
`{"type":"record","name":"Tree","fields":[
{"name":"v","type":"int"},
{"name":"next","type":["null","Tree"],"default":null}
]}`,
}
for _, s := range seeds {
f.Add([]byte(s))
}
f.Add([]byte(""))
f.Add([]byte("{"))
f.Fuzz(func(_ *testing.T, data []byte) {
if len(data) > 1<<24 {
return
}
_, _ = avro.ParseBytes(data)
})
}