Browse Source

Added tests for FindPath function

remotes/origin/ghostsbehaviour
Julian 11 months ago
parent
commit
4d86a65233
  1. 54
      src/test/java/pacmanTests/MapTest.java

54
src/test/java/pacmanTests/MapTest.java

@ -57,4 +57,58 @@ class MapTest {
assertThat(expectedMiddle).isEqualTo(middle);
assertThat(expectedBottomRight).isEqualTo(bottomRight);
}
@Test
void Map_getPath_returnCorrectPathSimple() {
// arrange
String[] mapTest = {
"wwwww",
"w...w",
"w.w.w",
"w.w.w",
"wwwww"
};
GameManager gameManager = new GameManager();
gameManager.map = new Map(mapTest, gameManager);
Vector2 from = new Vector2(1, 1);
Vector2 to = new Vector2(3, 1);
String expectedPath = "uurrdd";
// act
String path = gameManager.map.FindPath(from, to);
// assert
assertThat(path).isEqualTo(expectedPath);
}
@Test
void Map_getPath_returnCorrectPathComplex() {
// arrange
String[] mapTest = {
"wwwwwwwww",
"w.....w.w",
"w.www.w.w",
"w.w...w.w",
"w.w.www.w",
"w.w.....w",
"wwwwwwwww"
};
GameManager gameManager = new GameManager();
gameManager.map = new Map(mapTest, gameManager);
Vector2 from = new Vector2(4, 3);
Vector2 to = new Vector2(1, 1);
String expectedPath = "ruulllldddd";
// act
String path = gameManager.map.FindPath(from, to);
// assert
assertThat(path).isEqualTo(expectedPath);
}
}
Loading…
Cancel
Save