summaryrefslogtreecommitdiff
path: root/tests/gobang.go
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2025-02-11 08:28:34 -0300
committerEuAndreh <eu@euandre.org>2025-02-11 08:28:34 -0300
commit60c7553e515122774fecb600197b0910435e7aaa (patch)
tree53eefcf7303d5db068ef175bd69d9327ca69b357 /tests/gobang.go
parentsrc/gobang.go: Add "assertion failed: " prefix to assert error message (diff)
downloadgobang-60c7553e515122774fecb600197b0910435e7aaa.tar.gz
gobang-60c7553e515122774fecb600197b0910435e7aaa.tar.xz
src/gobang.go: Add generic function Must()
Diffstat (limited to 'tests/gobang.go')
-rw-r--r--tests/gobang.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/gobang.go b/tests/gobang.go
index b6039af..c1286cd 100644
--- a/tests/gobang.go
+++ b/tests/gobang.go
@@ -15,6 +15,32 @@ import (
+func test_Must() {
+ TestStart("Must()")
+
+ myErr := errors.New("test error")
+ f := func(shouldError bool) (string, error) {
+ if shouldError {
+ return "UNSEEN", myErr
+ }
+
+ return "no error", nil
+ }
+
+
+ Testing("value when error is nil", func() {
+ TAssertEqual(Must(f(false)), "no error")
+ })
+
+ Testing("panic when we have an error", func() {
+ defer func() {
+ TAssertEqual(recover(), myErr)
+ }()
+ Must(f(true))
+ TErrorNil(nil)
+ })
+}
+
func test_Clamp() {
TestStart("Clamp()")
@@ -1307,6 +1333,7 @@ func test_setHostname() {
func MainTest() {
Init()
+ test_Must()
test_Clamp()
test_ValidateSQLTablePrefix()
test_WrapErrors()