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

Function TestArray_ContainsOnly

array_test.go:1224–1375  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1222}
1223
1224func TestArray_ContainsOnly(t *testing.T) {
1225 t.Run("without duplicates", func(t *testing.T) {
1226 cases := []struct {
1227 name string
1228 array []interface{}
1229 value []interface{}
1230 wantContainsOnly chainResult
1231 }{
1232 {
1233 name: "first element",
1234 array: []interface{}{123, "foo"},
1235 value: []interface{}{123},
1236 wantContainsOnly: failure,
1237 },
1238 {
1239 name: "second element",
1240 array: []interface{}{123, "foo"},
1241 value: []interface{}{"foo"},
1242 wantContainsOnly: failure,
1243 },
1244 {
1245 name: "copy of array",
1246 array: []interface{}{123, "foo"},
1247 value: []interface{}{123, "foo"},
1248 wantContainsOnly: success,
1249 },
1250 {
1251 name: "copy of array with one valid value added",
1252 array: []interface{}{123, "foo"},
1253 value: []interface{}{123, "foo", "foo"},
1254 wantContainsOnly: success,
1255 },
1256 {
1257 name: "different order of array",
1258 array: []interface{}{123, "foo"},
1259 value: []interface{}{"foo", 123},
1260 wantContainsOnly: success,
1261 },
1262 {
1263 name: "copy of array with one invalid value added",
1264 array: []interface{}{123, "foo"},
1265 value: []interface{}{"foo", 123, "bar"},
1266 wantContainsOnly: failure,
1267 },
1268 }
1269 for _, tc := range cases {
1270 t.Run(tc.name, func(t *testing.T) {
1271 reporter := newMockReporter(t)
1272
1273 NewArray(reporter, tc.array).ContainsOnly(tc.value...).
1274 chain.assert(t, tc.wantContainsOnly)
1275
1276 NewArray(reporter, tc.array).NotContainsOnly(tc.value...).
1277 chain.assert(t, !tc.wantContainsOnly)
1278 })
1279 }
1280 })
1281

Callers

nothing calls this directly

Calls 6

newMockReporterFunction · 0.85
NewArrayFunction · 0.85
assertMethod · 0.80
ContainsOnlyMethod · 0.80
NotContainsOnlyMethod · 0.80
myIntTypeAlias · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…