-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathaux_test.go
34 lines (30 loc) · 833 Bytes
/
aux_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
package gonmap
import (
"testing"
)
func TestIsValidHost(t *testing.T) {
var result bool
testSet := map[string]bool{
"192.168.1.1": true,
"255.255.255.255": true,
"888.888.888.888": false,
"192.2.3": false,
"www.google.com": true,
"google.com": true,
"google.com.it.it": false,
"g": false,
"https://www.gloogle.com": false,
"google.com/32": true,
"0-254.4.20.4-7": true,
"0-256.4.20.4-7": false,
"0-254.4.20.4-7/32": true,
"0-254.4.20.4-7/33": false,
"0-254.4.20,21,22.4-7": true,
}
for test, expected := range testSet {
result = isValidHost(test)
if result != expected {
t.Errorf("Test: %s, expected: %t, got: %t", test, expected, result)
}
}
}