mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 06:18:44 +00:00
Added tests
Tags: #test
This commit is contained in:
@@ -56,7 +56,7 @@ public class Boat {
|
||||
*
|
||||
* @param velocity The velocity of boat
|
||||
*/
|
||||
public void setVelocity(float velocity) {
|
||||
public void setVelocity(double velocity) {
|
||||
this.velocity = velocity;
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,7 @@ public class BoatTest {
|
||||
public void testBoatCreation() {
|
||||
Boat boat1 = new Boat("Team 1");
|
||||
assertEquals(boat1.getTeamName(), "Team 1");
|
||||
assertEquals(boat1.getVelocity(), (double) 10.0, 1e-15);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -21,4 +22,13 @@ public class BoatTest {
|
||||
boat1.setTeamName("Team 2");
|
||||
assertEquals(boat1.getTeamName(), "Team 2");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetVelocity() {
|
||||
Boat boat1 = new Boat("Team 1", 29.0);
|
||||
assertEquals(boat1.getVelocity(), (double) 29.0, 1e-15);
|
||||
|
||||
boat1.setVelocity(12.0);
|
||||
assertEquals(boat1.getVelocity(), (double)12.0, 1e-15);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,9 +12,29 @@ public class EventTest {
|
||||
|
||||
@Test
|
||||
public void getTimeString() throws Exception {
|
||||
Leg leg = new Leg(035, 100, "Start");
|
||||
Leg leg = new Leg(35, 100, "Start");
|
||||
Boat boat = new Boat("testBoat");
|
||||
Event event = new Event(1231242, boat, leg);
|
||||
assertEquals("20:31:242", event.getTimeString());
|
||||
}
|
||||
|
||||
/**
|
||||
* ensure all boats are added as they pass the marker
|
||||
*/
|
||||
@Test
|
||||
public void boatOrderTest() throws Exception {
|
||||
Leg leg = new Leg(35, 100, "1");
|
||||
|
||||
Boat boat1 = new Boat("testBoat");
|
||||
Boat boat2 = new Boat("testBoat2");
|
||||
|
||||
Event event1 = new Event(1231242, boat1, leg);
|
||||
Event event2 = new Event(1231242, boat2, leg);
|
||||
|
||||
event1.boatPassedMarker();
|
||||
event2.boatPassedMarker();
|
||||
|
||||
assertEquals(event1.getLeg().getMarker().getBoats()[0].getTeamName(), "testBoat");
|
||||
assertEquals(event2.getLeg().getMarker().getBoats()[1].getTeamName(), "testBoat2");
|
||||
}
|
||||
}
|
||||
@@ -24,4 +24,16 @@ public class RaceTest {
|
||||
|
||||
assertEquals(Array.getLength(race.getBoats()), 2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetShuffledBoats(){
|
||||
Boat boat1 = new Boat("Team 1");
|
||||
Boat boat2 = new Boat("Team 2");
|
||||
|
||||
Race race = new Race();
|
||||
race.addBoat(boat1);
|
||||
race.addBoat(boat2);
|
||||
|
||||
assertEquals(Array.getLength(race.getShuffledBoats()), 2);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user