Skip to content

Commit

Permalink
Added unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
DM0000 committed Nov 2, 2024
1 parent 9475fc9 commit 1257fee
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion megamek/src/megamek/client/bot/princess/AeroPathUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,9 @@ public static boolean willStall(MovePath movePath) {
*/
public static boolean willCrash(MovePath movePath) {
return movePath.getEntity().isAero() &&
movePath.isOnAtmosphericGroundMap() &&
(movePath.getFinalAltitude() < 1) &&
!movePath.contains(MoveStepType.VLAND) &&
movePath.isOnAtmosphericGroundMap() &&
!movePath.contains(MoveStepType.LAND);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,18 @@ void testAssertWillCrashWithLandOrVland() {
boolean result = AeroPathUtil.willCrash(mockPath);
assertFalse(result);
}

@Test
void testAssertWillCrashNoAtmosphere() {
final Entity mockEntity = MockGenerators.generateMockAerospace(0, 0);

final MovePath mockPath = MockGenerators.generateMockPath(16, 16, mockEntity);
when(mockPath.getFinalVelocity()).thenReturn(1);
when(mockPath.isOnAtmosphericGroundMap()).thenReturn(false);

boolean result = AeroPathUtil.willCrash(mockPath);
assertFalse(result);
}


}

0 comments on commit 1257fee

Please sign in to comment.