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

Function TestIPNets

ipnet_slice_test.go:56–73  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

54}
55
56func TestIPNets(t *testing.T) {
57 var ips []net.IPNet
58 f := setUpIPNetFlagSet(&ips)
59
60 vals := []string{"192.168.1.1/24", "10.0.0.1/16", "fd00:0:0:0:0:0:0:2/64"}
61 arg := fmt.Sprintf("--cidrs=%s", strings.Join(vals, ","))
62 err := f.Parse([]string{arg})
63 if err != nil {
64 t.Fatal("expected no error; got", err)
65 }
66 for i, v := range ips {
67 if _, cidr, _ := net.ParseCIDR(vals[i]); cidr == nil {
68 t.Fatalf("invalid string being converted to CIDR: %s", vals[i])
69 } else if !equalCIDR(*cidr, v) {
70 t.Fatalf("expected ips[%d] to be %s but got: %s from GetIPSlice", i, vals[i], v)
71 }
72 }
73}
74
75func TestIPNetDefault(t *testing.T) {
76 var cidrs []net.IPNet

Callers

nothing calls this directly

Calls 3

setUpIPNetFlagSetFunction · 0.85
equalCIDRFunction · 0.85
ParseMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…