Compare commits

...

3 Commits

Author SHA1 Message Date
Charles Antoine NOURY 95bdef0c99 Merge branch 'main' of https://codefirst.iut.uca.fr/git/thomas.barbier/connect4
2 years ago
Charles Antoine NOURY 8113c657a8 [UT; rules] added a test
2 years ago
Charles Antoine NOURY d660da3b7f [rules] added a try except
2 years ago

@ -12,12 +12,12 @@ class Rules:
Output:
correct -> Bool: if True, the board size is correct
"""
correct = True
correct = False
if not self.nb_col == board.nb_col:
correct = False
if not self.nb_row == board.nb_row:
correct = False
try:
if self.nb_col == board.nb_col and self.nb_row == board.nb_row :
correct = True
except Exception:
print("Exception: check_board_size: col and row parameters might are compared to another type")
return correct

@ -0,0 +1,25 @@
import unittest
from parametrized import parametrized
from src.rules import Rules
class TestRules(unittest.TestCase):
@parameterized([
('Joe', 7, 6, True),
('Joe', 10, 10, False),
('Joe', '7', '6', False),
('Joe', 7, '1', False),
('Joe', '1', 6, False),
])
def test_check_board_size(self, name, col, row, no_exception=False):
Rules rules
Board board(name, col, row)
if no_exception:
try:
rules.check_board_sizes(board)
except Exception:
self.assertEqual(no_exception, False)
if __name__ == "__main__":
unittest.main()
Loading…
Cancel
Save