github.com/zhangyunhao116/wyhash@v0.4.1-0.20220217162229-7d42996fa899/testutil.go (about) 1 package wyhash 2 3 import ( 4 "math/rand" 5 "testing" 6 ) 7 8 func testSum(t *testing.T, f1, f2 func(p []byte) uint64) { 9 for size := 0; size <= 257; size++ { 10 data := make([]byte, size) 11 for i := range data { 12 data[i] = byte(rand.Intn(256)) 13 } 14 if f1(data) != f2(data) { 15 t.Fatal(size, f1(data), f2(data)) 16 } 17 } 18 } 19 20 func testSumWithSeed(t *testing.T, f1, f2 func(p []byte, seed uint64) uint64) { 21 for size := 0; size <= 257; size++ { 22 data := make([]byte, size) 23 for i := range data { 24 data[i] = byte(rand.Intn(256)) 25 } 26 seed := uint64(rand.Int63()) 27 if f1(data, seed) != f2(data, seed) { 28 t.Fatal(size, f1(data, seed), f2(data, seed)) 29 } 30 } 31 }