From ffb06c65f1d51ec5b77691a150563a7041802806 Mon Sep 17 00:00:00 2001 From: thomas Date: Tue, 22 Nov 2022 17:46:03 +0100 Subject: [PATCH] adding test board --- connect4/test/board_ut.py | 31 +++++++++++++++++++++++++++++++ src/rules.py | 23 ----------------------- 2 files changed, 31 insertions(+), 23 deletions(-) create mode 100644 connect4/test/board_ut.py delete mode 100644 src/rules.py diff --git a/connect4/test/board_ut.py b/connect4/test/board_ut.py new file mode 100644 index 0000000..f51e1f6 --- /dev/null +++ b/connect4/test/board_ut.py @@ -0,0 +1,31 @@ +import unittest +from src.board import Board +from parameterized import parameterized + +class TestBoard(unittest.TestCase): + @parameterized.expand([ + (8, 8, True), + ]) + def testString(self, nbrow, nbcol, no_exception): + try: + board = Board(nbrow=nbrow, nbcol=nbcol) + except: + self.assertFalse(no_exception) + + @parameterized.expand([ + (0, 1, True), + (0, 2, True), + (0, 0, False), + (10, 1, False), + (10, 2, False), + ]) + def testInsertPiece(self, col, player_id, no_exception): + board = Board(8, 8) + + if no_exception: + self.assertTrue(board.insert_piece_into_column(col, player_id)) + else: + self.assertFalse(board.insert_piece_into_column(col, player_id)) + +if __name__=='__main__': + unittest.main() \ No newline at end of file diff --git a/src/rules.py b/src/rules.py deleted file mode 100644 index 99047f0..0000000 --- a/src/rules.py +++ /dev/null @@ -1,23 +0,0 @@ -class Rules: - def __init__(self): - self.name = None - self.nb_row = None - self.nb_col = None - - def check_board_size(self, board: Board) -> Bool: - """ Checks if the board size is correct. - Entries: - self: the Rules class itself - board -> Board: a board - Output: - correct -> Bool: if True, the board size is correct - """ - correct = True - - if not self.nb_col == board.nb_col: - correct = False - - if not self.nb_row == board.nb_row: - correct = False - - return correct