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

Function TestElementsMatch

internal/testify/assert/assertions_test.go:1197–1236  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1195}
1196
1197func TestElementsMatch(t *testing.T) {
1198 mockT := new(testing.T)
1199
1200 cases := []struct {
1201 expected interface{}
1202 actual interface{}
1203 result bool
1204 }{
1205 // matching
1206 {nil, nil, true},
1207
1208 {nil, nil, true},
1209 {[]int{}, []int{}, true},
1210 {[]int{1}, []int{1}, true},
1211 {[]int{1, 1}, []int{1, 1}, true},
1212 {[]int{1, 2}, []int{1, 2}, true},
1213 {[]int{1, 2}, []int{2, 1}, true},
1214 {[2]int{1, 2}, [2]int{2, 1}, true},
1215 {[]string{"hello", "world"}, []string{"world", "hello"}, true},
1216 {[]string{"hello", "hello"}, []string{"hello", "hello"}, true},
1217 {[]string{"hello", "hello", "world"}, []string{"hello", "world", "hello"}, true},
1218 {[3]string{"hello", "hello", "world"}, [3]string{"hello", "world", "hello"}, true},
1219 {[]int{}, nil, true},
1220
1221 // not matching
1222 {[]int{1}, []int{1, 1}, false},
1223 {[]int{1, 2}, []int{2, 2}, false},
1224 {[]string{"hello", "hello"}, []string{"hello"}, false},
1225 }
1226
1227 for _, c := range cases {
1228 t.Run(fmt.Sprintf("ElementsMatch(%#v, %#v)", c.expected, c.actual), func(t *testing.T) {
1229 res := ElementsMatch(mockT, c.actual, c.expected)
1230
1231 if res != c.result {
1232 t.Errorf("ElementsMatch(%#v, %#v) should return %v", c.actual, c.expected, c.result)
1233 }
1234 })
1235 }
1236}
1237
1238func TestDiffLists(t *testing.T) {
1239 tests := []struct {

Callers

nothing calls this directly

Calls 4

RunMethod · 0.80
SprintfMethod · 0.80
ElementsMatchFunction · 0.70
ErrorfMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…