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

Function TestIPSCalledTwice

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

Source from the content-addressed store, hash-verified

122}
123
124func TestIPSCalledTwice(t *testing.T) {
125 var ips []net.IP
126 f := setUpIPSFlagSet(&ips)
127
128 in := []string{"192.168.1.2,0:0:0:0:0:0:0:1", "10.0.0.1"}
129 expected := []net.IP{net.ParseIP("192.168.1.2"), net.ParseIP("0:0:0:0:0:0:0:1"), net.ParseIP("10.0.0.1")}
130 argfmt := "ips=%s"
131 arg1 := fmt.Sprintf(argfmt, in[0])
132 arg2 := fmt.Sprintf(argfmt, in[1])
133 err := f.Parse([]string{arg1, arg2})
134 if err != nil {
135 t.Fatal("expected no error; got", err)
136 }
137 for i, v := range ips {
138 if !expected[i].Equal(v) {
139 t.Fatalf("expected ips[%d] to be %s but got: %s", i, expected[i], v)
140 }
141 }
142}
143
144func TestIPSAsSliceValue(t *testing.T) {
145 var ips []net.IP

Callers

nothing calls this directly

Calls 2

setUpIPSFlagSetFunction · 0.85
ParseMethod · 0.65

Tested by

no test coverage detected