Fix LatLng tests

This commit is contained in:
Tobias Schönberg 2017-05-28 18:35:03 +02:00
parent 4f4a875ebe
commit a62bfd2001
2 changed files with 19 additions and 19 deletions

View file

@ -9,55 +9,55 @@ import org.junit.Test;
public class LatLngTests {
@Test public void testZeroZero() {
LatLng place = new LatLng(0, 0);
LatLng place = new LatLng(0, 0, 0);
String prettyString = place.getPrettyCoordinateString();
Assert.assertThat(prettyString, is("0.0 N, 0.0 E"));
}
@Test public void testAntipode() {
LatLng place = new LatLng(0, 180);
LatLng place = new LatLng(0, 180, 0);
String prettyString = place.getPrettyCoordinateString();
Assert.assertThat(prettyString, is("0.0 N, 180.0 W"));
}
@Test public void testNorthPole() {
LatLng place = new LatLng(90, 0);
LatLng place = new LatLng(90, 0, 0);
String prettyString = place.getPrettyCoordinateString();
Assert.assertThat(prettyString, is("90.0 N, 0.0 E"));
}
@Test public void testSouthPole() {
LatLng place = new LatLng(-90, 0);
LatLng place = new LatLng(-90, 0, 0);
String prettyString = place.getPrettyCoordinateString();
Assert.assertThat(prettyString, is("90.0 S, 0.0 E"));
}
@Test public void testLargerNumbers() {
LatLng place = new LatLng(120, 380);
LatLng place = new LatLng(120, 380, 0);
String prettyString = place.getPrettyCoordinateString();
Assert.assertThat(prettyString, is("90.0 N, 20.0 E"));
}
@Test public void testNegativeNumbers() {
LatLng place = new LatLng(-120, -30);
LatLng place = new LatLng(-120, -30, 0);
String prettyString = place.getPrettyCoordinateString();
Assert.assertThat(prettyString, is("90.0 S, 30.0 W"));
}
@Test public void testTooBigWestValue() {
LatLng place = new LatLng(20, -190);
LatLng place = new LatLng(20, -190, 0);
String prettyString = place.getPrettyCoordinateString();
Assert.assertThat(prettyString, is("20.0 N, 170.0 E"));
}
@Test public void testRounding() {
LatLng place = new LatLng(0.1234567, -0.33333333);
LatLng place = new LatLng(0.1234567, -0.33333333, 0);
String prettyString = place.getPrettyCoordinateString();
Assert.assertThat(prettyString, is("0.1235 N, 0.3333 W"));
}
@Test public void testRoundingAgain() {
LatLng place = new LatLng(-0.000001, -0.999999);
LatLng place = new LatLng(-0.000001, -0.999999, 0);
String prettyString = place.getPrettyCoordinateString();
Assert.assertThat(prettyString, is("0.0 S, 1.0 W"));
}

View file

@ -10,36 +10,36 @@ import org.junit.Test;
public class LengthUtilsTest {
@Test public void testZeroDistance() {
LatLng pointA = new LatLng(0, 0);
LatLng pointB = new LatLng(0, 0);
LatLng pointA = new LatLng(0, 0, 0);
LatLng pointB = new LatLng(0, 0, 0);
String distance = LengthUtils.formatDistanceBetween(pointA, pointB);
Assert.assertThat(distance, is("0m"));
}
@Test public void testOneDegreeOnEquator() {
LatLng pointA = new LatLng(0, 0);
LatLng pointB = new LatLng(0, 1);
LatLng pointA = new LatLng(0, 0, 0);
LatLng pointB = new LatLng(0, 1, 0);
String distance = LengthUtils.formatDistanceBetween(pointA, pointB);
Assert.assertThat(distance, is("111.2km"));
}
@Test public void testOneDegreeFortyFiveDegrees() {
LatLng pointA = new LatLng(45, 0);
LatLng pointB = new LatLng(45, 1);
LatLng pointA = new LatLng(45, 0, 0);
LatLng pointB = new LatLng(45, 1, 0);
String distance = LengthUtils.formatDistanceBetween(pointA, pointB);
Assert.assertThat(distance, is("78.6km"));
}
@Test public void testOneDegreeSouthPole() {
LatLng pointA = new LatLng(-90, 0);
LatLng pointB = new LatLng(-90, 1);
LatLng pointA = new LatLng(-90, 0, 0);
LatLng pointB = new LatLng(-90, 1, 0);
String distance = LengthUtils.formatDistanceBetween(pointA, pointB);
Assert.assertThat(distance, is("0m"));
}
@Test public void testPoleToPole() {
LatLng pointA = new LatLng(90, 0);
LatLng pointB = new LatLng(-90, 0);
LatLng pointA = new LatLng(90, 0, 0);
LatLng pointB = new LatLng(-90, 0, 0);
String distance = LengthUtils.formatDistanceBetween(pointA, pointB);
Assert.assertThat(distance, is("20,015.1km"));
}