forked from go-openapi/jsonpointer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfuzz_test.go
More file actions
38 lines (31 loc) · 755 Bytes
/
fuzz_test.go
File metadata and controls
38 lines (31 loc) · 755 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
// SPDX-FileCopyrightText: Copyright (c) 2015-2025 go-swagger maintainers
// SPDX-License-Identifier: Apache-2.0
package jsonpointer
import (
"iter"
"slices"
"strings"
"testing"
"github.com/go-openapi/testify/v2/require"
)
func FuzzParse(f *testing.F) {
// initial seed
cumulated := make([]string, 0, 100)
for generator := range generators() {
f.Add(generator)
cumulated = append(cumulated, generator)
f.Add(strings.Join(cumulated, ""))
}
f.Fuzz(func(t *testing.T, input string) {
require.NotPanics(t, func() {
_, _ = New(input)
})
})
}
func generators() iter.Seq[string] {
return slices.Values([]string{
`a`,
``, `/`, `/`, `/a~1b`, `/a~1b`, `/c%d`, `/e^f`, `/g|h`, `/i\j`, `/k"l`, `/ `, `/m~0n`,
`/foo`, `/0`,
})
}