-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtests.py
44 lines (38 loc) · 1.48 KB
/
tests.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
import unittest
from maze import Maze
class Tests(unittest.TestCase):
def test_maze_create_cells(self):
num_cols = 12
num_rows = 10
m1 = Maze(0, 0, num_rows, num_cols, 10, 10)
self.assertEqual(
len(m1._cells),
num_cols,
)
self.assertEqual(
len(m1._cells[0]),
num_rows,
)
def test_entrance_and_exit_are_accessible(self):
num_cols = 12
num_rows = 10
m1 = Maze(0, 0, num_rows, num_cols, 10, 10)
self.assertEqual(m1._cells[0][0].has_left_wall, False)
self.assertEqual(m1._cells[0][0].has_right_wall, False)
self.assertEqual(m1._cells[0][0].has_top_wall, False)
self.assertEqual(m1._cells[0][0].has_bottom_wall, False)
self.assertEqual(m1._cells[num_cols - 1][num_rows - 1].has_left_wall, False)
self.assertEqual(m1._cells[num_cols - 1][num_rows - 1].has_right_wall, False)
self.assertEqual(m1._cells[num_cols - 1][num_rows - 1].has_top_wall, False)
self.assertEqual(m1._cells[num_cols - 1][num_rows - 1].has_bottom_wall, False)
def test_reset_visited_works(self):
num_cols = 12
num_rows = 10
m1 = Maze(0, 0, num_rows, num_cols, 10, 10)
m1.break_walls_r(0, 0)
m1.reset_cells_visited()
for i in range(num_cols):
for j in range(num_rows):
self.assertEqual(m1._cells[i][j].visited, False)
if __name__ == "__main__":
unittest.main()