-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDay14KtTest.kt
48 lines (39 loc) · 1.48 KB
/
Day14KtTest.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
47
48
package aoc2020.day14
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.Assertions.*
internal class Day14KtTest {
private val input = readInputToList("src/main/kotlin/aoc2020/day14/input")
private val input0 = readInputToList("src/main/kotlin/aoc2020/day14/input0")
private val input1 = readInputToList("src/main/kotlin/aoc2020/day14/input1")
@Test
fun readInputToList() {
println(input0)
println(input)
println(input1)
}
@Test
fun testRunInitProgramme() {
assertEquals(165, runInitProgramme(input0))
assertEquals(13476250121721, runInitProgramme(input))
}
@Test
fun testBinaryToDecimalLong() {
assertEquals(0, binaryToDecimal("0"))
assertEquals(1, binaryToDecimal("1"))
assertEquals(1, binaryToDecimal("000000001"))
assertEquals(2, binaryToDecimal("010"))
assertEquals(4, binaryToDecimal("100"))
assertEquals(38762125873, binaryToDecimal("100100000110011001110001101000110001"))
}
@Test
fun testRunInitProgramme2() {
assertEquals(208, runInitProgramme2(input1))
assertEquals(4463708436768, runInitProgramme2(input))
}
@Test
fun generateListOfBinaries() {
assertEquals(listOf("0", "1"), generateListOfBinaries(1))
assertEquals(listOf("00", "01", "10", "11"), generateListOfBinaries(2))
assertEquals(listOf("000", "001", "010", "011", "100", "101", "110", "111"), generateListOfBinaries(3))
}
}