summaryrefslogtreecommitdiff
path: root/libgo/go/hash/fnv/fnv_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'libgo/go/hash/fnv/fnv_test.go')
-rw-r--r--libgo/go/hash/fnv/fnv_test.go39
1 files changed, 39 insertions, 0 deletions
diff --git a/libgo/go/hash/fnv/fnv_test.go b/libgo/go/hash/fnv/fnv_test.go
index 89d39b38ad3..7da15ba9e82 100644
--- a/libgo/go/hash/fnv/fnv_test.go
+++ b/libgo/go/hash/fnv/fnv_test.go
@@ -44,6 +44,20 @@ var golden64a = []golden{
{[]byte{0xe7, 0x1f, 0xa2, 0x19, 0x05, 0x41, 0x57, 0x4b}, "abc"},
}
+var golden128 = []golden{
+ {[]byte{0x6c, 0x62, 0x27, 0x2e, 0x07, 0xbb, 0x01, 0x42, 0x62, 0xb8, 0x21, 0x75, 0x62, 0x95, 0xc5, 0x8d}, ""},
+ {[]byte{0xd2, 0x28, 0xcb, 0x69, 0x10, 0x1a, 0x8c, 0xaf, 0x78, 0x91, 0x2b, 0x70, 0x4e, 0x4a, 0x14, 0x1e}, "a"},
+ {[]byte{0x8, 0x80, 0x94, 0x5a, 0xee, 0xab, 0x1b, 0xe9, 0x5a, 0xa0, 0x73, 0x30, 0x55, 0x26, 0xc0, 0x88}, "ab"},
+ {[]byte{0xa6, 0x8b, 0xb2, 0xa4, 0x34, 0x8b, 0x58, 0x22, 0x83, 0x6d, 0xbc, 0x78, 0xc6, 0xae, 0xe7, 0x3b}, "abc"},
+}
+
+var golden128a = []golden{
+ {[]byte{0x6c, 0x62, 0x27, 0x2e, 0x07, 0xbb, 0x01, 0x42, 0x62, 0xb8, 0x21, 0x75, 0x62, 0x95, 0xc5, 0x8d}, ""},
+ {[]byte{0xd2, 0x28, 0xcb, 0x69, 0x6f, 0x1a, 0x8c, 0xaf, 0x78, 0x91, 0x2b, 0x70, 0x4e, 0x4a, 0x89, 0x64}, "a"},
+ {[]byte{0x08, 0x80, 0x95, 0x44, 0xbb, 0xab, 0x1b, 0xe9, 0x5a, 0xa0, 0x73, 0x30, 0x55, 0xb6, 0x9a, 0x62}, "ab"},
+ {[]byte{0xa6, 0x8d, 0x62, 0x2c, 0xec, 0x8b, 0x58, 0x22, 0x83, 0x6d, 0xbc, 0x79, 0x77, 0xaf, 0x7f, 0x3b}, "abc"},
+}
+
func TestGolden32(t *testing.T) {
testGolden(t, New32(), golden32)
}
@@ -60,6 +74,14 @@ func TestGolden64a(t *testing.T) {
testGolden(t, New64a(), golden64a)
}
+func TestGolden128(t *testing.T) {
+ testGolden(t, New128(), golden128)
+}
+
+func TestGolden128a(t *testing.T) {
+ testGolden(t, New128a(), golden128a)
+}
+
func testGolden(t *testing.T, hash hash.Hash, gold []golden) {
for _, g := range gold {
hash.Reset()
@@ -91,6 +113,13 @@ func TestIntegrity64(t *testing.T) {
func TestIntegrity64a(t *testing.T) {
testIntegrity(t, New64a())
}
+func TestIntegrity128(t *testing.T) {
+ testIntegrity(t, New128())
+}
+
+func TestIntegrity128a(t *testing.T) {
+ testIntegrity(t, New128a())
+}
func testIntegrity(t *testing.T, h hash.Hash) {
data := []byte{'1', '2', 3, 4, 5}
@@ -129,6 +158,8 @@ func testIntegrity(t *testing.T, h hash.Hash) {
if sum64 != binary.BigEndian.Uint64(sum) {
t.Fatalf("Sum()=0x%x, but Sum64()=0x%x", sum, sum64)
}
+ case 16:
+ // There's no Sum128 function, so we don't need to test anything here.
}
}
@@ -148,6 +179,14 @@ func BenchmarkFnv64aKB(b *testing.B) {
benchmarkKB(b, New64a())
}
+func BenchmarkFnv128KB(b *testing.B) {
+ benchmarkKB(b, New128())
+}
+
+func BenchmarkFnv128aKB(b *testing.B) {
+ benchmarkKB(b, New128a())
+}
+
func benchmarkKB(b *testing.B, h hash.Hash) {
b.SetBytes(1024)
data := make([]byte, 1024)