Forbedrer Direction

Forenkler getReverseDirection ved hjelp av matematikk
Legger til metoder for venstrerotert og høyrerotert retning
Lager tester for alle de 3 nevnte metodene
This commit is contained in:
2020-02-23 19:43:19 +01:00
parent b6aee9111a
commit 0b2f6c78c0
2 changed files with 145 additions and 21 deletions

View File

@ -1,6 +1,5 @@
package inf112.fiasko.roborally.element_properties;
import inf112.fiasko.roborally.element_properties.Direction;
import org.junit.Test;
import java.util.ArrayList;
@ -57,4 +56,124 @@ public class DirectionTest {
}
assertEquals(list.size(), set.size());
}
@Test
public void getNorthOppositeDirection() {
assertEquals(Direction.SOUTH, Direction.getReverseDirection(Direction.NORTH));
}
@Test
public void getSouthOppositeDirection() {
assertEquals(Direction.NORTH, Direction.getReverseDirection(Direction.SOUTH));
}
@Test
public void getEastOppositeDirection() {
assertEquals(Direction.WEST, Direction.getReverseDirection(Direction.EAST));
}
@Test
public void getWestOppositeDirection() {
assertEquals(Direction.EAST, Direction.getReverseDirection(Direction.WEST));
}
@Test
public void getNorthWestOppositeDirection() {
assertEquals(Direction.SOUTH_EAST, Direction.getReverseDirection(Direction.NORTH_WEST));
}
@Test
public void getNorthEastOppositeDirection() {
assertEquals(Direction.SOUTH_WEST, Direction.getReverseDirection(Direction.NORTH_EAST));
}
@Test
public void getSouthEastOppositeDirection() {
assertEquals(Direction.NORTH_WEST, Direction.getReverseDirection(Direction.SOUTH_EAST));
}
@Test
public void getSouthWestOppositeDirection() {
assertEquals(Direction.NORTH_EAST, Direction.getReverseDirection(Direction.SOUTH_WEST));
}
@Test
public void getLeftRotatedDirectionFromNorth() {
assertEquals(Direction.WEST, Direction.getLeftRotatedDirection(Direction.NORTH));
}
@Test
public void getRightRotatedDirectionFromNorth() {
assertEquals(Direction.EAST, Direction.getRightRotatedDirection(Direction.NORTH));
}
@Test
public void getRightRotatedDirectionFromSouth() {
assertEquals(Direction.WEST, Direction.getRightRotatedDirection(Direction.SOUTH));
}
@Test
public void getLeftRotatedDirectionFromSouth() {
assertEquals(Direction.EAST, Direction.getLeftRotatedDirection(Direction.SOUTH));
}
@Test
public void getRightRotatedDirectionFromEast() {
assertEquals(Direction.SOUTH, Direction.getRightRotatedDirection(Direction.EAST));
}
@Test
public void getLeftRotatedDirectionFromEast() {
assertEquals(Direction.NORTH, Direction.getLeftRotatedDirection(Direction.EAST));
}
@Test
public void getRightRotatedDirectionFromWest() {
assertEquals(Direction.NORTH, Direction.getRightRotatedDirection(Direction.WEST));
}
@Test
public void getLeftRotatedDirectionFromWest() {
assertEquals(Direction.SOUTH, Direction.getLeftRotatedDirection(Direction.WEST));
}
@Test
public void getRightRotatedDirectionFromNorthEast() {
assertEquals(Direction.SOUTH_EAST, Direction.getRightRotatedDirection(Direction.NORTH_EAST));
}
@Test
public void getLeftRotatedDirectionFromNorthEast() {
assertEquals(Direction.NORTH_WEST, Direction.getLeftRotatedDirection(Direction.NORTH_EAST));
}
@Test
public void getRightRotatedDirectionFromNorthWest() {
assertEquals(Direction.NORTH_EAST, Direction.getRightRotatedDirection(Direction.NORTH_WEST));
}
@Test
public void getLeftRotatedDirectionFromNorthWest() {
assertEquals(Direction.SOUTH_WEST, Direction.getLeftRotatedDirection(Direction.NORTH_WEST));
}
@Test
public void getRightRotatedDirectionFromSouthEast() {
assertEquals(Direction.SOUTH_WEST, Direction.getRightRotatedDirection(Direction.SOUTH_EAST));
}
@Test
public void getLeftRotatedDirectionFromSouthEast() {
assertEquals(Direction.NORTH_EAST, Direction.getLeftRotatedDirection(Direction.SOUTH_EAST));
}
@Test
public void getRightRotatedDirectionFromSouthWest() {
assertEquals(Direction.NORTH_WEST, Direction.getRightRotatedDirection(Direction.SOUTH_WEST));
}
@Test
public void getLeftRotatedDirectionFromSouthWest() {
assertEquals(Direction.SOUTH_EAST, Direction.getLeftRotatedDirection(Direction.SOUTH_WEST));
}
}