diff options
| author | JP Appel <jeanpierre.appel01@gmail.com> | 2024-09-11 22:27:00 -0400 |
|---|---|---|
| committer | JP Appel <jeanpierre.appel01@gmail.com> | 2024-09-11 22:27:00 -0400 |
| commit | a0ab77f2e8f21a7096dc9b0828907d6e4e34fc2d (patch) | |
| tree | 2929f087116ba6b2ee1bd3b2482f8197509313cb /bingo/board_test.go | |
| parent | 4d9a3334fbfea46ac1d17648ac532b8ff8b0363b (diff) | |
Start work on bingo functionality
Created a simple struct for game state.
Started work on board generators and their seeds.
Diffstat (limited to 'bingo/board_test.go')
| -rw-r--r-- | bingo/board_test.go | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/bingo/board_test.go b/bingo/board_test.go new file mode 100644 index 0000000..5df20ee --- /dev/null +++ b/bingo/board_test.go @@ -0,0 +1,60 @@ +package bingo_test + +import ( + "iter" + "testing" + + "github.com/jpappel/bingo-factory/bingo" +) + +func TestRows(t *testing.T) { + g := bingo.Game{} + + testGame := func(size int, length int) { + + g.Checked = make([]bool, size) + + testGroup := func(name string, iter iter.Seq[[]bool]) { + for i := range size { + g.Checked[i] = false + } + for group := range iter { + if len(group) != length { + t.Logf("Mismatching %s length: %d != %d", name, length, len(group)) + t.FailNow() + } + + for i := range length { + if group[i] != false { + t.Errorf("Incorrect value in %s!\n", name) + } + } + } + for i := range size { + g.Checked[i] = true + } + for group := range iter { + if len(group) != length { + t.Logf("Mismatching %s length: %d != %d\n", name, length, len(group)) + } + + for i := range length { + if group[i] != true { + t.Errorf("Incorrect value in %s!\n", name) + } + } + } + } + + testGroup("row", g.Rows(length)) + testGroup("col", g.Cols(length)) + testGroup("diag", g.Diags(length)) + + } + + t.Log("Testing Square Games") + testGame(9, 3) + testGame(25, 5) + t.Log("Testing Non-Square Games") + testGame(22, 2) +} |
