|
|
|
|
@ -84,7 +84,8 @@ public class RaceTest {
|
|
|
|
|
Leg leg1 = new Leg("1", new GPSCoordinate(0, 0), new GPSCoordinate(1, 1), 0);
|
|
|
|
|
Leg leg2 = new Leg("2", new GPSCoordinate(0, 0), new GPSCoordinate(1, 1), 1);
|
|
|
|
|
|
|
|
|
|
legs.add(leg2); legs.add(leg2);
|
|
|
|
|
legs.add(leg2);
|
|
|
|
|
legs.add(leg2);
|
|
|
|
|
|
|
|
|
|
ConstantVelocityRace race = new ConstantVelocityRace(new BoatInRace[1], legs);
|
|
|
|
|
|
|
|
|
|
@ -114,7 +115,7 @@ public class RaceTest {
|
|
|
|
|
@Test
|
|
|
|
|
public void scalerScalesVelocityCorrectly() {
|
|
|
|
|
|
|
|
|
|
int scaleFactor = 0;
|
|
|
|
|
int scaleFactor = 3;
|
|
|
|
|
float vel1 = 0;
|
|
|
|
|
float vel2 = (float) 1.999;
|
|
|
|
|
float vel3 = (float) 32.5;
|
|
|
|
|
@ -126,9 +127,26 @@ public class RaceTest {
|
|
|
|
|
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);
|
|
|
|
|
assertEquals(race.getStartingBoats().get(0).getScaledVelocity(), vel1 * scaleFactor, 1e-6);
|
|
|
|
|
assertEquals(race.getStartingBoats().get(1).getScaledVelocity(), vel2 * scaleFactor, 1e-6);
|
|
|
|
|
assertEquals(race.getStartingBoats().get(2).getScaledVelocity(), vel3 * scaleFactor, 1e-6);
|
|
|
|
|
assertEquals(race.getStartingBoats().get(3).getScaledVelocity(), vel4 * scaleFactor, 1e-6);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void scalerScalesRaceClockTo1MinCorrectly() {
|
|
|
|
|
int scaleFactor = 10;
|
|
|
|
|
ConstantVelocityRace race = new ConstantVelocityRace(new BoatInRace[5], new ArrayList<Leg>(), scaleFactor);
|
|
|
|
|
race.totalTimeElapsed = 6000; //6 seconds
|
|
|
|
|
assertTrue(race.calcTimer().equals("Race clock: 00:01:00"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void scalerScalesRaceClockHoursMinutesAndSecondsCorrectly() {
|
|
|
|
|
int scaleFactor = 3;
|
|
|
|
|
ConstantVelocityRace race = new ConstantVelocityRace(new BoatInRace[5], new ArrayList<Leg>(), scaleFactor);
|
|
|
|
|
race.totalTimeElapsed = 3213000;
|
|
|
|
|
assertTrue(race.calcTimer().equals("Race clock: 02:40:39"));
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|