summaryrefslogtreecommitdiff
path: root/platform/darwin/test
diff options
context:
space:
mode:
authorMinh Nguyễn <mxn@1ec5.org>2016-04-22 00:17:39 -0700
committerMinh Nguyễn <mxn@1ec5.org>2016-04-22 11:13:03 -0700
commit91023f02f85ad243f867a2fb920699c3e1659f94 (patch)
tree4f3e68615c6a6562e74a2a21d6069ce788993c90 /platform/darwin/test
parenta852ee24fbf6c883b7f64bad9883937eb7b8d80d (diff)
downloadqtlocation-mapboxgl-91023f02f85ad243f867a2fb920699c3e1659f94.tar.gz
[ios, osx] Coordinate formatter
Added a degree-minute-second coordinate formatter for general use. Use this formatter in iosapp and osxapp. Added unit tests for the coordinate formatter and for round-tripping geometry types through NSValue.
Diffstat (limited to 'platform/darwin/test')
-rw-r--r--platform/darwin/test/MGLCoordinateFormatterTests.m15
-rw-r--r--platform/darwin/test/MGLGeometryTests.mm25
2 files changed, 40 insertions, 0 deletions
diff --git a/platform/darwin/test/MGLCoordinateFormatterTests.m b/platform/darwin/test/MGLCoordinateFormatterTests.m
new file mode 100644
index 0000000000..84a17596b1
--- /dev/null
+++ b/platform/darwin/test/MGLCoordinateFormatterTests.m
@@ -0,0 +1,15 @@
+#import <Mapbox/Mapbox.h>
+#import <XCTest/XCTest.h>
+
+@interface MGLCoordinateFormatterTests : XCTestCase
+
+@end
+
+@implementation MGLCoordinateFormatterTests
+
+- (void)testStrings {
+ MGLCoordinateFormatter *formatter = [[MGLCoordinateFormatter alloc] init];
+ XCTAssertEqualObjects([formatter stringFromCoordinate:CLLocationCoordinate2DMake(38.9131982, -77.0325453144239)], @"38°54′48″N, 77°1′57″W");
+}
+
+@end
diff --git a/platform/darwin/test/MGLGeometryTests.mm b/platform/darwin/test/MGLGeometryTests.mm
index 73af0bb211..b9205e8d9d 100644
--- a/platform/darwin/test/MGLGeometryTests.mm
+++ b/platform/darwin/test/MGLGeometryTests.mm
@@ -52,4 +52,29 @@
XCTAssertEqualWithAccuracy(18, MGLZoomLevelForAltitude(MGLAltitudeForZoomLevel(18, 60, 40, midSize), 60, 40, midSize), 3);
}
+- (void)testGeometryBoxing {
+ CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake(38.9131982, -77.0325453144239);
+ CLLocationCoordinate2D roundTrippedCoordinate = [NSValue valueWithMGLCoordinate:coordinate].MGLCoordinateValue;
+
+ XCTAssertEqual(coordinate.latitude, roundTrippedCoordinate.latitude, @"Latitude should round-trip.");
+ XCTAssertEqual(coordinate.longitude, roundTrippedCoordinate.longitude, @"Longitude should round-trip.");
+
+ MGLCoordinateSpan span = MGLCoordinateSpanMake(4.383333333333335, -4.299999999999997);
+ MGLCoordinateSpan roundTrippedSpan = [NSValue valueWithMGLCoordinateSpan:span].MGLCoordinateSpanValue;
+
+ XCTAssertEqual(span.latitudeDelta, roundTrippedSpan.latitudeDelta, @"Latitude delta should round-trip.");
+ XCTAssertEqual(span.longitudeDelta, roundTrippedSpan.longitudeDelta, @"Longitude delta should round-trip.");
+
+ MGLCoordinateBounds bounds = MGLCoordinateBoundsMake(CLLocationCoordinate2DMake(38.9131982, -77.0325453144239),
+ CLLocationCoordinate2DMake(37.7757368, -122.4135302));
+ MGLCoordinateBounds roundTrippedBounds = [NSValue valueWithMGLCoordinateBounds:bounds].MGLCoordinateBoundsValue;
+
+ XCTAssertEqualObjects([NSValue valueWithMGLCoordinate:bounds.sw],
+ [NSValue valueWithMGLCoordinate:roundTrippedBounds.sw],
+ @"Southwest should round-trip.");
+ XCTAssertEqualObjects([NSValue valueWithMGLCoordinate:bounds.ne],
+ [NSValue valueWithMGLCoordinate:roundTrippedBounds.ne],
+ @"Northeast should round-trip.");
+}
+
@end