-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDay05Test.java
68 lines (57 loc) · 2.45 KB
/
Day05Test.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
63
64
65
66
67
68
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.math.BigInteger;
import java.util.List;
import java.util.stream.Stream;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class Day05Test extends AbstractTest {
private Day05 solution;
@BeforeAll
static void setUp() {
INPUT_PATH = "year2023/Day05_Input.txt";
SAMPLE_INPUT_PATH = "year2023/Day05_SampleInput.txt";
}
@BeforeEach
void init() {
solution = new Day05();
}
@ParameterizedTest
@MethodSource("inputDataSource")
void testSolver(Solution.Part part, List<String> inputLines, BigInteger expectedOutput) {
BigInteger computedOutput = solution.solve2(part, inputLines);
assertEquals(expectedOutput, computedOutput);
}
@ParameterizedTest
@MethodSource("sampleDataSource")
void testParseProblem(List<String> sampleInputLines, BigInteger seed, BigInteger expectedLocation) {
Day05.Problem p = this.solution.parseProblem(sampleInputLines);
BigInteger calculatedLocation = p.getMappedValueInAllMaps(seed);
assertEquals(expectedLocation, calculatedLocation);
}
static Stream<Arguments> sampleDataSource() {
List<String> sampleInputLines = getSampleInput();
return Stream.of(
Arguments.of(sampleInputLines, new BigInteger("79"), new BigInteger("82")),
Arguments.of(sampleInputLines, new BigInteger("14"), new BigInteger("43")),
Arguments.of(sampleInputLines, new BigInteger("55"), new BigInteger("86")),
Arguments.of(sampleInputLines, new BigInteger("13"), new BigInteger("35"))
);
}
static Stream<Arguments> inputDataSource() {
List<String> sampleInputLines = getSampleInput();
List<String> inputLines = getInput();
return Stream.of(
Arguments.of(Solution.Part.ONE, sampleInputLines, new BigInteger("35")),
// Arguments.of(Solution.PART_NUMBER.TWO, sampleInputLines, new BigInteger("46"))
//
Arguments.of(Solution.Part.ONE, inputLines, new BigInteger("825516882"))
// Arguments.of(Solution.PART_NUMBER.TWO, inputLines, new BigInteger("35"))
);
}
}