-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDay22KtTest.kt
46 lines (38 loc) · 1.64 KB
/
Day22KtTest.kt
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
package aoc2018.day22
import util.Coord
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
internal class Day22KtTest {
private val testDepth = 510
private val testTarget = Coord(10, 10)
private val depth = 4002
private val target = Coord(5, 746)
@Test
fun testComputeRegionGeologicIndex() {
val day22 = Day22(testTarget, testDepth)
assertEquals(0, day22.computeRegionGeologicIndex(Coord(0, 0)))
assertEquals(48271, day22.computeRegionGeologicIndex(Coord(0, 1)))
assertEquals(16807, day22.computeRegionGeologicIndex(Coord(1, 0)))
assertEquals(145722555, day22.computeRegionGeologicIndex(Coord(1, 1)))
assertEquals(0, day22.computeRegionGeologicIndex(testTarget))
}
@Test
fun testComputeRegionErosionLevel() {
val day22 = Day22(testTarget, testDepth)
assertEquals(510, day22.computeRegionErosionLevel(Coord(0, 0)))
assertEquals(8415, day22.computeRegionErosionLevel(Coord(0, 1)))
assertEquals(17317, day22.computeRegionErosionLevel(Coord(1, 0)))
assertEquals(1805, day22.computeRegionErosionLevel(Coord(1, 1)))
assertEquals(510, day22.computeRegionErosionLevel(testTarget))
}
@Test
fun testComputeTotalRiskLevel() {
assertEquals(114, Day22(testTarget, testDepth).computeTotalRiskLevel())
assertEquals(4479, Day22(target, depth).computeTotalRiskLevel())
}
@Test
fun testComputeCheapestPath() {
assertEquals(45, Day22(testTarget, testDepth).computeCheapestPath()?.cost)
assertEquals(1032, Day22(target, depth).computeCheapestPath()?.cost)
}
}