diff options
| author | EuAndreh <eu@euandre.org> | 2024-12-30 16:33:10 -0300 |
|---|---|---|
| committer | EuAndreh <eu@euandre.org> | 2024-12-30 16:33:10 -0300 |
| commit | 655e61e3f8dc8de92f0ecad3fdc6c79cf85d7d28 (patch) | |
| tree | 60561aab93703ddbadc376bd7427bbb0b2956b74 /tests | |
| parent | src/gobang.go: Deal with nil functions in SomeFnError arguments (diff) | |
| download | gobang-655e61e3f8dc8de92f0ecad3fdc6c79cf85d7d28.tar.gz gobang-655e61e3f8dc8de92f0ecad3fdc6c79cf85d7d28.tar.xz | |
src/gobang.go: Add Clamp()
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/gobang.go | 28 |
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() |
