-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathwordlist_test.go
More file actions
61 lines (51 loc) · 1.18 KB
/
wordlist_test.go
File metadata and controls
61 lines (51 loc) · 1.18 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
58
59
60
61
package httpfuzz
import (
"os"
"testing"
)
func TestWordlistCountIsAccurate(t *testing.T) {
wlFile, err := os.Open("./testdata/useragents.txt")
if err != nil {
t.Fatal(err)
}
wordlist := &Wordlist{File: wlFile}
count, err := wordlist.Count()
if err != nil {
t.Fatal(err)
}
const expectedCount = 5
if count != expectedCount {
t.Fatalf("Expected %d, got %d", expectedCount, count)
}
wordsReceived := 0
for range wordlist.Stream() {
wordsReceived++
if wordsReceived > count {
t.Fatalf("Expected %d words, got %d", count, wordsReceived)
}
}
if wordsReceived < count {
t.Fatalf("Expected %d words, got %d", count, wordsReceived)
}
}
func TestWordlistCountIsAccurateEmptyWordlist(t *testing.T) {
wordlist := &Wordlist{File: nil}
count, err := wordlist.Count()
if err != nil {
t.Fatal(err)
}
const expectedCount = 0
if count != expectedCount {
t.Fatalf("Expected %d, got %d", expectedCount, count)
}
wordsReceived := 0
for range wordlist.Stream() {
wordsReceived++
if wordsReceived > count {
t.Fatalf("Expected %d words, got %d", count, wordsReceived)
}
}
if wordsReceived < count {
t.Fatalf("Expected %d words, got %d", count, wordsReceived)
}
}