-
Notifications
You must be signed in to change notification settings - Fork 1
/
test_game_base.py
54 lines (43 loc) · 1.79 KB
/
test_game_base.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import unittest
from game_base import GameWithBoard
class TestGameBase(unittest.TestCase):
def setUp(self):
self.game_with_board = GameWithBoard()
def test_board_creation(self):
self.game_with_board.cols = 8
self.game_with_board.rows = 8
result = [
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '],
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '],
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '],
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '],
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '],
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '],
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '],
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '],
]
self.game_with_board.create_board(' ')
self.assertEqual(result, self.game_with_board.get_board)
def test_set_get_value(self):
self.game_with_board.cols = 3
self.game_with_board.rows = 3
self.game_with_board.create_board(' ')
self.game_with_board.set_value(1, 1, 'P')
self.assertEqual('P', self.game_with_board.get_value(1, 1))
def test_out_board_max(self):
self.game_with_board.cols = 3
self.game_with_board.rows = 3
self.game_with_board.create_board(' ')
self.assertFalse(self.game_with_board.in_board(3, 3))
def test_in_board_min(self):
self.game_with_board.cols = 3
self.game_with_board.rows = 3
self.game_with_board.create_board(' ')
self.assertTrue(self.game_with_board.in_board(0, 0))
def test_in_board_max(self):
self.game_with_board.cols = 3
self.game_with_board.rows = 3
self.game_with_board.create_board(' ')
self.assertTrue(self.game_with_board.in_board(2, 2))
if __name__ == "__main__":
unittest.main()