From 854feb079406163a0c64978bb2c66e0f38c2a231 Mon Sep 17 00:00:00 2001 From: JP Appel Date: Sat, 28 Sep 2024 02:34:22 -0400 Subject: Update test to check group iterators --- bingo/board_test.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'bingo/board_test.go') diff --git a/bingo/board_test.go b/bingo/board_test.go index 8d8b94f..a48eda5 100644 --- a/bingo/board_test.go +++ b/bingo/board_test.go @@ -1,13 +1,14 @@ package bingo_test import ( + "fmt" "iter" "testing" "github.com/jpappel/bingo-factory/bingo" ) -func TestRows(t *testing.T) { +func TestIters(t *testing.T) { g := bingo.Game{} testGame := func(size int, length int) { @@ -18,7 +19,9 @@ func TestRows(t *testing.T) { 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() @@ -29,7 +32,13 @@ func TestRows(t *testing.T) { t.Errorf("Incorrect value in %s!\n", name) } } + count++ } + + if count != 2 || count != size { + t.Errorf("Expected to iterate 2 or %d times, iterated %d\n", size, count) + } + for i := range size { g.Board[i].Checked = true } -- cgit v1.2.3