summaryrefslogtreecommitdiff
path: root/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/geometry/LatLngBoundsTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/geometry/LatLngBoundsTest.java')
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/geometry/LatLngBoundsTest.java76
1 files changed, 76 insertions, 0 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/geometry/LatLngBoundsTest.java b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/geometry/LatLngBoundsTest.java
index c3d13f0c66..e6c1fdd0cf 100644
--- a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/geometry/LatLngBoundsTest.java
+++ b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/geometry/LatLngBoundsTest.java
@@ -7,7 +7,9 @@ import com.mapbox.mapboxsdk.exceptions.InvalidLatLngBoundsException;
import com.mapbox.mapboxsdk.utils.MockParcel;
import org.junit.Before;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.ExpectedException;
import java.util.ArrayList;
import java.util.List;
@@ -289,4 +291,78 @@ public class LatLngBoundsTest {
assertEquals(40.713955826286039, bounds.getLatNorth(), DELTA);
}
+
+ @Rule
+ public final ExpectedException exception = ExpectedException.none();
+
+ @Test
+ public void testConstructorChecksNorthLatitudeNaN() {
+ exception.expect(IllegalArgumentException.class);
+ exception.expectMessage("latitude must not be NaN");
+ LatLngBounds.from(Double.NaN, 0, -20, -20);
+ }
+
+ @Test
+ public void testConstructorChecksEastLongitudeNaN() {
+ exception.expect(IllegalArgumentException.class);
+ exception.expectMessage("longitude must not be NaN");
+ LatLngBounds.from(0, Double.NaN, -20, -20);
+ }
+
+ @Test
+ public void testConstructorChecksNorthLatitudeGreaterThan90() {
+ exception.expect(IllegalArgumentException.class);
+ exception.expectMessage("latitude must be between -90 and 90");
+ LatLngBounds.from(95, 0, -20, -20);
+ }
+
+ @Test
+ public void testConstructorChecksNorthLatitudeLessThanThanNegative90() {
+ exception.expect(IllegalArgumentException.class);
+ exception.expectMessage("latitude must be between -90 and 90");
+ LatLngBounds.from(-95, 0, -20, -20);
+ }
+
+ @Test
+ public void testConstructorChecksEastLongitudeInfinity() {
+ exception.expect(IllegalArgumentException.class);
+ exception.expectMessage("longitude must not be infinite");
+ LatLngBounds.from(0, Double.POSITIVE_INFINITY, -20, -20);
+ }
+
+
+ @Test
+ public void testConstructorChecksSouthLatitudeNaN() {
+ exception.expect(IllegalArgumentException.class);
+ exception.expectMessage("latitude must not be NaN");
+ LatLngBounds.from(20, 20, Double.NaN, 0);
+ }
+
+ @Test
+ public void testConstructorChecksWesttLongitudeNaN() {
+ exception.expect(IllegalArgumentException.class);
+ exception.expectMessage("longitude must not be NaN");
+ LatLngBounds.from(20, 20, 0, Double.NaN);
+ }
+
+ @Test
+ public void testConstructorChecksSouthLatitudeGreaterThan90() {
+ exception.expect(IllegalArgumentException.class);
+ exception.expectMessage("latitude must be between -90 and 90");
+ LatLngBounds.from(20, 20,95, 0);
+ }
+
+ @Test
+ public void testConstructorChecksSouthLatitudeLessThanThanNegative90() {
+ exception.expect(IllegalArgumentException.class);
+ exception.expectMessage("latitude must be between -90 and 90");
+ LatLngBounds.from(20, 20, -95, 0);
+ }
+
+ @Test
+ public void testConstructorChecksWestLongitudeInfinity() {
+ exception.expect(IllegalArgumentException.class);
+ exception.expectMessage("longitude must not be infinite");
+ LatLngBounds.from(20, 20, 0, Double.POSITIVE_INFINITY);
+ }
}