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

Method ContainsAll

array.go:1268–1297  ·  view source on GitHub ↗

ContainsAll succeeds if array contains all given elements (in any order). Before comparison, array and all elements are converted to canonical form. Example: array := NewArray(t, []interface{}{"foo", 123}) array.ContainsAll(123, "foo")

(values ...interface{})

Source from the content-addressed store, hash-verified

1266// array := NewArray(t, []interface{}{"foo", 123})
1267// array.ContainsAll(123, "foo")
1268func (a *Array) ContainsAll(values ...interface{}) *Array {
1269 opChain := a.chain.enter("ContainsAll()")
1270 defer opChain.leave()
1271
1272 if opChain.failed() {
1273 return a
1274 }
1275
1276 elements, ok := canonArray(opChain, values)
1277 if !ok {
1278 return a
1279 }
1280
1281 for _, expected := range elements {
1282 if countElement(a.value, expected) == 0 {
1283 opChain.fail(AssertionFailure{
1284 Type: AssertContainsElement,
1285 Actual: &AssertionValue{a.value},
1286 Expected: &AssertionValue{expected},
1287 Reference: &AssertionValue{values},
1288 Errors: []error{
1289 errors.New("expected: array contains element from reference array"),
1290 },
1291 })
1292 break
1293 }
1294 }
1295
1296 return a
1297}
1298
1299// NotContainsAll succeeds if array does not contain at least one of the elements.
1300// Before comparison, array and all elements are converted to canonical form.

Callers 2

TestArray_FailedChainFunction · 0.80
TestArray_ContainsAllFunction · 0.80

Calls 6

canonArrayFunction · 0.85
countElementFunction · 0.85
enterMethod · 0.80
leaveMethod · 0.80
failedMethod · 0.80
failMethod · 0.80

Tested by 2

TestArray_FailedChainFunction · 0.64
TestArray_ContainsAllFunction · 0.64