-
Notifications
You must be signed in to change notification settings - Fork 8
/
key_test.go
95 lines (92 loc) · 1.51 KB
/
key_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
package ttlcache
import (
"testing"
)
func TestKeys(t *testing.T) {
tt := []struct {
name string
actual uint64
expected uint64
}{
{
name: "IntKey",
actual: IntKey(42),
expected: 42,
},
{
name: "ByteKey",
actual: ByteKey(42),
expected: 42,
},
{
name: "Int8Key",
actual: Int8Key(42),
expected: 42,
},
{
name: "Uint8Key",
actual: Uint8Key(42),
expected: 42,
},
{
name: "Int16Key",
actual: Int16Key(42),
expected: 42,
},
{
name: "Uint16Key",
actual: Uint16Key(42),
expected: 42,
},
{
name: "Int32Key",
actual: Int32Key(42),
expected: 42,
},
{
name: "Uint32Key",
actual: Uint32Key(42),
expected: 42,
},
{
name: "Int64Key",
actual: Int64Key(42),
expected: 42,
},
{
name: "Uint64Key",
actual: Uint64Key(42),
expected: 42,
},
{
name: "BytesKey",
actual: BytesKey([]byte("hello world")),
expected: 13388989860809387070,
},
{
name: "StringKey",
actual: StringKey("hello world"),
expected: 13388989860809387070,
},
{
name: "AnyKey_struct",
actual: AnyKey(struct {
X, Y int
}{
X: 1,
Y: 2,
}),
expected: 9173886622172901187,
},
{
name: "AnyKey_array",
actual: AnyKey([...]int{1, 2, 3}),
expected: 2675078694837399863,
},
}
for _, tc := range tt {
if tc.expected != tc.actual {
t.Errorf("%s expected: %v got: %v", tc.name, tc.expected, tc.actual)
}
}
}