-
Notifications
You must be signed in to change notification settings - Fork 0
/
Day4KtTest.kt
45 lines (35 loc) · 1.54 KB
/
Day4KtTest.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
package aoc2022.day04
import org.junit.jupiter.api.Assertions.*
import org.junit.jupiter.api.Test
internal class Day4KtTest {
private val testInput0 = readInputToRanges("src/main/kotlin/aoc2022/day04/assets/input0")
private val testInput = readInputToRanges("src/main/kotlin/aoc2022/day04/assets/input")
@Test
fun testPart1() {
assertEquals(2, part1(testInput0))
assertEquals(507, part1(testInput))
}
@Test
fun testPart2() {
assertEquals(4, part2(testInput0))
assertEquals(897, part2(testInput))
}
@Test
fun testIsRangeFullyContainedInOther() {
assertTrue(isRangeFullyContainedInOther(Pair(Range(2, 8), Range(3, 7))))
assertTrue(isRangeFullyContainedInOther(Pair(Range(6, 6), Range(4, 6))))
assertTrue(isRangeFullyContainedInOther(Pair(Range(6, 6), Range(4, 6))))
assertTrue(isRangeFullyContainedInOther(Pair(Range(6, 8), Range(8, 8))))
assertFalse(isRangeFullyContainedInOther(Pair(Range(2, 4), Range(6, 8))))
assertFalse(isRangeFullyContainedInOther(Pair(Range(2, 6), Range(4, 8))))
}
@Test
fun testDoRangesOverlap() {
assertTrue(doRangesOverlap(Pair(Range(5, 7), Range(7, 9))))
assertTrue(doRangesOverlap(Pair(Range(2, 8), Range(3, 7))))
assertTrue(doRangesOverlap(Pair(Range(6, 6), Range(4, 6))))
assertTrue(doRangesOverlap(Pair(Range(2, 6), Range(4, 8))))
assertFalse(doRangesOverlap(Pair(Range(2, 4), Range(6, 8))))
assertFalse(doRangesOverlap(Pair(Range(5, 6), Range(3, 4))))
}
}