-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathhash_test.go
More file actions
37 lines (33 loc) · 917 Bytes
/
hash_test.go
File metadata and controls
37 lines (33 loc) · 917 Bytes
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
package ring
import "testing"
func BenchmarkGenerateMultiHash(b *testing.B) {
data := []byte{0x00, 0x12, 0x34, 0x56, 0x78, 0x00}
buff := make([]byte, len(data))
for i := 0; i < b.N; i++ {
copy(buff, data)
generateMultiHash(buff[1:5])
}
}
func TestGenerateMultiHash(t *testing.T) {
data := []byte{
0x00, 0x12, 0x34, 0x56, 0x78, 0x00,
0x00, 0x12, 0x34, 0x56, 0x78, 0x00,
0x00, 0x12, 0x34, 0x56, 0x78, 0x00,
0x00, 0x12, 0x34, 0x56, 0x78, 0x00,
0x00, 0x12, 0x34, 0x56, 0x78, 0x00,
0x00, 0x12, 0x34, 0x56, 0x78, 0x00,
0x00, 0x12, 0x34, 0x56, 0x78, 0x00,
0x00, 0x12, 0x34, 0x56, 0x78, 0x00,
0x00, 0x12, 0x34, 0x56, 0x78, 0x00,
0x00, 0x12, 0x34, 0x56, 0x78, 0x00,
0x00, 0x12, 0x34, 0x56, 0x78, 0x00,
}
buff := make([]byte, len(data))
copy(buff, data)
generateMultiHash(buff[1:20])
for i := range data {
if data[i] != buff[i] {
t.Fatalf("data not match at index: %v", i)
}
}
}