Marker tests added
#story[20]
This commit is contained in:
@@ -187,43 +187,6 @@ public class RaceController extends Controller{
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * Function for the Bermuda Race.
|
|
||||||
// * @return legs in the Bermuda Race.
|
|
||||||
// */
|
|
||||||
// private ArrayList<Leg> generateBermudaCourseLegs() {
|
|
||||||
// ArrayList<Leg> legs = new ArrayList<>();
|
|
||||||
// Leg leg1 = new Leg("Start to Marker 1", Constants.startLineMarker1, Constants.startLineMarker2, Constants.mark1, null, 0);
|
|
||||||
// Leg leg2 = new Leg("Marker 1 to Leeward Gate", Constants.mark1, Constants.leewardGate1, 1);
|
|
||||||
// Leg leg3 = new Leg("Leeward Gate to Windward Gate", Constants.leewardGate1, Constants.windwardGate1, 2);
|
|
||||||
// Leg leg4 = new Leg("Windward Gate to Leeward Gate", Constants.windwardGate1, Constants.leewardGate1, 3);
|
|
||||||
// Leg leg5 = new Leg("Leeward Gate to Finish", Constants.leewardGate1, Constants.finishLineMarker1, 4);
|
|
||||||
// legs.add(leg1);
|
|
||||||
// legs.add(leg2);
|
|
||||||
// legs.add(leg3);
|
|
||||||
// legs.add(leg4);
|
|
||||||
// legs.add(leg5);
|
|
||||||
// return legs;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * Generates an example list of competitors (Official AC35 competitors)
|
|
||||||
// * @return List of official AC35 competing boats
|
|
||||||
// */
|
|
||||||
// private BoatInRace[] generateAC35Competitors() {
|
|
||||||
//
|
|
||||||
// BoatInRace[] boats = new BoatInRace[6];
|
|
||||||
//
|
|
||||||
// int i = 0;
|
|
||||||
// for (BoatInRace boat : Constants.OFFICIAL_AC35_COMPETITORS) {
|
|
||||||
// boat.setCurrentPosition(Constants.startLineMarker1);
|
|
||||||
// boats[i] = boat;
|
|
||||||
// i++;
|
|
||||||
// }
|
|
||||||
// return boats;
|
|
||||||
// }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the value for the race clock label
|
* Set the value for the race clock label
|
||||||
* @param time time that the label will be updated to
|
* @param time time that the label will be updated to
|
||||||
|
|||||||
@@ -47,5 +47,26 @@ public class GPSCoordinate {
|
|||||||
return String.format("Latitude: %f, Longitude: %f", latitude, longitude);
|
return String.format("Latitude: %f, Longitude: %f", latitude, longitude);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) return true;
|
||||||
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
|
|
||||||
|
GPSCoordinate that = (GPSCoordinate) o;
|
||||||
|
|
||||||
|
if (Math.abs(this.latitude - latitude) > 1e-6) return false;
|
||||||
|
return (Math.abs(this.longitude - longitude) < 1e-6);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
int result;
|
||||||
|
long temp;
|
||||||
|
temp = Double.doubleToLongBits(latitude);
|
||||||
|
result = (int) (temp ^ (temp >>> 32));
|
||||||
|
temp = Double.doubleToLongBits(longitude);
|
||||||
|
result = 31 * result + (int) (temp ^ (temp >>> 32));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ public class RaceXMLReader extends XMLReader{
|
|||||||
GPSCoordinate side1 = getCoordinates((Element) nCoordinates.item(0));
|
GPSCoordinate side1 = getCoordinates((Element) nCoordinates.item(0));
|
||||||
GPSCoordinate side2;
|
GPSCoordinate side2;
|
||||||
if (nCoordinates.getLength() > 1) {
|
if (nCoordinates.getLength() > 1) {
|
||||||
side2 = getCoordinates((Element) nCoordinates.item(0));
|
side2 = getCoordinates((Element) nCoordinates.item(1));
|
||||||
} else {
|
} else {
|
||||||
side2 = side1;
|
side2 = side1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,57 @@
|
|||||||
|
package seng302.Model;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
import seng302.GPSCoordinate;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by esa46 on 29/03/17.
|
||||||
|
*/
|
||||||
|
public class MarkerTest {
|
||||||
|
|
||||||
|
GPSCoordinate ORIGIN_COORD = new GPSCoordinate(0, 0);
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void averageOfSingleMarkAtOriginIsSingleMark() {
|
||||||
|
|
||||||
|
Marker testMark = new Marker(ORIGIN_COORD);
|
||||||
|
assertTrue(testMark.getAverageGPSCoordinate().equals(ORIGIN_COORD));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void averageOfSingleMarkIsSingleMark() {
|
||||||
|
|
||||||
|
GPSCoordinate testCoord = new GPSCoordinate(20, 25);
|
||||||
|
Marker testMark = new Marker(testCoord);
|
||||||
|
assertTrue(testMark.getAverageGPSCoordinate().equals(testCoord));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void averageLatOfTwoMarksIsAccurate() {
|
||||||
|
|
||||||
|
GPSCoordinate testCoord = new GPSCoordinate(10, 0);
|
||||||
|
Marker testMark = new Marker(ORIGIN_COORD, testCoord);
|
||||||
|
assertTrue(testMark.getAverageGPSCoordinate().equals(new GPSCoordinate(5, 0)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void averageLongOfTwoMarksIsAccurate() {
|
||||||
|
|
||||||
|
GPSCoordinate testCoord = new GPSCoordinate(0, 10);
|
||||||
|
Marker testMark = new Marker(ORIGIN_COORD, testCoord);
|
||||||
|
assertTrue(testMark.getAverageGPSCoordinate().equals(new GPSCoordinate(0, 5)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void averageLatAndLongOfTwoMarksIsAccurate() {
|
||||||
|
|
||||||
|
GPSCoordinate testCoord1 = new GPSCoordinate(10, 30);
|
||||||
|
GPSCoordinate testCoord2 = new GPSCoordinate(30, 60);
|
||||||
|
Marker testMark = new Marker(testCoord1, testCoord2);
|
||||||
|
assertTrue(testMark.getAverageGPSCoordinate().equals(new GPSCoordinate(020.644102, 44.014817)));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user