From b45017cdb4d9f723202b2f110e28029f974a7c86 Mon Sep 17 00:00:00 2001 From: Aineopintojen-harjoitustyo-Algoritmit-j Date: Sat, 3 Feb 2024 12:19:51 +0200 Subject: Making tests for readymade board. --- tests/test_board.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'tests') diff --git a/tests/test_board.py b/tests/test_board.py index 750e75f..f664e9c 100644 --- a/tests/test_board.py +++ b/tests/test_board.py @@ -111,3 +111,19 @@ class TestBoardClass(unittest.TestCase): self.assertIn(LevelSpecs[Level.INTERMEDIATE][3], b.get_level_name()) b = Board(level=Level.INTERMEDIATE, width=25, mines=2) self.assertIn("Mukautettu", b.get_level_name()) + + def test_board_invalid(self): + """ Yritetään luoda peli kelvottomalla laudalla """ + b = Board(board=[[0,0,0,0,0],[0,0,0,1],[0,0,0,0,0]]) + self.assertIn(LevelSpecs[Level.BEGINNER][3], b.get_level_name()) + b = Board(board=[[0,0,0,0,0]]) + self.assertIn(LevelSpecs[Level.BEGINNER][3], b.get_level_name()) + b = Board(board=[[0,0,0,0],[0,0,0,0],[0,0,0,0]]) + self.assertIn(LevelSpecs[Level.BEGINNER][3], b.get_level_name()) + + def test_board_valid(self): + """ Luodaan peli kelvollisella laudalla """ + b = Board(board=[[0,0,0,0],[0,0,0,1],[0,0,0,0]]) + self.assertEqual(b.get_width(), 4) + self.assertEqual(b.get_height(), 3) + self.assertEqual(b.get_mines(), 1) -- cgit v1.2.3