-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbloomwords_test.go
More file actions
57 lines (49 loc) · 1.02 KB
/
Copy pathbloomwords_test.go
File metadata and controls
57 lines (49 loc) · 1.02 KB
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
package bloomwords_test
import (
"testing"
bloomwords "github.com/oosawy/bloomwords"
)
func TestBloomWordsWithCommonWords(t *testing.T) {
bw, err := bloomwords.Init()
if err != nil {
t.Fatalf("Failed to initialize BloomWords: %v", err)
}
commonWords := []string{
"hello",
"world",
"computer",
"programming",
"test",
"function",
"variable",
"algorithm",
"database",
"network",
}
for _, word := range commonWords {
if !bw.Test(word) {
t.Errorf("Expected word '%s' to be found in bloom filter, but it was not", word)
}
}
}
func TestBloomWordsWithNonExistentWords(t *testing.T) {
bw, err := bloomwords.Init()
if err != nil {
t.Fatalf("Failed to initialize BloomWords: %v", err)
}
nonExistentWords := []string{
"xyzabc",
"qwertyu",
"asdfghj",
"zxcvbnm",
"abcdefghijklmnopqrstuvwxyz",
"aaaaaaaaa",
"zzzzzzzzz",
"notarealword",
}
for _, word := range nonExistentWords {
if bw.Test(word) {
t.Logf("Warning: non-existent word '%s' was found (false positive)", word)
}
}
}