aboutsummaryrefslogtreecommitdiffstats
path: root/bingo/board_test.go
diff options
context:
space:
mode:
authorJP Appel <jeanpierre.appel01@gmail.com>2024-09-28 03:23:36 -0400
committerJP Appel <jeanpierre.appel01@gmail.com>2024-09-28 03:23:36 -0400
commitd93bf6e3f52664c7782b14de54d606b5450d1866 (patch)
tree9c444c2aeeecf9dd71ffcb1f3a32d0a68ed96f7d /bingo/board_test.go
parent854feb079406163a0c64978bb2c66e0f38c2a231 (diff)
Fix board iterators on square boards
Diffstat (limited to 'bingo/board_test.go')
-rw-r--r--bingo/board_test.go25
1 files changed, 11 insertions, 14 deletions
diff --git a/bingo/board_test.go b/bingo/board_test.go
index a48eda5..7bff655 100644
--- a/bingo/board_test.go
+++ b/bingo/board_test.go
@@ -1,7 +1,6 @@
package bingo_test
import (
- "fmt"
"iter"
"testing"
@@ -14,20 +13,20 @@ func TestIters(t *testing.T) {
testGame := func(size int, length int) {
g.Board = make([]bingo.Tile, size)
+ g.Length = length
testGroup := func(name string, iter iter.Seq[[]bingo.Tile]) {
+ t.Log("Testing:", name)
for i := range size {
g.Board[i].Checked = false
}
count := 0
for group := range iter {
- fmt.Println("!")
- if len(group) != length {
- t.Logf("Mismatching %s length: %d != %d", name, length, len(group))
- t.FailNow()
+ if len(group) != g.Length {
+ t.Fatalf("Mismatching %s length: %d != %d", name, g.Length, len(group))
}
- for i := range length {
+ for i := range g.Length {
if group[i].Checked != false {
t.Errorf("Incorrect value in %s!\n", name)
}
@@ -35,19 +34,19 @@ func TestIters(t *testing.T) {
count++
}
- if count != 2 || count != size {
- t.Errorf("Expected to iterate 2 or %d times, iterated %d\n", size, count)
+ if count != 2 && count != length {
+ t.Errorf("Expected to iterate 2 or %d times, iterated %d\n", length, count)
}
for i := range size {
g.Board[i].Checked = true
}
for group := range iter {
- if len(group) != length {
- t.Logf("Mismatching %s length: %d != %d\n", name, length, len(group))
+ if len(group) != g.Length {
+ t.Logf("Mismatching %s length: %d != %d\n", name, g.Length, len(group))
}
- for i := range length {
+ for i := range g.Length {
if group[i].Checked != true {
t.Errorf("Incorrect value in %s!\n", name)
}
@@ -61,9 +60,7 @@ func TestIters(t *testing.T) {
}
- t.Log("Testing Square Games")
testGame(9, 3)
testGame(25, 5)
- t.Log("Testing Non-Square Games")
- testGame(22, 2)
+ testGame(49, 7)
}