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

Method NotContainsOnly

array.go:1501–1545  ·  view source on GitHub ↗

NotContainsOnly is opposite to ContainsOnly. Example: array := NewArray(t, []interface{}{"foo", 123}) array.NotContainsOnly(123) array.NotContainsOnly(123, "foo", "bar") These calls are equivalent: array.NotContainsOnly("a", "b") array.NotContainsOnly("b", "a")

(values ...interface{})

Source from the content-addressed store, hash-verified

1499// array.NotContainsOnly("a", "b")
1500// array.NotContainsOnly("b", "a")
1501func (a *Array) NotContainsOnly(values ...interface{}) *Array {
1502 opChain := a.chain.enter("NotContainsOnly()")
1503 defer opChain.leave()
1504
1505 if opChain.failed() {
1506 return a
1507 }
1508
1509 elements, ok := canonArray(opChain, values)
1510 if !ok {
1511 return a
1512 }
1513
1514 different := false
1515
1516 for _, element := range elements {
1517 if countElement(a.value, element) == 0 {
1518 different = true
1519 break
1520 }
1521 }
1522
1523 for _, element := range a.value {
1524 if countElement(elements, element) == 0 {
1525 different = true
1526 break
1527 }
1528 }
1529
1530 if !different {
1531 opChain.fail(AssertionFailure{
1532 Type: AssertNotEqual,
1533 Actual: &AssertionValue{a.value},
1534 Expected: &AssertionValue{values},
1535 Reference: &AssertionValue{values},
1536 Errors: []error{
1537 errors.New("expected:" +
1538 " array does not contain only elements from reference array" +
1539 " (at least one distinguishing element needed)"),
1540 },
1541 })
1542 }
1543
1544 return a
1545}
1546
1547// IsOrdered succeeds if every element is not less than the previous element
1548// as defined on the given `less` comparator function.

Callers 2

TestArray_FailedChainFunction · 0.80
TestArray_ContainsOnlyFunction · 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_ContainsOnlyFunction · 0.64