forked from adahn6/aStarWasBorn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tests.py
84 lines (75 loc) · 2.05 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/usr/bin/env python3
import unittest
from astar import *
class TestMazes(unittest.TestCase):
def test_maze_1(self):
"""
This is the maze:
21 22 23 24 25
16 17 18 19 20
11 12 13 14 15
6 7 8 9 10
1 2 3 4 5
Start: 1
Goal: 25
"""
ss = StarSolver()
ss.read_maze_file('input_1.json')
self.assertEqual(
ss.solve_the_maze(ss.start_node, ss.goal_node),
'1 -> 7 -> 13 -> 19 -> 25')
def test_maze_2(self):
"""
This is the maze:
21 22 23 24 25
16 17 18 19 20
11 15
6 7 8 9 10
1 2 3 4 5
Start: 1
Goal: 25
"""
ss = StarSolver()
ss.read_maze_file('input_2.json')
expected_output = [
'1 -> 7 -> 8 -> 9 -> 15 -> 20 -> 25',
'1 -> 6 -> 11 -> 17 -> 23 -> 24 -> 25'
]
actual_output = ss.solve_the_maze(ss.start_node, ss.goal_node)
self.assertTrue(actual_output in expected_output)
def test_maze_3(self):
"""
This is the maze:
11 12 13 14 15
6 7 8 9 10
1 2 3 4 5
Start: 1
Goal: 9
"""
ss = StarSolver()
ss.read_maze_file('input_3.json')
self.assertEqual(
ss.solve_the_maze(ss.start_node, ss.goal_node), '1 -> 2 -> 8 -> 9')
def test_maze_4(self):
"""
This is the maze:
21 22 23 24 25
16 17 18 19 20
11 12 15
6 7 8 9 10
1 2 3 4 5
Start: 1
Goal: 25
"""
ss = StarSolver()
ss.read_maze_file('input_4.json')
expected_outputs = [
'1 -> 7 -> 12 -> 18 -> 24 -> 25',
'1 -> 7 -> 12 -> 18 -> 19 -> 25',
'1 -> 6 -> 12 -> 18 -> 24 -> 25',
'1 -> 6 -> 12 -> 18 -> 19 -> 25'
]
self.assertTrue(
ss.solve_the_maze(ss.start_node, ss.goal_node) in expected_outputs)
if __name__ == '__main__':
unittest.main()