|
1 | 1 | package sc.plugin2021
|
2 | 2 |
|
| 3 | +import io.kotlintest.data.forall |
3 | 4 | import io.kotlintest.matchers.maps.shouldContain
|
4 | 5 | import io.kotlintest.matchers.maps.shouldContainExactly
|
5 | 6 | import io.kotlintest.shouldBe
|
6 | 7 | import io.kotlintest.specs.StringSpec
|
| 8 | +import io.kotlintest.tables.row |
7 | 9 | import org.opentest4j.AssertionFailedError
|
8 | 10 | import sc.plugin2021.util.*
|
9 | 11 |
|
@@ -162,39 +164,33 @@ class PieceTest: StringSpec({
|
162 | 164 | piece.coordinates shouldBe coordinates
|
163 | 165 | }
|
164 | 166 | "XML conversion" {
|
165 |
| - val pieces = listOf( |
166 |
| - Piece(Color.YELLOW, PieceShape.TETRO_O, Rotation.RIGHT, false), |
167 |
| - Piece(Color.RED, PieceShape.PENTO_Y, Rotation.LEFT, false), |
168 |
| - Piece(Color.BLUE, PieceShape.PENTO_P, Rotation.MIRROR, true), |
169 |
| - Piece(Color.GREEN, PieceShape.TRIO_L, Rotation.NONE, true, Coordinates(5, 9)) |
170 |
| - ) |
171 |
| - |
172 |
| - Configuration.xStream.toXML(pieces[0]) shouldBe """ |
173 |
| - <piece color="YELLOW" kind="TETRO_O" rotation="RIGHT" isFlipped="false"> |
174 |
| - <position x="0" y="0"/> |
175 |
| - </piece> |
176 |
| - """.trimIndent() |
177 |
| - Configuration.xStream.toXML(pieces[1]) shouldBe """ |
178 |
| - <piece color="RED" kind="PENTO_Y" rotation="LEFT" isFlipped="false"> |
179 |
| - <position x="0" y="0"/> |
180 |
| - </piece> |
181 |
| - """.trimIndent() |
182 |
| - Configuration.xStream.toXML(pieces[2]) shouldBe """ |
183 |
| - <piece color="BLUE" kind="PENTO_P" rotation="MIRROR" isFlipped="true"> |
184 |
| - <position x="0" y="0"/> |
185 |
| - </piece> |
186 |
| - """.trimIndent() |
187 |
| - Configuration.xStream.toXML(pieces[3]) shouldBe """ |
188 |
| - <piece color="GREEN" kind="TRIO_L" rotation="NONE" isFlipped="true"> |
189 |
| - <position x="5" y="9"/> |
190 |
| - </piece> |
191 |
| - """.trimIndent() |
192 |
| - |
193 |
| - pieces.forEach{ |
194 |
| - val xml = Configuration.xStream.toXML(it) |
195 |
| - val converted = Configuration.xStream.fromXML(xml) as Piece |
196 |
| - converted.toString() shouldBe it.toString() |
197 |
| - converted shouldBe it |
| 167 | + forall( |
| 168 | + row(Piece(Color.YELLOW, PieceShape.TETRO_O, Rotation.RIGHT, false), """ |
| 169 | + <piece color="YELLOW" kind="TETRO_O" rotation="RIGHT" isFlipped="false"> |
| 170 | + <position x="0" y="0"/> |
| 171 | + </piece> |
| 172 | + """.trimIndent()), |
| 173 | + row(Piece(Color.RED, PieceShape.PENTO_Y, Rotation.LEFT, false), """ |
| 174 | + <piece color="RED" kind="PENTO_Y" rotation="LEFT" isFlipped="false"> |
| 175 | + <position x="0" y="0"/> |
| 176 | + </piece> |
| 177 | + """.trimIndent()), |
| 178 | + row(Piece(Color.BLUE, PieceShape.PENTO_P, Rotation.MIRROR, true), """ |
| 179 | + <piece color="BLUE" kind="PENTO_P" rotation="MIRROR" isFlipped="true"> |
| 180 | + <position x="0" y="0"/> |
| 181 | + </piece> |
| 182 | + """.trimIndent()), |
| 183 | + row(Piece(Color.GREEN, PieceShape.TRIO_L, Rotation.NONE, true, Coordinates(5, 9)), """ |
| 184 | + <piece color="GREEN" kind="TRIO_L" rotation="NONE" isFlipped="true"> |
| 185 | + <position x="5" y="9"/> |
| 186 | + </piece> |
| 187 | + """.trimIndent()) |
| 188 | + ) {piece, xml -> |
| 189 | + Configuration.xStream.toXML(piece) shouldBe xml |
| 190 | + |
| 191 | + val converted = Configuration.xStream.fromXML(Configuration.xStream.toXML(piece)) as Piece |
| 192 | + converted.toString() shouldBe piece.toString() |
| 193 | + converted shouldBe piece |
198 | 194 | }
|
199 | 195 | }
|
200 | 196 | "Piece transformation calculation" {
|
|
0 commit comments