(t *testing.T)
| 217 | } |
| 218 | |
| 219 | func TestSAWithSquareBrackets(t *testing.T) { |
| 220 | var sa []string |
| 221 | f := setUpSAFlagSet(&sa) |
| 222 | |
| 223 | in := []string{"][]-[", "[a-z]", "[a-z]+"} |
| 224 | expected := []string{"][]-[", "[a-z]", "[a-z]+"} |
| 225 | argfmt := "--sa=%s" |
| 226 | arg1 := fmt.Sprintf(argfmt, in[0]) |
| 227 | arg2 := fmt.Sprintf(argfmt, in[1]) |
| 228 | arg3 := fmt.Sprintf(argfmt, in[2]) |
| 229 | err := f.Parse([]string{arg1, arg2, arg3}) |
| 230 | if err != nil { |
| 231 | t.Fatal("expected no error; got", err) |
| 232 | } |
| 233 | |
| 234 | if len(expected) != len(sa) { |
| 235 | t.Fatalf("expected number of sa to be %d but got: %d", len(expected), len(sa)) |
| 236 | } |
| 237 | for i, v := range sa { |
| 238 | if expected[i] != v { |
| 239 | t.Fatalf("expected sa[%d] to be %s but got: %s", i, expected[i], v) |
| 240 | } |
| 241 | } |
| 242 | |
| 243 | values, err := f.GetStringArray("sa") |
| 244 | if err != nil { |
| 245 | t.Fatal("expected no error; got", err) |
| 246 | } |
| 247 | |
| 248 | if len(expected) != len(values) { |
| 249 | t.Fatalf("expected number of values to be %d but got: %d", len(expected), len(values)) |
| 250 | } |
| 251 | for i, v := range values { |
| 252 | if expected[i] != v { |
| 253 | t.Fatalf("expected got sa[%d] to be %s but got: %s", i, expected[i], v) |
| 254 | } |
| 255 | } |
| 256 | } |
nothing calls this directly
no test coverage detected