aboutsummaryrefslogtreecommitdiff
path: root/internal/hash/hash_func_test.go
blob: 5ce39b4f83928e29d2887b663e8c6c3bc62edd78 (plain)
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
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)
			}
		})
	}
}