From b362eb8ba12834161e1de038395566c3c1f99d59 Mon Sep 17 00:00:00 2001 From: Eugene Triguba Date: Sat, 11 Oct 2025 10:32:42 -0400 Subject: Add Contains and NotContains --- assert/assert.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'assert/assert.go') diff --git a/assert/assert.go b/assert/assert.go index 1bb5b2b..b5bba9c 100644 --- a/assert/assert.go +++ b/assert/assert.go @@ -140,6 +140,28 @@ func NotEqual(t checkmate.TestingT, actual, expected any, msgAndArgs ...any) { } } +// Contains asserts if a string contains a substring. +func Contains(t checkmate.TestingT, s, substr string, msgAndArgs ...any) { + if ht, ok := t.(helperT); ok { + ht.Helper() + } + + if passed := check.Contains(t, s, substr, msgAndArgs...); !passed { + t.FailNow() + } +} + +// NotContains asserts if a string does not contain a substring. +func NotContains(t checkmate.TestingT, s, substr string, msgAndArgs ...any) { + if ht, ok := t.(helperT); ok { + ht.Helper() + } + + if passed := check.NotContains(t, s, substr, msgAndArgs...); !passed { + t.FailNow() + } +} + type helperT interface { Helper() } -- cgit v1.2.3