-
Notifications
You must be signed in to change notification settings - Fork 0
/
bloomfilter_test.go
43 lines (39 loc) · 1.11 KB
/
bloomfilter_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
package bloomfilter
import "testing"
func TestBloomFilter_Check(t *testing.T) {
b, _ := NewBloomFilter(20000, 0.05)
b.Set([]byte("Hello"))
b.Set([]byte("Python"))
b.Set([]byte(" "))
b.Set([]byte(""))
b.Set([]byte("#$%^&*("))
b.Set([]byte("Today is a big day!"))
b.Set([]byte("Bottle112345"))
b.Set([]byte("123456!@#$%^&*"))
b.Set([]byte(" "))
b.Set([]byte(""))
b.Set([]byte(" Monday "))
b.Set([]byte("a"))
type args struct {
data []byte
}
tests := []struct {
name string
args args
want bool
}{
{name: "case1", args: args{data: []byte(" ")}, want: true},
{name: "case2", args: args{data: []byte("a")}, want: true},
{name: "case3", args: args{data: []byte("Bottle112345")}, want: true},
{name: "case4", args: args{data: []byte("Today is a big day!")}, want: true},
{name: "case5", args: args{data: []byte("c")}, want: false},
{name: "case6", args: args{data: []byte("Today is a great day!")}, want: false},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := b.Check(tt.args.data); got != tt.want {
t.Errorf("Check() = %v, want %v", got, tt.want)
}
})
}
}