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()) }