summaryrefslogtreecommitdiff
path: root/tests/gobang.go
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2025-02-21 09:48:06 -0300
committerEuAndreh <eu@euandre.org>2025-02-23 07:28:42 -0300
commit909ca40a09662edfb8ca68d11dda52273141bf70 (patch)
treec7a017f68bb7cc720ebdd46a1d91a98715ebe245 /tests/gobang.go
parentsrc/gobang.go: Add simplistic PairT type (diff)
downloadgobang-909ca40a09662edfb8ca68d11dda52273141bf70.tar.gz
gobang-909ca40a09662edfb8ca68d11dda52273141bf70.tar.xz
src/gobang.go: Add SetT type alongside SetOf() and Contains() functions
Diffstat (limited to 'tests/gobang.go')
-rw-r--r--tests/gobang.go39
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/gobang.go b/tests/gobang.go
index 56e3978..e6c4ef2 100644
--- a/tests/gobang.go
+++ b/tests/gobang.go
@@ -15,6 +15,43 @@ import (
+func test_SetOf() {
+ TestStart("SetOf()")
+
+ Testing("empty set", func() {
+ expected := SetT[int]{
+ data: map[int]struct{}{
+ },
+ }
+
+ TAssertEqual(SetOf[int](), expected)
+ })
+
+ Testing("equal sets", func() {
+ expected := SetT[int]{
+ data: map[int]struct{}{
+ 1: struct{}{},
+ 2: struct{}{},
+ 3: struct{}{},
+ },
+ }
+
+ TAssertEqual(SetOf(1, 2, 3), expected)
+ })
+}
+
+func test_Contains() {
+ TestStart("Contains()")
+
+ Testing("trivial example usage", func() {
+ s := SetOf(1, 2, 3, 4, 5)
+ TAssertEqual(Contains(s, 0), false)
+ TAssertEqual(Contains(s, 1), true)
+ TAssertEqual(Contains(s, 5), true)
+ TAssertEqual(Contains(s, 6), false)
+ })
+}
+
func test_MapIndexed() {
TestStart("MapIndexed()")
@@ -1444,6 +1481,8 @@ func test_setHostname() {
func MainTest() {
Init()
+ test_SetOf()
+ test_Contains()
test_MapIndexed()
test_Map()
test_Filter()