(t *testing.T)
| 209 | } |
| 210 | |
| 211 | func TestMatch_Values(t *testing.T) { |
| 212 | type wantMatch struct { |
| 213 | target []string |
| 214 | result chainResult |
| 215 | } |
| 216 | |
| 217 | cases := []struct { |
| 218 | name string |
| 219 | submatches []string |
| 220 | wantMatch []wantMatch |
| 221 | }{ |
| 222 | { |
| 223 | name: "nil match instance", |
| 224 | submatches: nil, |
| 225 | wantMatch: []wantMatch{ |
| 226 | {target: nil, result: success}, |
| 227 | {target: []string{""}, result: failure}, |
| 228 | }, |
| 229 | }, |
| 230 | { |
| 231 | name: "empty match instance", |
| 232 | submatches: []string{}, |
| 233 | wantMatch: []wantMatch{ |
| 234 | {target: nil, result: success}, |
| 235 | {target: []string{""}, result: failure}, |
| 236 | }, |
| 237 | }, |
| 238 | { |
| 239 | name: "not empty index 0 only", |
| 240 | submatches: []string{"m0"}, |
| 241 | wantMatch: []wantMatch{ |
| 242 | {target: nil, result: success}, |
| 243 | {target: []string{"m0"}, result: failure}, |
| 244 | }, |
| 245 | }, |
| 246 | { |
| 247 | name: "not empty", |
| 248 | submatches: []string{"m0", "m1", "m2"}, |
| 249 | wantMatch: []wantMatch{ |
| 250 | {target: nil, result: failure}, |
| 251 | {target: []string{"m1"}, result: failure}, |
| 252 | {target: []string{"m2", "m1"}, result: failure}, |
| 253 | {target: []string{"m1", "m2"}, result: success}, |
| 254 | }, |
| 255 | }, |
| 256 | } |
| 257 | |
| 258 | for _, tc := range cases { |
| 259 | t.Run(tc.name, func(t *testing.T) { |
| 260 | reporter := newMockReporter(t) |
| 261 | |
| 262 | for _, match := range tc.wantMatch { |
| 263 | NewMatch(reporter, tc.submatches, nil).HasSubmatches(match.target...). |
| 264 | chain.assert(t, match.result) |
| 265 | |
| 266 | NewMatch(reporter, tc.submatches, nil).NotHasSubmatches(match.target...). |
| 267 | chain.assert(t, !match.result) |
| 268 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…