-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_maze_solver.py
More file actions
57 lines (49 loc) · 1.3 KB
/
test_maze_solver.py
File metadata and controls
57 lines (49 loc) · 1.3 KB
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
55
56
57
import unittest
from maze_solver import MazeSolver
class TestMazeSolver(unittest.TestCase):
def test_single_row_maze(self):
"""Test User Story 1: Single row with empty space"""
maze = "### ###"
solver = MazeSolver(maze)
result = solver.find_empty_space()
self.assertEqual(result, 3)
def test_simple_hallway(self):
"""Test User Story 2: Simple hallway navigation"""
maze = """#######
#S #
##### #
# #
# #####
# E#
#######"""
solver = MazeSolver(maze)
path = solver.explore_maze()
self.assertIsNotNone(path)
self.assertEqual(path[0], (1, 1)) # Start
self.assertEqual(path[-1], (5, 5)) # End
def test_maze_with_rooms(self):
"""Test User Story 3: Maze with rooms"""
maze = """#########
#S #
# ##### #
# # # #
# # # # #
# # # # #
# # E#
#########"""
solver = MazeSolver(maze)
path = solver.explore_maze()
self.assertIsNotNone(path)
self.assertTrue(len(path) > 0)
def test_no_solution(self):
"""Test maze with no solution"""
maze = """#####
#S# #
### #
# E#
#####"""
solver = MazeSolver(maze)
path = solver.explore_maze()
self.assertIsNone(path)
if __name__ == '__main__':
unittest.main()