summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2025-02-11 11:50:58 -0300
committerEuAndreh <eu@euandre.org>2025-02-11 11:50:58 -0300
commit0ab6903f1d2a2894baff6a81615f3f58ea8fd2ad (patch)
tree0df992d55dbee44ede945cb3cef21db1c6900715 /tests
parentsrc/gobang.go: Add generic function Must() (diff)
downloadgobang-0ab6903f1d2a2894baff6a81615f3f58ea8fd2ad.tar.gz
gobang-0ab6903f1d2a2894baff6a81615f3f58ea8fd2ad.tar.xz
src/gobang.go: Add PanicIf() companion to Must()
Diffstat (limited to 'tests')
-rw-r--r--tests/gobang.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/gobang.go b/tests/gobang.go
index c1286cd..32f6d99 100644
--- a/tests/gobang.go
+++ b/tests/gobang.go
@@ -15,6 +15,27 @@ import (
+func test_PanicIf() {
+ TestStart("PanicIf()")
+
+ myErr := errors.New("test error")
+
+
+ Testing("noop when error is nil", func() {
+ var err error
+ PanicIf(err)
+ PanicIf(nil)
+ })
+
+ Testing("panic when we have an error", func() {
+ defer func() {
+ TAssertEqual(recover(), myErr)
+ }()
+ PanicIf(myErr)
+ TErrorNil(nil)
+ })
+}
+
func test_Must() {
TestStart("Must()")
@@ -1333,6 +1354,7 @@ func test_setHostname() {
func MainTest() {
Init()
+ test_PanicIf()
test_Must()
test_Clamp()
test_ValidateSQLTablePrefix()