(t *testing.T)
| 91 | } |
| 92 | |
| 93 | func TestIPSWithDefault(t *testing.T) { |
| 94 | var ips []net.IP |
| 95 | f := setUpIPSFlagSetWithDefault(&ips) |
| 96 | |
| 97 | vals := []string{"192.168.1.1", "0:0:0:0:0:0:0:1"} |
| 98 | arg := fmt.Sprintf("--ips=%s", strings.Join(vals, ",")) |
| 99 | err := f.Parse([]string{arg}) |
| 100 | if err != nil { |
| 101 | t.Fatal("expected no error; got", err) |
| 102 | } |
| 103 | for i, v := range ips { |
| 104 | if ip := net.ParseIP(vals[i]); ip == nil { |
| 105 | t.Fatalf("invalid string being converted to IP address: %s", vals[i]) |
| 106 | } else if !ip.Equal(v) { |
| 107 | t.Fatalf("expected ips[%d] to be %s but got: %s", i, vals[i], v) |
| 108 | } |
| 109 | } |
| 110 | |
| 111 | getIPS, err := f.GetIPSlice("ips") |
| 112 | if err != nil { |
| 113 | t.Fatal("got an error from GetIPSlice") |
| 114 | } |
| 115 | for i, v := range getIPS { |
| 116 | if ip := net.ParseIP(vals[i]); ip == nil { |
| 117 | t.Fatalf("invalid string being converted to IP address: %s", vals[i]) |
| 118 | } else if !ip.Equal(v) { |
| 119 | t.Fatalf("expected ips[%d] to be %s but got: %s", i, vals[i], v) |
| 120 | } |
| 121 | } |
| 122 | } |
| 123 | |
| 124 | func TestIPSCalledTwice(t *testing.T) { |
| 125 | var ips []net.IP |
nothing calls this directly
no test coverage detected