-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils_test.go
More file actions
42 lines (37 loc) · 863 Bytes
/
utils_test.go
File metadata and controls
42 lines (37 loc) · 863 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
package echobasicauth
import "testing"
func TestEquals(t *testing.T) {
tests := []struct {
a, b string
shouldEqual bool
}{
{"password", "password", true},
{"pass", "word", false},
{"same", "same", true},
{"", "", true},
}
for _, test := range tests {
if equals(test.a, test.b) != test.shouldEqual {
t.Errorf("equals(%q, %q) expected %v", test.a, test.b, test.shouldEqual)
}
}
}
func TestAnonymizeIP(t *testing.T) {
tests := []struct {
input string
expected string
}{
{"", ""},
{"not-an-ip", "not-an-ip"},
{"192.168.1.100", "192.168.1.0"},
{"10.0.0.1", "10.0.0.0"},
{"::1", "::0"},
{"2001:db8::1", "2001:db8::0"},
}
for _, test := range tests {
result := anonymizeIP(test.input)
if result != test.expected {
t.Errorf("anonymizeIP(%q) = %q, expected %q", test.input, result, test.expected)
}
}
}