From 116cefbc633c592a37920c77b3aed46b648bb2ad Mon Sep 17 00:00:00 2001 From: Pablo Fraile Alonso Date: Thu, 17 Feb 2022 19:38:20 +0100 Subject: [PATCH] fix(position): test with columns and rows --- src/main/kotlin/movements/Position.kt | 6 +++--- src/test/kotlin/movements/PositionTest.kt | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/kotlin/movements/Position.kt b/src/main/kotlin/movements/Position.kt index 1654ddd..6012f0a 100644 --- a/src/main/kotlin/movements/Position.kt +++ b/src/main/kotlin/movements/Position.kt @@ -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) } } diff --git a/src/test/kotlin/movements/PositionTest.kt b/src/test/kotlin/movements/PositionTest.kt index a93ce0e..c29ee1c 100644 --- a/src/test/kotlin/movements/PositionTest.kt +++ b/src/test/kotlin/movements/PositionTest.kt @@ -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)) } } \ No newline at end of file