-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_test.go
31 lines (27 loc) · 973 Bytes
/
main_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
package main
import (
"testing"
)
func Test_parseandprint(t *testing.T) {
tests := []struct {
name string
ips string
want string
}{
{"test1", "193.51.24.1", "193.51.24.1 (France / AS2200 Renater)"},
{"localhost", "127.0.0.1", "127.0.0.1 (ERROR / AS0 Error db.Country)"},
{"broadcast", "255.255.255.0", "255.255.255.0 (ERROR / AS0 Error db.Country)"},
{"network", "193.51.24.0/24", "193.51.24.0/24 (ERROR / AS0 Error net.parseIP)"},
{"not a ipv4", "289.0.0.1", "289.0.0.1 (ERROR / AS0 Error net.parseIP)"},
{"not a ipv4", "2001::0:0:1", "2001::0:0:1 (ERROR / AS0 Error db.Country)"},
{"DEL '", "193.56.242.17", "193.56.242.17 (France / AS25117 Euro-Information-Europeenne de Traitement de l Information SAS)"},
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := parseandprint(tt.ips); got != tt.want {
t.Errorf("parseandprint() \nreturn \t%v\nwant \t%v", got, tt.want)
}
})
}
}