aboutsummaryrefslogtreecommitdiffstats
path: root/check/check_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 /check/check_test.go
parentAdd usage example (diff)
downloadcheckmate-b362eb8ba12834161e1de038395566c3c1f99d59.zip
Add Contains and NotContains
Diffstat (limited to 'check/check_test.go')
-rw-r--r--check/check_test.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/check/check_test.go b/check/check_test.go
index 10d3551..a5ab96c 100644
--- a/check/check_test.go
+++ b/check/check_test.go
@@ -109,6 +109,22 @@ func wrappedCheckNotEqual(t checkmate.TestingT, args []any) bool {
}
}
+func wrappedCheckContains(t checkmate.TestingT, args []any) bool {
+ if len(args) > 2 {
+ return Contains(t, args[0].(string), args[1].(string), args[2:]...)
+ } else {
+ return Contains(t, args[0].(string), args[1].(string))
+ }
+}
+
+func wrappedCheckNotContains(t checkmate.TestingT, args []any) bool {
+ if len(args) > 2 {
+ return NotContains(t, args[0].(string), args[1].(string), args[2:]...)
+ } else {
+ return NotContains(t, args[0].(string), args[1].(string))
+ }
+}
+
var passingTestFns = []struct {
name string
fn checkFn
@@ -126,6 +142,8 @@ var passingTestFns = []struct {
{"CheckNotDeepEqual", wrappedCheckNotDeepEqual, []any{5, 6}},
{"CheckEqual", wrappedCheckEqual, []any{5, 5}},
{"CheckNotEqual", wrappedCheckNotEqual, []any{5, 10}},
+ {"CheckContains", wrappedCheckContains, []any{"hello world", "world"}},
+ {"CheckNotContains", wrappedCheckNotContains, []any{"hello world", "goodbye"}},
}
var failingTestFns = []struct {
@@ -145,6 +163,8 @@ var failingTestFns = []struct {
{"CheckNotDeepEqual", wrappedCheckNotDeepEqual, []any{5, 5}},
{"CheckEqual", wrappedCheckEqual, []any{5, 10}},
{"CheckNotEqual", wrappedCheckNotEqual, []any{5, 5}},
+ {"CheckContains", wrappedCheckContains, []any{"hello world", "goodbye"}},
+ {"CheckNotContains", wrappedCheckNotContains, []any{"hello world", "world"}},
}
func TestOptionalMessageAndArgs(t *testing.T) {