Fifteen pieces of a games night: Dice, DiceTray, PlayingCard, CardHand, Deck, Chessboard, GoBoard, MahjongTile, Domino, Roulette, CoinFlip, BingoCard, TicTacToe, ScoreTrack and Meeple. Component number 500 is a meeple, which seems right. Dice tumble, coins turn and wheels spin on a cue, a frame at a time, and land at once under Reduce Motion. Hands lift the card you point at and play the one drawn on top; pieces and stones pick the lighter of Lit and Ink for White, so they read in every palette; the computer plays a fair O; FREE is a star in every language. New 12x12 icons: Spade, Club, Diamond, Meeple, King, Queen, Rook, Bishop, Knight and Pawn.
38 lines
877 B
Go
38 lines
877 B
Go
package tabletop
|
|
|
|
import "testing"
|
|
|
|
func TestAnswerWinsBlocksThenFills(t *testing.T) {
|
|
for _, tc := range []struct {
|
|
b [9]int
|
|
want int
|
|
}{
|
|
{[9]int{2, 2, 0, 1, 1, 0, 0, 0, 0}, 2},
|
|
{[9]int{1, 1, 0, 0, 2, 0, 0, 0, 0}, 2},
|
|
{[9]int{1, 0, 0, 0, 0, 0, 0, 0, 0}, 4},
|
|
{[9]int{0, 0, 0, 0, 1, 0, 0, 0, 0}, 0},
|
|
{[9]int{1, 2, 1, 2, 2, 1, 0, 1, 0}, 8}, {[9]int{1, 2, 1, 1, 2, 2, 2, 1, 0}, 8},
|
|
} {
|
|
if got := answer(tc.b); got != tc.want {
|
|
t.Errorf("answer(%v) = %d, want %d", tc.b, got, tc.want)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestFullSeesEveryLine(t *testing.T) {
|
|
lines := [][]int{{0, 1, 2, 3, 4}, {2, 7, 12, 17, 22}, {0, 6, 12, 18, 24}, {4, 8, 12, 16, 20}}
|
|
for _, l := range lines {
|
|
var m [25]bool
|
|
for _, i := range l[:4] {
|
|
m[i] = true
|
|
}
|
|
if full(&m) {
|
|
t.Fatalf("four of %v is full", l)
|
|
}
|
|
m[l[4]] = true
|
|
if !full(&m) {
|
|
t.Fatalf("%v is not full", l)
|
|
}
|
|
}
|
|
}
|