MCPcopy
hub / github.com/stretchr/testify / NotElementsMatch

Function NotElementsMatch

assert/assertions.go:1240–1261  ·  view source on GitHub ↗

NotElementsMatch asserts that the specified listA(array, slice...) is NOT equal to specified listB(array, slice...) ignoring the order of the elements. If there are duplicate elements, the number of appearances of each of them in both lists should not match. This is an inverse of ElementsMatch. ass

(t TestingT, listA, listB interface{}, msgAndArgs ...interface{})

Source from the content-addressed store, hash-verified

1238//
1239// assert.NotElementsMatch(t, [1, 2, 3], [1, 2, 4]) -> true
1240func NotElementsMatch(t TestingT, listA, listB interface{}, msgAndArgs ...interface{}) (ok bool) {
1241 if h, ok := t.(tHelper); ok {
1242 h.Helper()
1243 }
1244 if isEmpty(listA) && isEmpty(listB) {
1245 return Fail(t, "listA and listB contain the same elements", msgAndArgs)
1246 }
1247
1248 if !isList(t, listA, msgAndArgs...) {
1249 return Fail(t, "listA is not a list type", msgAndArgs...)
1250 }
1251 if !isList(t, listB, msgAndArgs...) {
1252 return Fail(t, "listB is not a list type", msgAndArgs...)
1253 }
1254
1255 extraA, extraB := diffLists(listA, listB)
1256 if len(extraA) == 0 && len(extraB) == 0 {
1257 return Fail(t, "listA and listB contain the same elements", msgAndArgs)
1258 }
1259
1260 return true
1261}
1262
1263// Condition uses a Comparison to assert a complex condition.
1264func Condition(t TestingT, comp Comparison, msgAndArgs ...interface{}) bool {

Callers 4

NotElementsMatchFunction · 0.92
NotElementsMatchfFunction · 0.70
TestNotElementsMatchFunction · 0.70
NotElementsMatchMethod · 0.70

Calls 5

isEmptyFunction · 0.85
isListFunction · 0.85
diffListsFunction · 0.85
FailFunction · 0.70
HelperMethod · 0.65

Tested by 1

TestNotElementsMatchFunction · 0.56