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

Method NotEqualUnordered

array.go:945–993  ·  view source on GitHub ↗

NotEqualUnordered succeeds if array is not equal to another array, ignoring element order. Before comparison, both arrays are converted to canonical form. Example: array := NewArray(t, []interface{}{"foo", 123}) array.NotEqualUnordered([]interface{}{123, "foo", "bar"})

(value interface{})

Source from the content-addressed store, hash-verified

943// array := NewArray(t, []interface{}{"foo", 123})
944// array.NotEqualUnordered([]interface{}{123, "foo", "bar"})
945func (a *Array) NotEqualUnordered(value interface{}) *Array {
946 opChain := a.chain.enter("NotEqualUnordered()")
947 defer opChain.leave()
948
949 if opChain.failed() {
950 return a
951 }
952
953 expected, ok := canonArray(opChain, value)
954 if !ok {
955 return a
956 }
957
958 different := false
959
960 for _, element := range expected {
961 expectedCount := countElement(expected, element)
962 actualCount := countElement(a.value, element)
963
964 if actualCount != expectedCount {
965 different = true
966 break
967 }
968 }
969
970 for _, element := range a.value {
971 expectedCount := countElement(expected, element)
972 actualCount := countElement(a.value, element)
973
974 if actualCount != expectedCount {
975 different = true
976 break
977 }
978 }
979
980 if !different {
981 opChain.fail(AssertionFailure{
982 Type: AssertNotEqual,
983 Actual: &AssertionValue{a.value},
984 Expected: &AssertionValue{value},
985 Reference: &AssertionValue{value},
986 Errors: []error{
987 errors.New("expected: arrays are non-equal (ignoring order)"),
988 },
989 })
990 }
991
992 return a
993}
994
995// Deprecated: use IsEqualUnordered instead.
996func (a *Array) EqualUnordered(value interface{}) *Array {

Callers 2

TestArray_FailedChainFunction · 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