summaryrefslogtreecommitdiffstats
path: root/day9/test_init.py
diff options
context:
space:
mode:
Diffstat (limited to 'day9/test_init.py')
-rw-r--r--day9/test_init.py128
1 files changed, 120 insertions, 8 deletions
diff --git a/day9/test_init.py b/day9/test_init.py
index b36eed6..eb889c7 100644
--- a/day9/test_init.py
+++ b/day9/test_init.py
@@ -4,11 +4,123 @@ import os.path
4import day9 4import day9
5 5
6 6
7def test_output_visualization(): 7class TestAssignment:
8 expected = "..##..\n" "...##.\n" ".####.\n" "....#.\n" "s###.." 8 def test_right(self):
9 9 expected = "\n".join(
10 assignment = day9.AssignmentOne(path=os.path.dirname(day9.__file__)) 10 [
11 unique_positions = assignment.unique_tail_positions( 11 "s###..",
12 input=assignment.read_input(True) 12 ]
13 ) 13 )
14 assert expected == assignment.visualize(6, 5, unique_positions) 14
15 input = ["R 4"]
16
17 assignment = day9.AssignmentOne(path=os.path.dirname(day9.__file__))
18 unique_positions = assignment.unique_tail_positions(input=input, length=2)
19
20 assert assignment.visualize(range(6), range(1), unique_positions) == expected
21
22 def test_left(self):
23 expected = "\n".join(
24 [
25 "..###s",
26 ]
27 )
28
29 input = ["L 4"]
30
31 assignment = day9.AssignmentOne(path=os.path.dirname(day9.__file__))
32 unique_positions = assignment.unique_tail_positions(input=input, length=2)
33
34 assert (
35 assignment.visualize(range(-5, 1), range(1), unique_positions) == expected
36 )
37
38 def test_up(self):
39 expected = "\n".join(
40 [
41 ".",
42 ".",
43 "#",
44 "#",
45 "#",
46 "s",
47 ]
48 )
49
50 input = ["U 4"]
51
52 assignment = day9.AssignmentOne(path=os.path.dirname(day9.__file__))
53 unique_positions = assignment.unique_tail_positions(input=input, length=2)
54
55 assert assignment.visualize(range(1), range(6), unique_positions) == expected
56
57 def test_down(self):
58 expected = "\n".join(
59 [
60 "s",
61 "#",
62 "#",
63 "#",
64 ".",
65 ".",
66 ]
67 )
68
69 input = ["D 4"]
70
71 assignment = day9.AssignmentOne(path=os.path.dirname(day9.__file__))
72 unique_positions = assignment.unique_tail_positions(input=input, length=2)
73
74 assert (
75 assignment.visualize(range(1), range(-5, 1), unique_positions) == expected
76 )
77
78
79class TestAssignmentOne:
80 def test_output_visualization(self):
81 expected = "\n".join(["..##..", "...##.", ".####.", "....#.", "s###.."])
82
83 assignment = day9.AssignmentOne(path=os.path.dirname(day9.__file__))
84 unique_positions = assignment.unique_tail_positions(
85 input=assignment.read_input(True), length=2
86 )
87 assert assignment.visualize(range(6), range(5), unique_positions) == expected
88
89
90class TestAssignmentTwo:
91 def test_output_visualization(self):
92 expected = "\n".join(
93 [
94 "..........................",
95 "..........................",
96 "..........................",
97 "..........................",
98 "..........................",
99 "..........................",
100 "..........................",
101 "..........................",
102 "..........................",
103 "#.........................",
104 "#.............###.........",
105 "#............#...#........",
106 ".#..........#.....#.......",
107 "..#..........#.....#......",
108 "...#........#.......#.....",
109 "....#......s.........#....",
110 ".....#..............#.....",
111 "......#............#......",
112 ".......#..........#.......",
113 "........#........#........",
114 ".........########.........",
115 ]
116 )
117
118 assignment = day9.AssignmentTwo(path=os.path.dirname(day9.__file__))
119 unique_positions = assignment.unique_tail_positions(
120 input=assignment.read_input(True),
121 length=10,
122 )
123 assert (
124 assignment.visualize(range(-11, 15), range(-5, 16), unique_positions)
125 == expected
126 )