NotContainsAny succeeds if none of the given elements are in the array. Before comparison, array and all elements are converted to canonical form. Example: array := NewArray(t, []interface{}{"foo", 123}) array.NotContainsAny("bar", 124) // success array.NotContainsAny(123) // failure
(values ...interface{})
| 1395 | // array.NotContainsAny("bar", 124) // success |
| 1396 | // array.NotContainsAny(123) // failure |
| 1397 | func (a *Array) NotContainsAny(values ...interface{}) *Array { |
| 1398 | opChain := a.chain.enter("NotContainsAny()") |
| 1399 | defer opChain.leave() |
| 1400 | |
| 1401 | if opChain.failed() { |
| 1402 | return a |
| 1403 | } |
| 1404 | |
| 1405 | elements, ok := canonArray(opChain, values) |
| 1406 | if !ok { |
| 1407 | return a |
| 1408 | } |
| 1409 | |
| 1410 | for _, expected := range elements { |
| 1411 | if countElement(a.value, expected) != 0 { |
| 1412 | opChain.fail(AssertionFailure{ |
| 1413 | Type: AssertNotContainsElement, |
| 1414 | Actual: &AssertionValue{a.value}, |
| 1415 | Expected: &AssertionValue{expected}, |
| 1416 | Reference: &AssertionValue{values}, |
| 1417 | Errors: []error{ |
| 1418 | errors.New("expected:" + |
| 1419 | " array does not contain any elements from reference array"), |
| 1420 | }, |
| 1421 | }) |
| 1422 | return a |
| 1423 | } |
| 1424 | } |
| 1425 | |
| 1426 | return a |
| 1427 | } |
| 1428 | |
| 1429 | // ContainsOnly succeeds if array contains all given elements, in any order, and only |
| 1430 | // them, ignoring duplicates. Before comparison, array and all elements are converted |