[android] #3556 - Added test to trigger NaN value on same point, updated LatLng model to handle calls for distance calls of same point
This commit is contained in:
@@ -6,6 +6,7 @@ import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@@ -43,6 +44,23 @@ public class LatLngTest {
|
||||
assertEquals("altitude default value", latLng2.getAltitude(), altitude, DELTA);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDistanceTo() {
|
||||
LatLng latLng1 = new LatLng(0.0, 0.0);
|
||||
LatLng latLng2 = new LatLng(1.0, 1.0);
|
||||
assertEquals("distances should match",
|
||||
latLng1.distanceTo(latLng2),
|
||||
157425.53710839353, DELTA);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDistanceToSamePoint() {
|
||||
LatLng latLng1 = new LatLng(40.71199035644531, -74.0081);
|
||||
LatLng latLng2 = new LatLng(40.71199035644531, -74.0081);
|
||||
double distance = latLng1.distanceTo(latLng2);
|
||||
assertEquals("distance should match", 0.0, distance, DELTA);
|
||||
}
|
||||
|
||||
/*
|
||||
* A sample test where Mockito is necessary
|
||||
*/
|
||||
@@ -86,13 +104,4 @@ public class LatLngTest {
|
||||
"LatLng [longitude=3.4, latitude=1.2, altitude=5.6]");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDistanceTo() {
|
||||
LatLng latLng1 = new LatLng(0.0, 0.0);
|
||||
LatLng latLng2 = new LatLng(1.0, 1.0);
|
||||
assertEquals("distances should match",
|
||||
latLng1.distanceTo(latLng2),
|
||||
157425.53710839353, DELTA);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user