Test that boat velocities are being scaled correctly added
#story[16] #implement
This commit is contained in:
@@ -110,4 +110,25 @@ public class RaceTest {
|
||||
assertTrue(System.currentTimeMillis() - timeStarted > 500);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void scalerScalesVelocityCorrectly() {
|
||||
|
||||
int scaleFactor = 0;
|
||||
float vel1 = 0;
|
||||
float vel2 = (float) 1.999;
|
||||
float vel3 = (float) 32.5;
|
||||
float vel4 = 500;
|
||||
BoatInRace boat1 = new BoatInRace("test", vel1, Color.ALICEBLUE, "tt");
|
||||
BoatInRace boat2 = new BoatInRace("test", vel2, Color.ALICEBLUE, "tt");
|
||||
BoatInRace boat3 = new BoatInRace("test", vel3, Color.ALICEBLUE, "tt");
|
||||
BoatInRace boat4 = new BoatInRace("test", vel4, Color.ALICEBLUE, "tt");
|
||||
BoatInRace[] boats = new BoatInRace[] {boat1, boat2, boat3, boat4};
|
||||
|
||||
ConstantVelocityRace race = new ConstantVelocityRace(boats, new ArrayList<Leg>(), scaleFactor);
|
||||
assertEquals(race.getStartingBoats().get(0).getScaledVelocity(), vel1 * scaleFactor, 1e-8);
|
||||
assertEquals(race.getStartingBoats().get(1).getScaledVelocity(), vel2 * scaleFactor, 1e-8);
|
||||
assertEquals(race.getStartingBoats().get(2).getScaledVelocity(), vel3 * scaleFactor, 1e-8);
|
||||
assertEquals(race.getStartingBoats().get(3).getScaledVelocity(), vel4 * scaleFactor, 1e-8);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user