-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_day12.py
34 lines (29 loc) · 955 Bytes
/
test_day12.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
from day12 import Dijkstra, Hill
import sys
filename = 'inputs/2022/day12-test.txt'
def test_hill_init():
hill = Hill('S', 0, 0)
assert hill.height == ord('a')
assert hill.start
assert not hill.end
assert hill.tentative_distance == 0
hill = Hill('E', 4, 6)
assert hill.height == ord('z')
assert not hill.start
assert hill.end
assert hill.tentative_distance == sys.maxsize
hill = Hill('g', 3, 3)
assert hill.height == ord('g')
assert not hill.start
assert not hill.end
assert hill.tentative_distance == sys.maxsize
def test_dijkstra_init():
dijkstra = Dijkstra(filename)
assert dijkstra.data
assert len(dijkstra.unvisited) == 5 * 8
def test_dijkstra_find_path():
dijkstra = Dijkstra(filename)
assert dijkstra.find_path(dijkstra.start) == 31
def test_dijkstra_find_paths():
dijkstra = Dijkstra(filename)
assert dijkstra.find_path(dijkstra.end, dijkstra.neighbours_down, lambda x: x.height == ord('a')) == 29