@@ -91,6 +91,37 @@ class PieceTest: StringSpec({
91
91
}
92
92
}
93
93
}
94
+ " Test Set transformation arithmetic (TETRO_L)" {
95
+ val shape = PieceShape .TETRO_L
96
+ val TID = listOf("NN ", "RN ", "MN ", "LN ", "NY ", "RY ", "MY ", "LY ")
97
+ val SHOULD = (TID zip listOf(
98
+ setOf(Coordinates (0, 0), Coordinates (0, 1), Coordinates (0, 2), Coordinates (1, 2)),
99
+ setOf(Coordinates (0, 0), Coordinates (0, 1), Coordinates (1, 0), Coordinates (2, 0)),
100
+ setOf(Coordinates (0, 0), Coordinates (1, 0), Coordinates (1, 1), Coordinates (1, 2)),
101
+ setOf(Coordinates (0, 1), Coordinates (1, 1), Coordinates (2, 1), Coordinates (2, 0)),
102
+ setOf(Coordinates (1, 0), Coordinates (1, 1), Coordinates (1, 2), Coordinates (0, 2)),
103
+ setOf(Coordinates (0, 0), Coordinates (1, 0), Coordinates (2, 0), Coordinates (2, 1)),
104
+ setOf(Coordinates (1, 0), Coordinates (0, 0), Coordinates (0, 1), Coordinates (0, 2)),
105
+ setOf(Coordinates (0, 0), Coordinates (0, 1), Coordinates (1, 1), Coordinates (2, 1))
106
+ )).toMap()
107
+ val transformations = (TID zip (
108
+ (Rotation .values() zip List (Rotation .values().size) {false}) +
109
+ (Rotation .values() zip List (Rotation .values().size) {true})
110
+ )).toMap()
111
+ val IS = transformations.map {
112
+ it.key to shape.transform(it.value.first, it.value.second)
113
+ }.toMap()
114
+
115
+ TID .forEach {
116
+ try {
117
+ IS [it] shouldBe SHOULD [it]
118
+ } catch (e: AssertionFailedError ) {
119
+ println("Expected : $it Actual :")
120
+ printShapes(SHOULD .getValue(it), IS .getValue(it))
121
+ throw e
122
+ }
123
+ }
124
+ }
94
125
" Piece coordination calculation" {
95
126
val position = Coordinates (2, 2)
96
127
val coordinates = setOf(Coordinates (2, 3), Coordinates (3, 3), Coordinates (3, 2))
0 commit comments