-
Notifications
You must be signed in to change notification settings - Fork 0
/
Day6KtTest.kt
46 lines (37 loc) · 1.3 KB
/
Day6KtTest.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 aoc2020.day06
import aoc2020.day04.readInputFile
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.Assertions.*
internal class Day6KtTest {
private val input = readInputFile("src/main/kotlin/aoc2020/day06/input")
private val input0 = readInputFile("src/main/kotlin/aoc2020/day06/input0")
@Test
fun readInput() {
println(input)
println(input0)
}
@Test
fun testCountUniqueLetters() {
assertEquals(2, countUniqueChars("i x i i"))
assertEquals(3, countUniqueChars("ab ac"))
assertEquals(3, countUniqueChars("abc"))
assertEquals(6, countUniqueChars("abcx abcy abcz"))
}
@Test
fun testCountCommonLetters() {
assertEquals(0, countCommonChars("i x i i"))
assertEquals(1, countCommonChars("ab ac"))
assertEquals(3, countCommonChars("abc"))
assertEquals(3, countCommonChars("abcx abcy abcz"))
}
@Test
fun testCountTotalAnswers() {
assertEquals(17, countTotalAnswers(input0, ::countUniqueChars))
assertEquals(6768, countTotalAnswers(input, ::countUniqueChars))
}
@Test
fun testCountCommonAnswers() {
assertEquals(9, countTotalAnswers(input0, ::countCommonChars))
assertEquals(3489, countTotalAnswers(input, ::countCommonChars))
}
}