Check procs for sub boards.

This commit is contained in:
2019-10-26 00:15:30 +02:00
parent dcddb96f93
commit b0bdb16b4a
4 changed files with 147 additions and 25 deletions

View File

@@ -9,7 +9,41 @@ import unittest
import libmttt
test "debugging":
var metaBoard = createBoard()
metaBoard[0][0][1][1] = mPlayer1
echo metaBoard[0][0].checkBoard()
suite "Test the board result checker":
setup:
var
player1 = Player(name: "Max")
player2 = Player(name: "Adam")
state: GameState = newGame(player1, player2)
test "row checking":
state.board[0][0] = [
[mFree, mFree, mFree],
[mPlayer1, mPlayer1, mPlayer1],
[mFree, mFree, mFree]
]
check checkBoard(state.board[0][0]) == rPlayer1
test "column checking":
state.board[0][0] = [
[mPlayer2, mFree, mPlayer1],
[mPlayer2, mPlayer1, mFree],
[mPlayer2, mPlayer1, mFree]
]
check checkBoard(state.board[0][0]) == rPlayer2
test "check for draw":
state.board[0][0] = [
[mPlayer1, mPlayer2, mPlayer1],
[mPlayer2, mPlayer1, mPlayer1],
[mPlayer2, mPlayer1, mPlayer2]
]
check checkBoard(state.board[0][0]) == rDraw
test "check for open board":
state.board[0][0] = [
[mPlayer1, mPlayer2, mFree],
[mPlayer1, mFree, mPlayer1],
[mFree, mPlayer1, mPlayer2]
]
check checkBoard(state.board[0][0]) == rOpen