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{})
| 1266 | // array := NewArray(t, []interface{}{"foo", 123}) |
| 1267 | // array.ContainsAll(123, "foo") |
| 1268 | func (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. |