Skip to content

Commit

Permalink
fix(position): test with columns and rows
Browse files Browse the repository at this point in the history
  • Loading branch information
Pablito2020 committed Apr 16, 2022
1 parent 6259920 commit 116cefb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/main/kotlin/movements/Position.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ data class Position(val row: Int, val column: Int) {

fun move(direction: Direction): Position {
return when(direction) {
Direction.DOWN -> Position(row, column + 1)
Direction.LEFT -> Position(row - 1, column)
Direction.RIGHT -> Position(row + 1, column)
Direction.DOWN -> Position(row + 1, column)
Direction.LEFT -> Position(row, column - 1)
Direction.RIGHT -> Position(row , column + 1)
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/test/kotlin/movements/PositionTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ class PositionTest {

@Test
fun `Apply DOWN direction`(){
assertEquals(Position(1,2), position.move(Direction.DOWN))
assertEquals(Position(2,1), position.move(Direction.DOWN))
}

@Test
fun `Apply LEFT direction`(){
assertEquals(Position(0,1), position.move(Direction.LEFT))
assertEquals(Position(1,0), position.move(Direction.LEFT))
}

@Test
fun `Apply RIGHT direction`(){
assertEquals(Position(2,1), position.move(Direction.RIGHT))
assertEquals(Position(1,2), position.move(Direction.RIGHT))
}

}

0 comments on commit 116cefb

Please sign in to comment.