aboutsummaryrefslogtreecommitdiffstats
path: root/assert/assert_test.go
diff options
context:
space:
mode:
authorEugene Triguba <hello@eugenetriguba.com>2025-10-11 10:32:42 -0400
committerEugene Triguba <hello@eugenetriguba.com>2025-10-11 10:32:42 -0400
commitb362eb8ba12834161e1de038395566c3c1f99d59 (patch)
treed46498d8fe8957b9d28d459663031bbd177c60de /assert/assert_test.go
parentAdd usage example (diff)
downloadcheckmate-b362eb8ba12834161e1de038395566c3c1f99d59.zip
Add Contains and NotContains
Diffstat (limited to 'assert/assert_test.go')
-rw-r--r--assert/assert_test.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/assert/assert_test.go b/assert/assert_test.go
index afe01af..f07b14b 100644
--- a/assert/assert_test.go
+++ b/assert/assert_test.go
@@ -110,6 +110,22 @@ func wrappedAssertNotEqual(t checkmate.TestingT, args []any) {
}
}
+func wrappedAssertContains(t checkmate.TestingT, args []any) {
+ if len(args) > 2 {
+ Contains(t, args[0].(string), args[1].(string), args[2:]...)
+ } else {
+ Contains(t, args[0].(string), args[1].(string))
+ }
+}
+
+func wrappedAssertNotContains(t checkmate.TestingT, args []any) {
+ if len(args) > 2 {
+ NotContains(t, args[0].(string), args[1].(string), args[2:]...)
+ } else {
+ NotContains(t, args[0].(string), args[1].(string))
+ }
+}
+
var passingTestFns = []struct {
name string
assertionFn assertFn
@@ -127,6 +143,8 @@ var passingTestFns = []struct {
{"AssertNotDeepEqual", wrappedAssertNotDeepEqual, []any{5, 6}},
{"AssertEqual", wrappedAssertEqual, []any{5, 5}},
{"AssertNotEqual", wrappedAssertNotEqual, []any{5, 10}},
+ {"AssertContains", wrappedAssertContains, []any{"hello world", "world"}},
+ {"AssertNotContains", wrappedAssertNotContains, []any{"hello world", "goodbye"}},
}
var failingTestFns = []struct {
@@ -146,6 +164,8 @@ var failingTestFns = []struct {
{"AssertNotDeepEqual", wrappedAssertNotDeepEqual, []any{5, 5}},
{"AssertEqual", wrappedAssertEqual, []any{5, 10}},
{"AssertNotEqual", wrappedAssertNotEqual, []any{5, 5}},
+ {"AssertContains", wrappedAssertContains, []any{"hello world", "goodbye"}},
+ {"AssertNotContains", wrappedAssertNotContains, []any{"hello world", "world"}},
}
func TestOptionalMessageAndArgs(t *testing.T) {