70 lines
2.0 KiB
Kotlin
70 lines
2.0 KiB
Kotlin
package be.vandewalleh.aoc.days
|
|
|
|
import be.vandewalleh.aoc.utils.input.Input
|
|
import be.vandewalleh.aoc.utils.input.createDay
|
|
import org.assertj.core.api.Assertions.assertThat
|
|
import org.junit.jupiter.api.Assertions
|
|
import org.junit.jupiter.api.Nested
|
|
import org.junit.jupiter.api.Test
|
|
|
|
class Day04Test {
|
|
|
|
@Nested
|
|
inner class Example {
|
|
private val example = """
|
|
ecl:gry pid:860033327 eyr:2020 hcl:#fffffd
|
|
byr:1937 iyr:2017 cid:147 hgt:183cm
|
|
|
|
iyr:2013 ecl:amb cid:350 eyr:2023 pid:028048884
|
|
hcl:#cfa07d byr:1929
|
|
|
|
hcl:#ae17e1 iyr:2013
|
|
eyr:2024
|
|
ecl:brn pid:760753108 byr:1931
|
|
hgt:179cm
|
|
|
|
hcl:#cfa07d eyr:2025 pid:166559648
|
|
iyr:2011 ecl:brn hgt:59in
|
|
""".trimIndent()
|
|
.let { Input(it) }
|
|
|
|
private val day04 = Day04(example)
|
|
|
|
@Test
|
|
fun parse() {
|
|
val str = """
|
|
[(ecl, gry), (pid, 860033327), (eyr, 2020), (hcl, #fffffd), (byr, 1937), (iyr, 2017), (cid, 147), (hgt, 183cm)]
|
|
[(iyr, 2013), (ecl, amb), (cid, 350), (eyr, 2023), (pid, 028048884), (hcl, #cfa07d), (byr, 1929)]
|
|
[(hcl, #ae17e1), (iyr, 2013), (eyr, 2024), (ecl, brn), (pid, 760753108), (byr, 1931), (hgt, 179cm)]
|
|
[(hcl, #cfa07d), (eyr, 2025), (pid, 166559648), (iyr, 2011), (ecl, brn), (hgt, 59in)]
|
|
""".trimIndent()
|
|
|
|
Assertions.assertEquals(str, day04.entries.joinToString("\n"))
|
|
}
|
|
|
|
@Test
|
|
fun `part1 result`() {
|
|
assertThat(day04.part1()).isEqualTo(2)
|
|
}
|
|
|
|
}
|
|
|
|
@Nested
|
|
inner class RealInput {
|
|
private val day04 = createDay<Day04>()
|
|
|
|
@Test
|
|
fun `part1 result`() {
|
|
assertThat(day04.part1()).isEqualTo(192)
|
|
}
|
|
|
|
@Test
|
|
fun `part2 result`() {
|
|
assertThat(day04.part2())
|
|
.`as`("Part 2 results")
|
|
.isEqualTo(101)
|
|
}
|
|
}
|
|
|
|
}
|