forked from N-R-K/ChibiHash
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchibihash64_test.go
36 lines (34 loc) · 965 Bytes
/
chibihash64_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package chibihashgo
import (
"testing"
)
func TestChibihash641(t *testing.T) {
var tests = []struct {
name string
input string
len0 int
seed uint64
want uint64
}{
// the input-output table
// https://github.com/N-R-K/ChibiHash/issues/1
{"blank1", "", 0, 0, 0x9EA80F3B18E26CFB},
{"blank2", "", 0, 55555, 0x2EED9399FC4AC7E5},
{"hi", "hi", 2, 0, 0xAF98F3924F5C80D6},
{"123", "123", 3, 0, 0x893A5CCA05B0A883},
{"abcdefgh", "abcdefgh", 8, 0, 0x8F922660063E3E75},
{"Helloworld", "Hello, world!", 13, 0, 0x5AF920D8C0EBFE9F},
{"qwerty1", "qwertyuiopasdfghjklzxcvbnm123456", 32, 0, 0x2EF296DB634F6551},
{"qwerty2", "qwertyuiopasdfghjklzxcvbnm123456789", 35, 0, 0x0F56CF3735FFA943},
}
// The execution loop
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
u8arr := []uint8(tt.input)
ans := Chibihash64(u8arr, tt.len0, tt.seed)
if ans != tt.want {
t.Errorf("got %x, want %x", ans, tt.want)
}
})
}
}