(t *testing.T)
| 154 | } |
| 155 | |
| 156 | func TestSAWithSpecialChar(t *testing.T) { |
| 157 | var sa []string |
| 158 | f := setUpSAFlagSet(&sa) |
| 159 | |
| 160 | in := []string{"one,two", `"three"`, `"four,five",six`, "seven eight"} |
| 161 | expected := []string{"one,two", `"three"`, `"four,five",six`, "seven eight"} |
| 162 | argfmt := "--sa=%s" |
| 163 | arg1 := fmt.Sprintf(argfmt, in[0]) |
| 164 | arg2 := fmt.Sprintf(argfmt, in[1]) |
| 165 | arg3 := fmt.Sprintf(argfmt, in[2]) |
| 166 | arg4 := fmt.Sprintf(argfmt, in[3]) |
| 167 | err := f.Parse([]string{arg1, arg2, arg3, arg4}) |
| 168 | if err != nil { |
| 169 | t.Fatal("expected no error; got", err) |
| 170 | } |
| 171 | |
| 172 | if len(expected) != len(sa) { |
| 173 | t.Fatalf("expected number of sa to be %d but got: %d", len(expected), len(sa)) |
| 174 | } |
| 175 | for i, v := range sa { |
| 176 | if expected[i] != v { |
| 177 | t.Fatalf("expected sa[%d] to be %s but got: %s", i, expected[i], v) |
| 178 | } |
| 179 | } |
| 180 | |
| 181 | values, err := f.GetStringArray("sa") |
| 182 | if err != nil { |
| 183 | t.Fatal("expected no error; got", err) |
| 184 | } |
| 185 | |
| 186 | if len(expected) != len(values) { |
| 187 | t.Fatalf("expected number of values to be %d but got: %d", len(expected), len(values)) |
| 188 | } |
| 189 | for i, v := range values { |
| 190 | if expected[i] != v { |
| 191 | t.Fatalf("expected got sa[%d] to be %s but got: %s", i, expected[i], v) |
| 192 | } |
| 193 | } |
| 194 | } |
| 195 | |
| 196 | func TestSAAsSliceValue(t *testing.T) { |
| 197 | var sa []string |
nothing calls this directly
no test coverage detected