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

Function TestArray_Contains

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

Source from the content-addressed store, hash-verified

928}
929
930func TestArray_Contains(t *testing.T) {
931 t.Run("basic", func(t *testing.T) {
932 cases := []struct {
933 name string
934 array []interface{}
935 value interface{}
936 wantContains chainResult
937 }{
938 {
939 name: "first value in array",
940 array: []interface{}{123, "foo"},
941 value: 123,
942 wantContains: success,
943 },
944 {
945 name: "second value in array",
946 array: []interface{}{123, "foo"},
947 value: "foo",
948 wantContains: success,
949 },
950 {
951 name: "value not in array",
952 array: []interface{}{123, "foo"},
953 value: "FOO",
954 wantContains: failure,
955 },
956 {
957 name: "array",
958 array: []interface{}{123, "foo"},
959 value: []interface{}{123, "foo"},
960 wantContains: failure,
961 },
962 }
963
964 for _, tc := range cases {
965 t.Run(tc.name, func(t *testing.T) {
966 reporter := newMockReporter(t)
967
968 NewArray(reporter, tc.array).Contains(tc.value).
969 chain.assert(t, tc.wantContains)
970
971 NewArray(reporter, tc.array).NotContains(tc.value).
972 chain.assert(t, !tc.wantContains)
973 })
974 }
975 })
976
977 t.Run("canonization", func(t *testing.T) {
978 type (
979 myInt int
980 )
981 cases := []struct {
982 name string
983 array []interface{}
984 value interface{}
985 wantContains chainResult
986 }{
987 {

Callers

nothing calls this directly

Calls 6

newMockReporterFunction · 0.85
NewArrayFunction · 0.85
assertMethod · 0.80
myIntTypeAlias · 0.70
ContainsMethod · 0.45
NotContainsMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…