-
Notifications
You must be signed in to change notification settings - Fork 119
Expand file tree
/
Copy pathfnv_test.go
More file actions
53 lines (40 loc) · 811 Bytes
/
fnv_test.go
File metadata and controls
53 lines (40 loc) · 811 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package boom
import (
"crypto/rand"
"hash/fnv"
"reflect"
"testing"
)
func TestHash32DefaultFnv(t *testing.T) {
var b []byte
rand.Read(b)
h := fnv.New32()
h.Write(b)
expected := h.Sum32()
got := hash32DefaultFnv(b, nil)
if expected != got {
t.Errorf("Expected %x, got %x", expected, got)
}
}
func TestHash64DefaultFnv(t *testing.T) {
var b []byte
rand.Read(b)
h := fnv.New64()
h.Write(b)
expected := h.Sum64()
got := hash64DefaultFnv(b, nil)
if expected != got {
t.Errorf("Expected %x, got %x", expected, got)
}
}
func TestHash32BytesDefaultFnv(t *testing.T) {
var b []byte
rand.Read(b)
h := fnv.New32()
h.Write(b)
expected := h.Sum(nil)
got := hash32BytesDefaultFnv(b, nil)
if !reflect.DeepEqual(expected, got) {
t.Errorf("Expected %x, got %x", expected, got)
}
}