-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
26 lines (22 loc) · 762 Bytes
/
test.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
from helpers import load_map
MAP_40_ANSWERS = [
(5, 34, [5, 16, 37, 12, 34]),
(5, 5, [5]),
(8, 24, [8, 14, 16, 37, 12, 17, 10, 24])
]
def test(shortest_path_function):
map_40 = load_map('map-40.pickle')
correct = 0
for start, goal, answer_path in MAP_40_ANSWERS:
path = shortest_path_function(map_40, start, goal)
if path == answer_path:
correct += 1
else:
print("For start:", start,
"Goal: ", goal,
"Your path:", path,
"Correct: ", answer_path)
if correct == len(MAP_40_ANSWERS):
print("All tests pass! Congratulations!")
else:
print("You passed", correct, "/", len(MAP_40_ANSWERS), "test cases")