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{})
| 924 | // assert.Contains(t, ["Hello", "World"], "World") |
| 925 | // assert.Contains(t, {"Hello": "World"}, "Hello") |
| 926 | func Contains(t TestingT, s, contains interface{}, msgAndArgs ...interface{}) bool { |
| 927 | if h, ok := t.(tHelper); ok { |
| 928 | h.Helper() |
| 929 | } |
| 930 | |
| 931 | ok, found := containsElement(s, contains) |
| 932 | if !ok { |
| 933 | return Fail(t, fmt.Sprintf("%#v could not be applied builtin len()", s), msgAndArgs...) |
| 934 | } |
| 935 | if !found { |
| 936 | return Fail(t, fmt.Sprintf("%#v does not contain %#v", s, contains), msgAndArgs...) |
| 937 | } |
| 938 | |
| 939 | return true |
| 940 | |
| 941 | } |
| 942 | |
| 943 | // NotContains asserts that the specified string, list(array, slice...) or map does NOT contain the |
| 944 | // specified substring or element. |
searching dependent graphs…