-
-
Notifications
You must be signed in to change notification settings - Fork 944
Expand file tree
/
Copy pathfuzz_test.go
More file actions
43 lines (39 loc) · 735 Bytes
/
fuzz_test.go
File metadata and controls
43 lines (39 loc) · 735 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
package pq
import (
"testing"
)
func FuzzNewConnector(f *testing.F) {
f.Add(`host=example.com port=5432 user=libpq password=secret`)
f.Fuzz(func(t *testing.T, dsn string) {
NewConnector(dsn)
})
}
func FuzzParseArray(f *testing.F) {
for _, a := range []string{
`{"hello","world"}`,
`{1,2}`,
`{}`,
`{NULL}`,
`{a}`,
`{a,b}`,
`{{a,b}}`,
`{{a},{b}}`,
`{{{a,b},{c,d},{e,f}}}`,
`{""}`,
`{","}`,
`{",",","}`,
`{{",",","}}`,
`{{","},{","}}`,
`{{{",",","},{",",","},{",",","}}}`,
`{"\"}"}`,
`{"\"","\""}`,
`{{"\"","\""}}`,
`{{"\""},{"\""}}`,
`{{{"\"","\""},{"\"","\""},{"\"","\""}}}`,
} {
f.Add([]byte(a))
}
f.Fuzz(func(t *testing.T, array []byte) {
parseArray(array, []byte{','})
})
}