-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDay21KtTest.kt
44 lines (36 loc) · 1.65 KB
/
Day21KtTest.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 aoc2016.day21
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
internal class Day21KtTest {
private val basePath = "src/main/kotlin/aoc2016/day21/"
@Test
fun readInputToListAndCompute() {
assertEquals("decab", readInputToListAndCompute("${basePath}testInput", "abcde"))
assertEquals("gbhcefad", readInputToListAndCompute("${basePath}input", "abcdefgh"))
assertEquals("fbgdceah", readInputToListAndCompute("${basePath}input", "gahedfcb"))
}
@Test
fun readInputToListAndComputeReversed() {
assertEquals("gahedfcb", readInputToListAndComputeReversed("${basePath}input", "fbgdceah"))
// assertEquals("abcdefgh", readInputToListAndComputeReversed("${basePath}input", "gbhcefad"))
}
@Test
fun testPositionInstruction() {
assertEquals("ebcda", positionInstruction(4, 0, "abcde", Operation.SWAP))
assertEquals("abcde", positionInstruction(0, 4, "edcba", Operation.REVERSE))
assertEquals("bdeac", positionInstruction(1, 4, "bcdea", Operation.MOVE))
assertEquals("abdec", positionInstruction(3, 0, "bdeac", Operation.MOVE))
}
@Test
fun testSwapLetter() {
assertEquals("abcdef", swapLetter("abcdfe", 'f', 'e'))
assertEquals("ba", swapLetter("ab", 'b', 'a'))
}
@Test
fun testRotateLeftRight() {
assertEquals("eabcd", rotateLeftRight("abcde", Rotation.RIGHT, 1))
assertEquals("deabc", rotateLeftRight("abcde", Rotation.RIGHT, 2))
assertEquals("bcdea", rotateLeftRight("abcde", Rotation.LEFT, 1))
assertEquals("cdeab", rotateLeftRight("abcde", Rotation.LEFT, 2))
}
}