[android] #4007 - improve coverage geometry package

This commit is contained in:
Tobrun
2016-02-18 11:40:57 +01:00
parent dcbdfde932
commit 1180df00f2
4 changed files with 61 additions and 3 deletions

View File

@@ -2,9 +2,11 @@ package com.mapbox.mapboxsdk.geometry;
import com.mapbox.mapboxsdk.exceptions.InvalidLatLngBoundsException;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
@@ -84,6 +86,18 @@ public class LatLngBoundsTest {
assertFalse("Should not be empty", mLatLngBounds.isEmptySpan());
}
@Test
public void testToLatLngs() {
mLatLngBounds = new LatLngBounds.Builder()
.include(LAT_LNG_NOT_NULL_ISLAND)
.include(LAT_LNG_NULL_ISLAND)
.build();
assertArrayEquals("LatLngs should match",
new LatLng[]{LAT_LNG_NOT_NULL_ISLAND, LAT_LNG_NULL_ISLAND},
mLatLngBounds.toLatLngs());
}
@Test
public void testIncluding() {
assertTrue("LatLng should be included", mLatLngBounds.including(new LatLng(1, 1)));

View File

@@ -1,9 +1,8 @@
package com.mapbox.mapboxsdk.geometry;
import com.mapbox.mapboxsdk.geometry.ProjectedMeters;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
public class ProjectedMetersTest {
@@ -14,4 +13,34 @@ public class ProjectedMetersTest {
assertNotNull("projectedMeters should not be null", projectedMeters);
}
@Test
public void testNorthing() {
ProjectedMeters projectedMeters = new ProjectedMeters(1.0, 0.0);
assertEquals("northing should be 1", 1, projectedMeters.getNorthing(), 0);
}
@Test
public void testEasting() {
ProjectedMeters projectedMeters = new ProjectedMeters(0.0, 1.0);
assertEquals("easting should be 1", 1, projectedMeters.getEasting(), 0);
}
@Test
public void testConstructor() {
ProjectedMeters projectedMeters1 = new ProjectedMeters(1, 2);
ProjectedMeters projectedMeters2 = new ProjectedMeters(projectedMeters1);
assertEquals("projectedmeters should match", projectedMeters1, projectedMeters2);
}
@Test
public void testHashcode() {
ProjectedMeters meters = new ProjectedMeters(1, 2);
assertEquals("hashcode should match", -1048576, meters.hashCode());
}
@Test
public void testToString(){
ProjectedMeters meters = new ProjectedMeters(1, 1);
assertEquals("toString should match","ProjectedMeters [northing=1.0, easting=1.0]",meters.toString());
}
}

View File

@@ -56,6 +56,12 @@ public class VisibleRegionTest {
assertEquals("VisibleRegions should match", regionLeft, regionRight);
}
@Test
public void testHashcode() {
VisibleRegion region = new VisibleRegion(FAR_LEFT, FAR_RIGHT, NEAR_LEFT, NEAR_RIGHT, BOUNDS);
assertEquals("hashcode should match", -923534102, region.hashCode());
}
@Test
public void testToString() {
VisibleRegion region = new VisibleRegion(FAR_LEFT, FAR_RIGHT, NEAR_LEFT, NEAR_RIGHT, BOUNDS);