aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorInigoGutierrez <inigogf.95@gmail.com>2021-01-29 15:06:27 +0100
committerInigoGutierrez <inigogf.95@gmail.com>2021-01-29 15:06:27 +0100
commit65adea3cf601525c32279a5ae36a23c1cde6a387 (patch)
treeacc46020c4bbdadd135d718ae6286c313c53b8dc /tests
parentddde2a9a43daf870c26bef33f47abe45b414c3d0 (diff)
downloadimago-65adea3cf601525c32279a5ae36a23c1cde6a387.tar.gz
imago-65adea3cf601525c32279a5ae36a23c1cde6a387.zip
Started implementing tests for gameBoard.
Diffstat (limited to 'tests')
-rw-r--r--tests/test_gameBoard.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/test_gameBoard.py b/tests/test_gameBoard.py
new file mode 100644
index 0000000..2fa1037
--- /dev/null
+++ b/tests/test_gameBoard.py
@@ -0,0 +1,30 @@
+"""Tests for gameBoard module."""
+
+import unittest
+
+from imago.data.enums import Player
+from imago.gameLogic.gameBoard import GameBoard
+
+#from imago.data.enums import Player
+
+TEST_BOARD_SIZE = 19
+
+class TestGameBoard(unittest.TestCase):
+ """Test gameBoard module."""
+
+ def testGetGroupLiberties(self):
+ """Test calculation of group liberties."""
+ board = GameBoard(TEST_BOARD_SIZE)
+
+ #Empty cell liberties
+ self.assertEqual(board.getGroupLiberties(0,0), {})
+ self.assertEqual(board.getGroupLibertiesCount(0,0), 0)
+
+ # Lone stone liberties
+ board.board[3][3] = Player.WHITE
+ self.assertEqual(board.getGroupLiberties(3,3),
+ {(2,3), (3,2), (4,3), (3,4)})
+ self.assertEqual(board.getGroupLibertiesCount(3,3), 4)
+
+if __name__ == '__main__':
+ unittest.main()