Skip to content

Commit

Permalink
Write a failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexProgrammerDE committed Nov 28, 2024
1 parent 520b885 commit bb1c2a9
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions server/src/test/java/com/soulfiremc/test/PathfindingTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,31 @@ public void testPathfindingDiagonal() {
assertEquals(2, route.size());
}

@Test
public void testPathfindingDiagonalImpossible() {
var accessor = new TestBlockAccessor();
accessor.setBlockAt(0, 0, 0, BlockType.STONE);
accessor.setBlockAt(1, 0, 1, BlockType.STONE);
accessor.setBlockAt(2, 0, 2, BlockType.STONE);

// Barricade
accessor.setBlockAt(1, 1, 2, BlockType.STONE);
accessor.setBlockAt(1, 2, 2, BlockType.STONE);
accessor.setBlockAt(2, 1, 1, BlockType.STONE);
accessor.setBlockAt(2, 2, 1, BlockType.STONE);

var inventory = ProjectedInventory.forUnitTest(List.of(), TestPathConstraint.INSTANCE);
var routeFinder = new RouteFinder(new MinecraftGraph(TAGS_STATE,
accessor,
inventory,
TestPathConstraint.INSTANCE), new PosGoal(2, 1, 2));

var initialState = NodeState.forInfo(new SFVec3i(0, 1, 0), inventory);

assertThrowsExactly(
NoRouteFoundException.class, () -> routeFinder.findRouteSync(initialState, false));
}

@ParameterizedTest
@ValueSource(ints = {1, 2, 3})
public void testPathfindingJump(int height) {
Expand Down

0 comments on commit bb1c2a9

Please sign in to comment.