-
Notifications
You must be signed in to change notification settings - Fork 0
/
SolutionTest.kt
109 lines (95 loc) · 2.95 KB
/
SolutionTest.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
package solutions.day20
import GenericSolutionTest
import org.junit.jupiter.api.Test
import kotlin.test.assertEquals
import kotlin.test.assertTrue
internal class SolutionTest : GenericSolutionTest(Solution()) {
override val expectedPart1Result = "140656720229539"
override val expectedPart2Result = "1885"
private val classUnderTest = Solution()
// 1 0 1 1 0
// 1 1 0 0 1
// 1 1 1 0 0
// 1 0 1 0 1
// 0 1 0 0 0
private val tile = Tile(
1,
listOf(1, 0, 1, 1, 0),
listOf(0, 1, 0, 0, 0),
listOf(1, 1, 1, 1, 0),
listOf(0, 1, 0, 1, 0),
arrayOf(
intArrayOf(1, 0, 0),
intArrayOf(1, 1, 0),
intArrayOf(0, 1, 0),
)
)
// 0 1 0 1 0
// 1 0 0 0 0
// 1 0 1 1 0
// 0 1 1 0 1
// 1 1 1 1 0
private val rotatedTile = Tile(
1,
listOf(0, 1, 0, 1, 0),
listOf(1, 1, 1, 1, 0),
listOf(0, 1, 1, 0, 1),
listOf(0, 0, 0, 1, 0),
arrayOf(
intArrayOf(0, 0, 0),
intArrayOf(0, 1, 1),
intArrayOf(1, 1, 0),
)
)
@Test
fun rotateTileWithoutContentTest() {
classUnderTest.rotateTile(tile, false)
assertEquals(rotatedTile.edgeTop, tile.edgeTop)
assertEquals(rotatedTile.edgeBottom, tile.edgeBottom)
assertEquals(rotatedTile.edgeLeft, tile.edgeLeft)
assertEquals(rotatedTile.edgeRight, tile.edgeRight)
}
@Test
fun rotateTileAndContentTest() {
classUnderTest.rotateTile(tile, true)
assertEquals(rotatedTile.edgeTop, tile.edgeTop)
assertEquals(rotatedTile.edgeBottom, tile.edgeBottom)
assertEquals(rotatedTile.edgeLeft, tile.edgeLeft)
assertEquals(rotatedTile.edgeRight, tile.edgeRight)
assertTrue(rotatedTile.content.contentDeepEquals(tile.content))
}
// 0 1 1 0 1
// 1 0 0 1 1
// 0 0 1 1 1
// 1 0 1 0 1
// 0 0 0 1 0
private val flippedTile = Tile(
1,
listOf(0, 1, 1, 0, 1),
listOf(0, 0, 0, 1, 0),
listOf(0, 1, 0, 1, 0),
listOf(1, 1, 1, 1, 0),
arrayOf(
intArrayOf(0, 0, 1),
intArrayOf(0, 1, 1),
intArrayOf(0, 1, 0),
)
)
@Test
fun flipTileWithoutContentTest() {
classUnderTest.flipTile(tile, false)
assertEquals(flippedTile.edgeTop, tile.edgeTop)
assertEquals(flippedTile.edgeBottom, tile.edgeBottom)
assertEquals(flippedTile.edgeLeft, tile.edgeLeft)
assertEquals(flippedTile.edgeRight, tile.edgeRight)
}
@Test
fun flipTileAndContentTest() {
classUnderTest.flipTile(tile, true)
assertEquals(flippedTile.edgeTop, tile.edgeTop)
assertEquals(flippedTile.edgeBottom, tile.edgeBottom)
assertEquals(flippedTile.edgeLeft, tile.edgeLeft)
assertEquals(flippedTile.edgeRight, tile.edgeRight)
assertTrue(flippedTile.content.contentDeepEquals(tile.content))
}
}