예제 #1
0
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)))
		}
	}
}
// NewS32 creates a new *XXHash32 computing the 32bit xxHash checksum starting with the specific seed.
func NewS32(seed uint32) *N.XXHash32 { return N.NewS32(0) }
예제 #3
0
// NewS32 creates a new hash.Hash32 computing the 32bit xxHash checksum starting with the specific seed.
func NewS32(seed uint32) hash.Hash32 {
	return N.NewS32(0)
}