-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhashing_test.go
103 lines (90 loc) · 2.92 KB
/
hashing_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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
package go_memoize
import (
"math"
"testing"
)
func TestHashBoolTest(t *testing.T) {
if hashBool(true) != trueHash {
t.Errorf("Expected %d, got %d", trueHash, hashBool(true))
}
if hashBool(false) != falseHash {
t.Errorf("Expected %d, got %d", falseHash, hashBool(false))
}
}
func TestHashStringTest(t *testing.T) {
expected := hash1("test")
result := hashString(offset64, "test")
if result != expected {
t.Errorf("Expected %d, got %d", expected, result)
}
}
func TestHashIntTest(t *testing.T) {
expected := hash1(12345)
result := hashInt(offset64, 12345)
if result != expected {
t.Errorf("Expected %d, got %d", expected, result)
}
}
func TestHashUintTest(t *testing.T) {
expected := hash1(12345)
result := hashUint(offset64, 12345)
if result != expected {
t.Errorf("Expected %d, got %d", expected, result)
}
}
func TestHashFloatTest(t *testing.T) {
expected := hash1(123.45)
result := hashFloat(offset64, math.Float64bits(123.45))
if result != expected {
t.Errorf("Expected %d, got %d", expected, result)
}
}
func TestHash1Test(t *testing.T) {
expected := hashString(offset64, "test")
result := hash1("test")
if result != expected {
t.Errorf("Expected %d, got %d", expected, result)
}
}
func TestHash2Test(t *testing.T) {
expected := hashString(hashString(offset64, "test1"), "test2")
result := hash2("test1", "test2")
if result != expected {
t.Errorf("Expected %d, got %d", expected, result)
}
}
func TestHash3Test(t *testing.T) {
expected := hashString(hashString(hashString(offset64, "test1"), "test2"), "test3")
result := hash3("test1", "test2", "test3")
if result != expected {
t.Errorf("Expected %d, got %d", expected, result)
}
}
func TestHash4Test(t *testing.T) {
expected := hashString(hashString(hashString(hashString(offset64, "test1"), "test2"), "test3"), "test4")
result := hash4("test1", "test2", "test3", "test4")
if result != expected {
t.Errorf("Expected %d, got %d", expected, result)
}
}
func TestHash5Test(t *testing.T) {
expected := hashString(hashString(hashString(hashString(hashString(offset64, "test1"), "test2"), "test3"), "test4"), "test5")
result := hash5("test1", "test2", "test3", "test4", "test5")
if result != expected {
t.Errorf("Expected %d, got %d", expected, result)
}
}
func TestHash6Test(t *testing.T) {
expected := hashString(hashString(hashString(hashString(hashString(hashString(offset64, "test1"), "test2"), "test3"), "test4"), "test5"), "test6")
result := hash6("test1", "test2", "test3", "test4", "test5", "test6")
if result != expected {
t.Errorf("Expected %d, got %d", expected, result)
}
}
func TestHash7Test(t *testing.T) {
expected := hashString(hashString(hashString(hashString(hashString(hashString(hashString(offset64, "test1"), "test2"), "test3"), "test4"), "test5"), "test6"), "test7")
result := hash7("test1", "test2", "test3", "test4", "test5", "test6", "test7")
if result != expected {
t.Errorf("Expected %d, got %d", expected, result)
}
}