diff options
Diffstat (limited to 'day12/test_init.py')
| -rw-r--r-- | day12/test_init.py | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/day12/test_init.py b/day12/test_init.py new file mode 100644 index 0000000..f6e78e1 --- /dev/null +++ b/day12/test_init.py | |||
| @@ -0,0 +1,72 @@ | |||
| 1 | from day12 import Node, AssignmentOne, AssignmentTwo | ||
| 2 | |||
| 3 | |||
| 4 | def test_calculate_all_paths_assignment_one(): | ||
| 5 | start = Node(id='start') | ||
| 6 | end = Node(id='end') | ||
| 7 | |||
| 8 | start.nodes.add(end) | ||
| 9 | end.nodes.add(start) | ||
| 10 | |||
| 11 | assert AssignmentOne.calculate_all_paths(start, end) == [ | ||
| 12 | [start, end] | ||
| 13 | ] | ||
| 14 | |||
| 15 | a = Node(id='a') | ||
| 16 | start.nodes = { a } | ||
| 17 | a.nodes = { start, end } | ||
| 18 | end.nodes = { end } | ||
| 19 | |||
| 20 | assert AssignmentOne.calculate_all_paths(start, end) == [ | ||
| 21 | [start, a, end] | ||
| 22 | ] | ||
| 23 | |||
| 24 | b = Node(id='b') | ||
| 25 | start.nodes = { a, b } | ||
| 26 | b.nodes = { start, end } | ||
| 27 | a.nodes = { start, end } | ||
| 28 | end.nodes = { a, b } | ||
| 29 | |||
| 30 | assert sorted(AssignmentOne.calculate_all_paths(start, end)) == sorted([ | ||
| 31 | [start, a, end], | ||
| 32 | [start, b, end] | ||
| 33 | ]) | ||
| 34 | |||
| 35 | a.nodes.add(b) | ||
| 36 | b.nodes.add(a) | ||
| 37 | |||
| 38 | assert sorted(AssignmentOne.calculate_all_paths(start, end)) == sorted([ | ||
| 39 | [start, a, end], | ||
| 40 | [start, a, b, end], | ||
| 41 | [start, b, end], | ||
| 42 | [start, b, a, end] | ||
| 43 | ]) | ||
| 44 | |||
| 45 | a.big = True | ||
| 46 | |||
| 47 | assert sorted(AssignmentOne.calculate_all_paths(start, end)) == sorted([ | ||
| 48 | [start, a, end], | ||
| 49 | [start, a, b, end], | ||
| 50 | [start, a, b, a, end], | ||
| 51 | [start, b, end], | ||
| 52 | [start, b, a, end], | ||
| 53 | ]) | ||
| 54 | |||
| 55 | |||
| 56 | def test_calculate_all_paths_assignment_two(): | ||
| 57 | start = Node(id='start') | ||
| 58 | end = Node(id='end') | ||
| 59 | |||
| 60 | a = Node(id='a') | ||
| 61 | b = Node(id='b') | ||
| 62 | |||
| 63 | start.nodes.add(a) | ||
| 64 | a.nodes.add(b) | ||
| 65 | a.nodes.add(start) | ||
| 66 | b.nodes.add(a) | ||
| 67 | b.nodes.add(end) | ||
| 68 | end.nodes.add(b) | ||
| 69 | |||
| 70 | assert sorted(AssignmentTwo.calculate_all_paths(start, end)) == sorted([ | ||
| 71 | [start, a, b, end] | ||
| 72 | ]) | ||
