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
65
66
67
68
69
70
71
72
73
74
75
76
|
package remembering
import (
"os"
"reflect"
"strings"
"testing"
"testing/internal/testdeps"
)
func fn(f *testing.F) {
f.Add("0 profile a\n1 profile b\n", "c\nd", "a")
f.Add("", "x", "x")
f.Fuzz(func(
t *testing.T,
content string,
input string,
choice string,
) {
profile := parseProfile(content)
again := parseProfile(serializeProfile(profile))
if !reflect.DeepEqual(again, profile) {
t.Fatalf(
"roundtrip: %#v != %#v",
again, profile,
)
}
if choice == "" ||
strings.Contains(choice, "\n") {
return
}
lines := splitLines(input)
next := nextProfile(profile, lines, choice)
found := false
for _, entry := range next {
if entry.text == choice {
found = true
}
}
if !found {
t.Fatalf(
"pick %q not learnt in %#v",
choice, next,
)
}
reNext := parseProfile(serializeProfile(next))
if !reflect.DeepEqual(reNext, next) {
t.Fatalf(
"next roundtrip: %#v != %#v",
reNext, next,
)
}
})
}
func MainTest() {
fuzzTargets := []testing.InternalFuzzTarget{
{"fn", fn},
}
deps := testdeps.TestDeps{}
tests := []testing.InternalTest {}
benchmarks := []testing.InternalBenchmark{}
examples := []testing.InternalExample {}
m := testing.MainStart(
deps, tests, benchmarks, fuzzTargets, examples,
)
os.Exit(m.Run())
}
|