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

Function Contains

assert/assertions.go:960–974  ·  view source on GitHub ↗

Contains asserts that the specified string, list(array, slice...) or map contains the specified substring or element. assert.Contains(t, "Hello World", "World") assert.Contains(t, ["Hello", "World"], "World") assert.Contains(t, {"Hello": "World"}, "Hello")

(t TestingT, s, contains interface{}, msgAndArgs ...interface{})

Source from the content-addressed store, hash-verified

958// assert.Contains(t, ["Hello", "World"], "World")
959// assert.Contains(t, {"Hello": "World"}, "Hello")
960func Contains(t TestingT, s, contains interface{}, msgAndArgs ...interface{}) bool {
961 if h, ok := t.(tHelper); ok {
962 h.Helper()
963 }
964
965 ok, found := containsElement(s, contains)
966 if !ok {
967 return Fail(t, fmt.Sprintf("%#v could not be applied builtin len()", s), msgAndArgs...)
968 }
969 if !found {
970 return Fail(t, fmt.Sprintf("%#v does not contain %#v", s, contains), msgAndArgs...)
971 }
972
973 return true
974}
975
976// NotContains asserts that the specified string, list(array, slice...) or map does NOT contain the
977// specified substring or element.

Callers 15

TestRunSuiteFunction · 0.92
TestSuiteLoggingFunction · 0.92
Test_Arguments_DiffFunction · 0.92
ContainsFunction · 0.92
ContainsfFunction · 0.70
TestContainsNotContainsFunction · 0.70
TestLenFunction · 0.70

Calls 3

containsElementFunction · 0.85
FailFunction · 0.70
HelperMethod · 0.65