MCPcopy Index your code
hub / github.com/gavv/httpexpect / TestString_InList

Function TestString_InList

string_test.go:267–327  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

265}
266
267func TestString_InList(t *testing.T) {
268 t.Run("basic", func(t *testing.T) {
269 cases := []struct {
270 name string
271 str string
272 value []string
273 wantInList chainResult
274 wantInListFold chainResult
275 }{
276 {
277 name: "in list",
278 str: "foo",
279 value: []string{"foo", "bar"},
280 wantInList: success,
281 wantInListFold: success,
282 },
283 {
284 name: "not in list",
285 str: "baz",
286 value: []string{"foo", "bar"},
287 wantInList: failure,
288 wantInListFold: failure,
289 },
290 {
291 name: "different case",
292 str: "FOO",
293 value: []string{"foo", "bar"},
294 wantInList: failure,
295 wantInListFold: success,
296 },
297 }
298
299 for _, tc := range cases {
300 reporter := newMockReporter(t)
301
302 NewString(reporter, tc.str).InList(tc.value...).
303 chain.assert(t, tc.wantInList)
304 NewString(reporter, tc.str).NotInList(tc.value...).
305 chain.assert(t, !tc.wantInList)
306
307 NewString(reporter, tc.str).InListFold(tc.value...).
308 chain.assert(t, tc.wantInListFold)
309 NewString(reporter, tc.str).NotInListFold(tc.value...).
310 chain.assert(t, !tc.wantInListFold)
311 }
312 })
313
314 t.Run("invalid argument", func(t *testing.T) {
315 reporter := newMockReporter(t)
316
317 NewString(reporter, "foo").InList().
318 chain.assert(t, failure)
319 NewString(reporter, "foo").NotInList().
320 chain.assert(t, failure)
321
322 NewString(reporter, "foo").InListFold().
323 chain.assert(t, failure)
324 NewString(reporter, "foo").NotInListFold().

Callers

nothing calls this directly

Calls 7

newMockReporterFunction · 0.85
NewStringFunction · 0.85
assertMethod · 0.80
InListFoldMethod · 0.80
NotInListFoldMethod · 0.80
InListMethod · 0.45
NotInListMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…