diff --git a/fuzz_test.go b/fuzz_test.go index 8d9b3c9..1e17145 100644 --- a/fuzz_test.go +++ b/fuzz_test.go @@ -2,7 +2,6 @@ package intervals_test import ( "crypto/rand" - "encoding/binary" "slices" "testing" @@ -107,31 +106,28 @@ func FuzzSymmetricDifference(f *testing.F) { } func fuzz(f *testing.F, ff func(t *testing.T, x, y Set[elems.Uint8])) { - data := make([]byte, 8*4) + data := make([]byte, 32) + args := make([]any, len(data)) for i := 0; i < 10; i++ { if _, err := rand.Read(data); err != nil { f.Fatal(err) } - f.Add( - binary.LittleEndian.Uint64(data), - binary.LittleEndian.Uint64(data[8:]), - binary.LittleEndian.Uint64(data[16:]), - binary.LittleEndian.Uint64(data[24:]), - ) - } - - f.Fuzz(func(t *testing.T, x1, x2, y1, y2 uint64) { - xs, ys := make([]byte, 8*2), make([]byte, 8*2) - - for i, u64 := range []uint64{x1, x2} { - binary.LittleEndian.PutUint64(xs[i*8:], u64) + for i, v := range data { + args[i] = v } - for i, u64 := range []uint64{y1, y2} { - binary.LittleEndian.PutUint64(ys[i*8:], u64) - } + f.Add(args...) + } + + f.Fuzz(func( + t *testing.T, + x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, + y0, y1, y2, y3, y4, y5, y6, y7, y8, y9, y10, y11, y12, y13, y14, y15 byte, + ) { + xs := []byte{x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15} + ys := []byte{y0, y1, y2, y3, y4, y5, y6, y7, y8, y9, y10, y11, y12, y13, y14, y15} slices.Sort(xs) slices.Sort(ys)