MCPcopy
hub / github.com/spf13/pflag / TestIPS

Function TestIPS

ip_slice_test.go:44–61  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

42}
43
44func TestIPS(t *testing.T) {
45 var ips []net.IP
46 f := setUpIPSFlagSet(&ips)
47
48 vals := []string{"192.168.1.1", "10.0.0.1", "0:0:0:0:0:0:0:2"}
49 arg := fmt.Sprintf("--ips=%s", strings.Join(vals, ","))
50 err := f.Parse([]string{arg})
51 if err != nil {
52 t.Fatal("expected no error; got", err)
53 }
54 for i, v := range ips {
55 if ip := net.ParseIP(vals[i]); ip == nil {
56 t.Fatalf("invalid string being converted to IP address: %s", vals[i])
57 } else if !ip.Equal(v) {
58 t.Fatalf("expected ips[%d] to be %s but got: %s from GetIPSlice", i, vals[i], v)
59 }
60 }
61}
62
63func TestIPSDefault(t *testing.T) {
64 var ips []net.IP

Callers

nothing calls this directly

Calls 2

setUpIPSFlagSetFunction · 0.85
ParseMethod · 0.65

Tested by

no test coverage detected