-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathas_ips_test.go
44 lines (42 loc) · 962 Bytes
/
as_ips_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
package netlib
import (
"fmt"
"testing"
)
func TestAsIps(t *testing.T) {
var (
input = []string{
"localhost",
"localhost:5144",
"localhost:21",
"127.0.0.2",
"127.0.0.3:47",
"[::1]",
"[::1]:443",
"[FE80:0000:0000:0000:0202:B3FF:FE1E:8329]",
"[FE80:0000:0000:0000:0202:B3FF:FE1E:8329]:445",
"[FE80::0202:B3FF:FE1E:8329]",
"[FE80::0202:B3FF:FE1E:8329]:80",
}
expected = []string{
"127.0.0.1",
"127.0.0.1:5144",
"127.0.0.1:21",
"127.0.0.2",
"127.0.0.3:47",
"[::1]",
"[::1]:443",
"[FE80:0000:0000:0000:0202:B3FF:FE1E:8329]",
"[FE80:0000:0000:0000:0202:B3FF:FE1E:8329]:445",
"[FE80::0202:B3FF:FE1E:8329]",
"[FE80::0202:B3FF:FE1E:8329]:80",
}
)
actual, err := AsIps(input...)
if err != nil {
t.Fatalf("asIps failed: %s", err)
}
if fmt.Sprintf("%+v", actual) != fmt.Sprintf("%+v", expected) {
t.Fatalf("Expected output slice:\n\t%+v\nbut actual was:\n\t%+v", expected, actual)
}
}