-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDay01Test.java
62 lines (50 loc) · 1.83 KB
/
Day01Test.java
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package net.bqc.aoc.year2023;
import net.bqc.aoc.AbstractTest;
import net.bqc.aoc.Solution;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import java.util.List;
import java.util.stream.Stream;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class Day01Test extends AbstractTest {
private Day01 solution;
@BeforeAll
static void setUp() {
INPUT_PATH = "year2023/Day01_Input.txt";
}
@BeforeEach
void init() {
solution = new Day01();
}
@ParameterizedTest
@MethodSource("inputDataSource")
void testSolver(Solution.Part part, List<String> inputLines, long expectedOutput) {
long computedOutput = solution.solve(part, inputLines);
assertEquals(expectedOutput, computedOutput);
}
@ParameterizedTest
@MethodSource("sampleDataSource")
void testParseCalibrationValue(String calibrationLine, long expectedCalibrationValue) {
long parsedCalibrationValue = solution.parseCalibrationValue(calibrationLine);
assertEquals(expectedCalibrationValue, parsedCalibrationValue);
}
static Stream<Arguments> inputDataSource() {
List<String> inputLines = getInput();
return Stream.of(
Arguments.of(Solution.Part.ONE, inputLines, 54953),
Arguments.of(Solution.Part.TWO, inputLines, 53868)
);
}
static Stream<Arguments> sampleDataSource() {
return Stream.of(
Arguments.of("9cbncbxclbvkmfzdnldc", 99),
Arguments.of("1abc2", 12),
Arguments.of("pqr3stu8vwx", 38),
Arguments.of("a1b2c3d4e5f", 15),
Arguments.of("treb7uchet", 77)
);
}
}