Skip to content

Commit 8ed78bb

Browse files
committed
feat: 2024 day2 part 2 tests
1 parent ddb3e22 commit 8ed78bb

File tree

1 file changed

+46
-31
lines changed

1 file changed

+46
-31
lines changed
Lines changed: 46 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,53 @@
11
package net.leibi.adventofcode2024.day2;
22

3-
import org.junit.jupiter.api.Test;
3+
import static org.assertj.core.api.Assertions.assertThat;
44

55
import java.util.List;
6-
7-
import static org.assertj.core.api.Assertions.assertThat;
6+
import org.junit.jupiter.api.Test;
87

98
class Day2Test {
109

11-
12-
private final Day2 day2 = new Day2();
13-
14-
@Test
15-
void part1Small(){
16-
assertThat((day2.part1(Input.SMALL))).isEqualTo(2L);
17-
}
18-
19-
@Test
20-
void part1Big(){
21-
assertThat((day2.part1(Input.BIG))).isEqualTo(624L);
22-
}
23-
24-
25-
@Test
26-
void isSafe(){
27-
28-
assertThat(day2.isSafe(List.of(7,6,4,2,1))).isTrue();
29-
assertThat(day2.isSafe(List.of(1,2,7,8,9))).isFalse();
30-
assertThat(day2.isSafe(List.of(9,7,6,2,1))).isFalse();
31-
assertThat(day2.isSafe(List.of(1,3,2,4,5))).isFalse();
32-
assertThat(day2.isSafe(List.of(8,6,4,4,1))).isFalse();
33-
assertThat(day2.isSafe(List.of(1,3,6,7,9))).isTrue();
34-
35-
36-
}
37-
38-
}
10+
private final Day2 day2 = new Day2();
11+
12+
@Test
13+
void part1Small() {
14+
assertThat((day2.part1(Input.SMALL))).isEqualTo(2L);
15+
}
16+
17+
@Test
18+
void part1Big() {
19+
assertThat((day2.part1(Input.BIG))).isEqualTo(624L);
20+
}
21+
22+
@Test
23+
void part2Small() {
24+
assertThat((day2.part1(Input.SMALL))).isEqualTo(4L);
25+
}
26+
27+
@Test
28+
void part2Big() {
29+
assertThat((day2.part1(Input.BIG))).isEqualTo(624L);
30+
}
31+
32+
@Test
33+
void isSafe() {
34+
35+
assertThat(day2.isSafe(List.of(7, 6, 4, 2, 1), false)).isTrue();
36+
assertThat(day2.isSafe(List.of(1, 2, 7, 8, 9), false)).isFalse();
37+
assertThat(day2.isSafe(List.of(9, 7, 6, 2, 1), false)).isFalse();
38+
assertThat(day2.isSafe(List.of(1, 3, 2, 4, 5), false)).isFalse();
39+
assertThat(day2.isSafe(List.of(8, 6, 4, 4, 1), false)).isFalse();
40+
assertThat(day2.isSafe(List.of(1, 3, 6, 7, 9), false)).isTrue();
41+
}
42+
43+
@Test
44+
void isSafeWithDampener() {
45+
46+
assertThat(day2.isSafe(List.of(7, 6, 4, 2, 1), true)).isTrue();
47+
assertThat(day2.isSafe(List.of(1, 2, 7, 8, 9), true)).isFalse();
48+
assertThat(day2.isSafe(List.of(9, 7, 6, 2, 1), true)).isFalse();
49+
assertThat(day2.isSafe(List.of(1, 3, 2, 4, 5), true)).isTrue();
50+
assertThat(day2.isSafe(List.of(8, 6, 4, 4, 1), true)).isTrue();
51+
assertThat(day2.isSafe(List.of(1, 3, 6, 7, 9), true)).isTrue();
52+
}
53+
}

0 commit comments

Comments
 (0)