コード例 #1
0
ファイル: bugs_test.go プロジェクト: wheelcomplex/xxhash-1
func TestHulkSmash(t *testing.T) {
	const C = 10000
	rnd, typ := rand.New(rand.NewSource(time.Now().UnixNano())), reflect.TypeOf([]byte(nil))
	for i := 0; i < C; i++ {
		v, ok := quick.Value(typ, rnd)
		if !ok {
			t.Fatal("!ok")
		}
		vb := v.Bytes()
		seed := uint64(rnd.Int63())
		x64 := N.NewS64(seed)
		x64.Write(vb)
		if s1, s2 := x64.Sum64(), N.Checksum64S(vb, seed); s1 != s2 {
			t.Fatalf("len(v) = %d: %d != %d, should be %d", len(vb), s1, s2, cxx.Checksum64S(vb, seed))
		}
		x32 := N.NewS32(uint32(seed))
		x32.Write(vb)
		if s1, s2 := x32.Sum32(), N.Checksum32S(vb, uint32(seed)); s1 != s2 {
			t.Fatalf("len(v) = %d: %d != %d, should be %d", len(vb), s1, s2, cxx.Checksum32S(vb, uint32(seed)))
		}
	}
}
コード例 #2
0
// Checksum32S returns the checksum of the input data with the specific seed.
func Checksum32S(in []byte, seed uint32) uint32 { return N.Checksum32S(in, seed) }