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

Function TestElementsMatch

assert/assertions_test.go:1327–1368  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1325}
1326
1327func TestElementsMatch(t *testing.T) {
1328 t.Parallel()
1329
1330 mockT := new(testing.T)
1331
1332 cases := []struct {
1333 expected interface{}
1334 actual interface{}
1335 result bool
1336 }{
1337 // matching
1338 {nil, nil, true},
1339
1340 {nil, nil, true},
1341 {[]int{}, []int{}, true},
1342 {[]int{1}, []int{1}, true},
1343 {[]int{1, 1}, []int{1, 1}, true},
1344 {[]int{1, 2}, []int{1, 2}, true},
1345 {[]int{1, 2}, []int{2, 1}, true},
1346 {[2]int{1, 2}, [2]int{2, 1}, true},
1347 {[]string{"hello", "world"}, []string{"world", "hello"}, true},
1348 {[]string{"hello", "hello"}, []string{"hello", "hello"}, true},
1349 {[]string{"hello", "hello", "world"}, []string{"hello", "world", "hello"}, true},
1350 {[3]string{"hello", "hello", "world"}, [3]string{"hello", "world", "hello"}, true},
1351 {[]int{}, nil, true},
1352
1353 // not matching
1354 {[]int{1}, []int{1, 1}, false},
1355 {[]int{1, 2}, []int{2, 2}, false},
1356 {[]string{"hello", "hello"}, []string{"hello"}, false},
1357 }
1358
1359 for _, c := range cases {
1360 t.Run(fmt.Sprintf("ElementsMatch(%#v, %#v)", c.expected, c.actual), func(t *testing.T) {
1361 res := ElementsMatch(mockT, c.actual, c.expected)
1362
1363 if res != c.result {
1364 t.Errorf("ElementsMatch(%#v, %#v) should return %v", c.actual, c.expected, c.result)
1365 }
1366 })
1367 }
1368}
1369
1370func TestDiffLists(t *testing.T) {
1371 t.Parallel()

Callers

nothing calls this directly

Calls 3

ElementsMatchFunction · 0.70
ErrorfMethod · 0.65
RunMethod · 0.45

Tested by

no test coverage detected