summaryrefslogtreecommitdiff
path: root/must/must.go
diff options
context:
space:
mode:
authortjp <tjp@ctrl-c.club>2024-06-02 20:04:57 -0600
committertjp <tjp@ctrl-c.club>2024-06-02 20:04:57 -0600
commitb7e284c68c7f34e23ab30ffe95d364f22b6ced4e (patch)
tree743cc1cddb07e5f7e1e82f23d98cec28a38ac94b /must/must.go
initial commitmain
[Not]Equal checks in `assert` and `must` packages
Diffstat (limited to 'must/must.go')
-rw-r--r--must/must.go30
1 files changed, 30 insertions, 0 deletions
diff --git a/must/must.go b/must/must.go
new file mode 100644
index 0000000..67a58dd
--- /dev/null
+++ b/must/must.go
@@ -0,0 +1,30 @@
+// package must contains functions for checking values in unit tests.
+//
+// The functions in this package handle check failures by logging a message
+// containing the relevant values, and aborting the test immediately as failed.
+//
+// For analogues which allow the remainder of the test to run, see package
+// assert.
+package must
+
+import (
+ "testing"
+
+ "git.tjp.lol/assert"
+)
+
+// Equal asserts that two values compare as equal.
+func Equal(t testing.TB, actual, expect any) {
+ t.Helper()
+ if !assert.Equal(t, actual, expect) {
+ t.FailNow()
+ }
+}
+
+// NotEqual asserts that two values compare as unequal.
+func NotEqual(t testing.TB, actual, expect any) {
+ t.Helper()
+ if !assert.NotEqual(t, actual, expect) {
+ t.FailNow()
+ }
+}