Skip to content

Commit ce51ed3

Browse files
committed
updated the test file
1 parent 71e78ae commit ce51ed3

1 file changed

Lines changed: 41 additions & 2 deletions

File tree

tests/test_dynamic_maze_solver.py

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import conftest
2-
from PathPlanning.Dynamic_maze_Solver.dynamic_maze_solver import MazeVisualizer
2+
from PathPlanning.DynamicMazeSolver import dynamic_maze_solver as m
33

44

55
def test_bfs_finds_path():
@@ -13,7 +13,8 @@ def test_bfs_finds_path():
1313
start = (0, 0)
1414
target = (2, 2)
1515

16-
viz = MazeVisualizer(maze, start, target)
16+
# module `dynamic_maze_solver` exposes `MazeVisualizer` class
17+
viz = m.MazeVisualizer(maze, start, target)
1718

1819
path, visited = viz._bfs()
1920

@@ -22,5 +23,43 @@ def test_bfs_finds_path():
2223
assert path[-1] == target
2324

2425

26+
def test_bfs_unreachable_target():
27+
# target is enclosed by walls
28+
maze = [
29+
[0, 1, 0],
30+
[1, 1, 1],
31+
[0, 1, 0]
32+
]
33+
34+
start = (0, 0)
35+
target = (2, 2)
36+
37+
viz = m.MazeVisualizer(maze, start, target)
38+
39+
path, visited = viz._bfs()
40+
41+
assert path is None
42+
assert target not in visited
43+
44+
45+
def test_bfs_start_equals_target():
46+
# trivial case where start == target
47+
maze = [
48+
[0, 0, 0],
49+
[0, 0, 0],
50+
[0, 0, 0]
51+
]
52+
53+
start = (1, 1)
54+
target = start
55+
56+
viz = m.MazeVisualizer(maze, start, target)
57+
58+
path, visited = viz._bfs()
59+
60+
assert path is not None
61+
assert path == [start]
62+
63+
2564
if __name__ == '__main__':
2665
conftest.run_this_test(__file__)

0 commit comments

Comments
 (0)