-
Notifications
You must be signed in to change notification settings - Fork 1
/
asn_test.go
49 lines (41 loc) · 1.02 KB
/
asn_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
44
45
46
47
48
49
package main
import (
numberRange "./numberRange"
"net/http"
"regexp"
"testing"
)
func TestRangeGenerator(t *testing.T) {
if numberRange.GetRegex(400, 569) != "_4[0-9][0-9]|_5[0-6][0-9]" {
t.Error("Failed generating correct regex")
}
}
func TestPostiveMatch(t *testing.T) {
/* test for my home AS196922 , Hofmeir Media GmbH Datacenter */
/* positive match */
regex := numberRange.GetRegex(196608, 197631)
positiveMatch, err := regexp.Compile(regex)
if err != nil {
t.Error("Cant compile regex")
}
if !positiveMatch.MatchString("_196922") {
t.Error("Regex did not match _196922!")
}
}
func TestNegativeMatch(t *testing.T) {
/* negative match */
regex := numberRange.GetRegex(264605, 265628)
negativeMatch, err := regexp.Compile(regex)
if err != nil {
t.Error("Cant compile regex")
}
if negativeMatch.MatchString("_196922") {
t.Error("Regex did match 196922!")
}
}
func TestRechabilityIANA(t *testing.T) {
_, err := http.Get("http://www.iana.org")
if err != nil {
t.Error("Cant connect to iana.org")
}
}