aboutsummaryrefslogtreecommitdiff
path: root/internal/hash/hash_func_test.go
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2019-01-15 23:40:19 +0100
committerDimitri Sokolyuk <demon@dim13.org>2019-01-15 23:40:19 +0100
commitf99a144f93efd6209f6f7fc7187a680cc435aa4b (patch)
treef70bdb57b8c2f94aa2e485593c88701ec0cef6f5 /internal/hash/hash_func_test.go
parentc911316be5b0ead797f9e0bdd591c9477bf7d5f7 (diff)
adjust interface
Diffstat (limited to 'internal/hash/hash_func_test.go')
-rw-r--r--internal/hash/hash_func_test.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/internal/hash/hash_func_test.go b/internal/hash/hash_func_test.go
new file mode 100644
index 0000000..5ce39b4
--- /dev/null
+++ b/internal/hash/hash_func_test.go
@@ -0,0 +1,28 @@
+package hash
+
+import "testing"
+
+func TestDefaultHash(t *testing.T) {
+ testCases := []struct {
+ key string
+ hash uint32
+ }{
+ {"", 0},
+ {"A", 65},
+ {"AA", 2210},
+ {"AAA", 72995},
+ {"AAAA", 2408900},
+ {"AAAAA", 79493765},
+ {"AAAAAA", 2623294310},
+ {"AAAAAAA", 669366375},
+ {"AAAAAAAA", 614253960},
+ }
+ for _, tc := range testCases {
+ t.Run(tc.key, func(t *testing.T) {
+ x := defaultHash([]byte(tc.key))
+ if x != tc.hash {
+ t.Errorf("got %v, want %v", x, tc.hash)
+ }
+ })
+ }
+}