MCPcopy
hub / github.com/expr-lang/expr / ElementsMatch

Function ElementsMatch

internal/testify/assert/assertions.go:1086–1105  ·  view source on GitHub ↗

ElementsMatch asserts that the specified listA(array, slice...) is 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 match. assert.ElementsMatch(t, [1, 3, 2, 3], [1, 3, 3, 2])

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

Source from the content-addressed store, hash-verified

1084//
1085// assert.ElementsMatch(t, [1, 3, 2, 3], [1, 3, 3, 2])
1086func ElementsMatch(t TestingT, listA, listB interface{}, msgAndArgs ...interface{}) (ok bool) {
1087 if h, ok := t.(tHelper); ok {
1088 h.Helper()
1089 }
1090 if isEmpty(listA) && isEmpty(listB) {
1091 return true
1092 }
1093
1094 if !isList(t, listA, msgAndArgs...) || !isList(t, listB, msgAndArgs...) {
1095 return false
1096 }
1097
1098 extraA, extraB := diffLists(listA, listB)
1099
1100 if len(extraA) == 0 && len(extraB) == 0 {
1101 return true
1102 }
1103
1104 return Fail(t, formatListDiff(listA, listB, extraA, extraB), msgAndArgs...)
1105}
1106
1107// isList checks that the provided value is array or slice.
1108func isList(t TestingT, list interface{}, msgAndArgs ...interface{}) (ok bool) {

Callers 4

ElementsMatchFunction · 0.92
ElementsMatchfFunction · 0.70
TestElementsMatchFunction · 0.70
ElementsMatchMethod · 0.70

Calls 6

isEmptyFunction · 0.85
isListFunction · 0.85
diffListsFunction · 0.85
formatListDiffFunction · 0.85
FailFunction · 0.70
HelperMethod · 0.45

Tested by 1

TestElementsMatchFunction · 0.56

Used in the wild real call sites across dependent graphs

searching dependent graphs…