adding test board

main
Thomas BARBIER 2 years ago
parent 267eb0cd9f
commit ffb06c65f1

@ -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()

@ -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
Loading…
Cancel
Save