Fuzz test for N iterations
(t *testing.T, base interface{}, ff interface{}, n int)
| 404 | |
| 405 | // Fuzz test for N iterations |
| 406 | func testTypeFuzzN(t *testing.T, base interface{}, ff interface{}, n int) { |
| 407 | require.Implements(t, (*json.Marshaler)(nil), ff) |
| 408 | require.Implements(t, (*json.Unmarshaler)(nil), ff) |
| 409 | require.Implements(t, (*marshalerFaster)(nil), ff) |
| 410 | require.Implements(t, (*unmarshalFaster)(nil), ff) |
| 411 | |
| 412 | if _, ok := base.(unmarshalFaster); ok { |
| 413 | require.FailNow(t, "base should not have a UnmarshalJSONFFLexer") |
| 414 | } |
| 415 | |
| 416 | if _, ok := base.(marshalerFaster); ok { |
| 417 | require.FailNow(t, "base should not have a MarshalJSONBuf") |
| 418 | } |
| 419 | |
| 420 | f := fuzz.New() |
| 421 | f.NumElements(0, 1+n/40) |
| 422 | f.NilChance(0.2) |
| 423 | f.Funcs(fuzzTime, fuzzTimeSlice) |
| 424 | for i := 0; i < n; i++ { |
| 425 | f.RandSource(rand.New(rand.NewSource(int64(i * 5275)))) |
| 426 | f.Fuzz(base) |
| 427 | f.RandSource(rand.New(rand.NewSource(int64(i * 5275)))) |
| 428 | f.Fuzz(ff) |
| 429 | |
| 430 | testSameMarshal(t, base, ff) |
| 431 | testCycle(t, base, ff) |
| 432 | } |
| 433 | } |
| 434 | |
| 435 | func TestFuzzArray(t *testing.T) { |
| 436 | testTypeFuzz(t, &Tarray{X: [3]int{}}, &Xarray{X: [3]int{}}) |
no test coverage detected
searching dependent graphs…