MCPcopy Create free account
hub / github.com/gavv/httpexpect / TestMatch_Values

Function TestMatch_Values

match_test.go:211–271  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

209}
210
211func 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 }

Callers

nothing calls this directly

Calls 5

newMockReporterFunction · 0.85
NewMatchFunction · 0.85
assertMethod · 0.80
HasSubmatchesMethod · 0.80
NotHasSubmatchesMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…