From 65adea3cf601525c32279a5ae36a23c1cde6a387 Mon Sep 17 00:00:00 2001 From: InigoGutierrez Date: Fri, 29 Jan 2021 15:06:27 +0100 Subject: Started implementing tests for gameBoard. --- tests/test_gameBoard.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 tests/test_gameBoard.py (limited to 'tests') 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() -- cgit v1.2.1