Skip to content

Commit 21a4e65

Browse files
committed
Don't read the input file on AdventOfCode initialization
Otherwise the subclasses' tests need the full set of input files.
1 parent 447664d commit 21a4e65

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/main/kotlin/de/ronny_h/aoc/AdventOfCode.kt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,19 @@ abstract class AdventOfCode<T>(val year: Int, val day: Int) {
99
abstract fun part1(input: List<String>): T
1010
abstract fun part2(input: List<String>): T
1111

12-
private val input = readInput()
13-
1412
fun run(expectedPart1: T, expectedPart2: T) {
13+
val input = readInput()
1514
println("Day $day $year - ${this::class.simpleName} - part 1")
16-
printAndCheck(::part1, expectedPart1)
15+
printAndCheck(input, ::part1, expectedPart1)
1716
println("Day $day $year - ${this::class.simpleName} - part 2")
18-
printAndCheck(::part2, expectedPart2)
17+
printAndCheck(input, ::part2, expectedPart2)
1918
}
2019

2120
private fun readInput() = Path("src/input/$year/Day${paddedDay()}.txt").readText().trim().lines()
2221

2322
private fun paddedDay(): String = day.toString().padStart(2, '0')
2423

25-
private fun printAndCheck(block: (List<String>) -> T, expected: T) {
24+
private fun printAndCheck(input: List<String>, block: (List<String>) -> T, expected: T) {
2625
printAndCheck(measureTimedValue { block(input) }, expected)
2726
}
2827

0 commit comments

Comments
 (0)