# Test that the wrong type given with f.Add will fail.
! go test -run FuzzWrongType fuzz_add_test.go
! stdout ^ok
+stdout '\[string int\], want \[\[\]uint8 int8\]'
stdout FAIL
# Test fatal with testdata seed corpus
}
func FuzzWrongType(f *testing.F) {
- f.Add("hello")
- f.Fuzz(func(*testing.T, []byte) {})
+ f.Add("hello", 50)
+ f.Fuzz(func(*testing.T, []byte, int8) {})
}
-- corpustesting/fuzz_testdata_corpus_test.go --
// provided.
func CheckCorpus(vals []interface{}, types []reflect.Type) error {
if len(vals) != len(types) {
- return fmt.Errorf("wrong number of values in corpus entry %v: want %v", vals, types)
+ return fmt.Errorf("wrong number of values in corpus entry: %d, want %d", len(vals), len(types))
+ }
+ valsT := make([]reflect.Type, len(vals))
+ for valsI, v := range vals {
+ valsT[valsI] = reflect.TypeOf(v)
}
for i := range types {
- if reflect.TypeOf(vals[i]) != types[i] {
- return fmt.Errorf("mismatched types in corpus entry: %v, want %v", vals, types)
+ if valsT[i] != types[i] {
+ return fmt.Errorf("mismatched types in corpus entry: %v, want %v", valsT, types)
}
}
return nil