summaryrefslogtreecommitdiff
path: root/tests/gobang.go
diff options
context:
space:
mode:
Diffstat (limited to 'tests/gobang.go')
-rw-r--r--tests/gobang.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/gobang.go b/tests/gobang.go
index 64e9eb5..d67b99f 100644
--- a/tests/gobang.go
+++ b/tests/gobang.go
@@ -14,6 +14,33 @@ import (
+func test_Clamp() {
+ TestStart("Clamp()")
+
+ Testing("equal values", func() {
+ TAssertEqual(Clamp(0, 0, 0), 0)
+ TAssertEqual(Clamp(1, 1, 1), 1)
+ TAssertEqual(Clamp(1.0, 1.0, 1.0), 1.0)
+ })
+
+ Testing("within range", func() {
+ TAssertEqual(Clamp(5, 0, 10), 5)
+ TAssertEqual(Clamp(1.1, 1.0, 1.2), 1.1)
+ TAssertEqual(Clamp(0, 0, 10), 0)
+ TAssertEqual(Clamp(10, 0, 10), 10)
+ })
+
+ Testing("lower than min", func() {
+ TAssertEqual(Clamp(1, 2, 3), 2)
+ TAssertEqual(Clamp(1.0, 1.1, 1.2), 1.1)
+ })
+
+ Testing("greater than max", func() {
+ TAssertEqual(Clamp(1, 11, 10), 10)
+ TAssertEqual(Clamp(1.2, 1.0, 1.1), 1.1)
+ })
+}
+
func test_ValidateSQLTablePrefix() {
TestStart("ValidateSQLTablePrefix()")
@@ -968,6 +995,7 @@ func test_setHostname() {
func MainTest() {
+ test_Clamp()
test_ValidateSQLTablePrefix()
test_WrapErrors()
test_SomeError()