-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(jblock): implement double rotation
- Loading branch information
1 parent
27431df
commit 082597c
Showing
2 changed files
with
78 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package blocks.JBlock | ||
|
||
import blocks.DoubleRotation | ||
import blocks.Rotation | ||
import blocks.implementation.JBlock | ||
import movements.Position | ||
import org.junit.jupiter.api.BeforeEach | ||
import org.junit.jupiter.api.Test | ||
import kotlin.test.assertEquals | ||
|
||
class JBlockDoubleRotationTest : DoubleRotation { | ||
|
||
private lateinit var jBlock: JBlock | ||
|
||
@BeforeEach | ||
fun setUp() { | ||
jBlock = JBlock(Position(0, 0)) | ||
} | ||
|
||
@Test | ||
override fun `Rotate block 90 degrees to right and then to left stays on same position`() { | ||
jBlock.rotate(Rotation.RIGHT_90_DEGREE) | ||
jBlock.rotate(Rotation.LEFT_90_DEGREE) | ||
assertEquals( | ||
listOf(Position(0, 0), Position(1, 0), Position(1, 1), Position(1, 2)), | ||
jBlock.getNeededPositions() | ||
) | ||
} | ||
|
||
@Test | ||
override fun `Rotate block 90 degrees to left and then to right stays on same position`() { | ||
jBlock.rotate(Rotation.LEFT_90_DEGREE) | ||
jBlock.rotate(Rotation.RIGHT_90_DEGREE) | ||
assertEquals( | ||
listOf(Position(0, 0), Position(1, 0), Position(1, 1), Position(1, 2)), | ||
jBlock.getNeededPositions() | ||
) | ||
} | ||
|
||
@Test | ||
override fun `Rotate block 180 degrees to left`() { | ||
jBlock.rotate(Rotation.LEFT_90_DEGREE) | ||
jBlock.rotate(Rotation.LEFT_90_DEGREE) | ||
assertEquals( | ||
listOf(Position(1, 0), Position(1, 1), Position(1, 2), Position(2, 2)), | ||
jBlock.getNeededPositions() | ||
) | ||
} | ||
|
||
@Test | ||
override fun `Rotate block 180 degrees to right`() { | ||
jBlock.rotate(Rotation.RIGHT_90_DEGREE) | ||
jBlock.rotate(Rotation.RIGHT_90_DEGREE) | ||
assertEquals( | ||
listOf(Position(1, 0), Position(1, 1), Position(1, 2), Position(2, 2)), | ||
jBlock.getNeededPositions() | ||
) | ||
} | ||
|
||
} |