diff options
Diffstat (limited to 'tests/test_gameBoard.py')
-rw-r--r-- | tests/test_gameBoard.py | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/tests/test_gameBoard.py b/tests/test_gameBoard.py index 3a4d5a0..8a7b127 100644 --- a/tests/test_gameBoard.py +++ b/tests/test_gameBoard.py @@ -10,20 +10,33 @@ TEST_BOARD_SIZE = 19 class TestGameBoard(unittest.TestCase): """Test gameBoard module.""" - def testGetGroupLiberties(self): - """Test calculation of group liberties.""" + def testGetGroupCounts(self): + """Test calculation of group stones and liberties.""" board = GameBoard(TEST_BOARD_SIZE, TEST_BOARD_SIZE) #Empty cell liberties self.assertEqual(board.getGroupLiberties(0,0), set()) self.assertEqual(board.getGroupLibertiesCount(0,0), 0) - # Lone stone liberties + # Lone stone board.board[3][3] = Player.WHITE + self.assertEqual(board.getGroupVertices(3,3), + {(3,3)}) + self.assertEqual(board.getGroupVerticesCount(3,3), 1) self.assertEqual(board.getGroupLiberties(3,3), {(2,3), (3,2), (4,3), (3,4)}) self.assertEqual(board.getGroupLibertiesCount(3,3), 4) + # L group (don't compute twice liberty inside L) + board.board[3][4] = Player.WHITE + board.board[2][4] = Player.WHITE + self.assertEqual(board.getGroupVertices(3,3), + {(3,3), (3,4), (2,4)}) + self.assertEqual(board.getGroupVerticesCount(3,3), 3) + self.assertEqual(board.getGroupLiberties(3,3), + {(2,3), (3,2), (4,3), (4, 4), (3,5), (2,5), (1,4)}) + self.assertEqual(board.getGroupLibertiesCount(3,3), 7) + def testIsCellEye(self): """Tests the isCellEye method.""" board = GameBoard(TEST_BOARD_SIZE, TEST_BOARD_SIZE) @@ -101,6 +114,5 @@ class TestGameBoard(unittest.TestCase): board.board[9][0] = Player.WHITE self.assertEqual((9, 21), board.score()) - if __name__ == '__main__': unittest.main() |