summaryrefslogtreecommitdiff
path: root/platform/darwin/test/MGLCoordinateFormatterTests.m
diff options
context:
space:
mode:
authorMinh Nguyễn <mxn@1ec5.org>2016-04-23 11:36:46 -0700
committerMinh Nguyễn <mxn@1ec5.org>2016-04-24 16:13:54 -0700
commite4752912dad7dcedfb5853e5773b2194980e07e1 (patch)
tree5a7d3eb58c12fb0b2d67e8a8f2e05eb4f72399f9 /platform/darwin/test/MGLCoordinateFormatterTests.m
parent6c9ca4be50e74a260d9cc2bc731fe56d85c353d2 (diff)
downloadqtlocation-mapboxgl-e4752912dad7dcedfb5853e5773b2194980e07e1.tar.gz
[ios, osx] Corrected clock, coordinate formats
Long unit style isn’t intended to be spelled out, so the clock and coordinate direction formatters now use numerals for long unit style, differing from medium unit style in less drastic ways. The locale no longer needs to be exposed, since it’ll always match the overall string’s locale. Added support to the coordinate formatter for different unit styles. Made minutes and seconds of arc optional. Maintain strings for darwin/ formatter classes in a separate Foundation strings table that can be shared between the iOS and OS X SDKs. Added an English .stringsdict override that correctly pluralizes units. Capitalize osxapp window titles, now that they spell out the directions.
Diffstat (limited to 'platform/darwin/test/MGLCoordinateFormatterTests.m')
-rw-r--r--platform/darwin/test/MGLCoordinateFormatterTests.m37
1 files changed, 35 insertions, 2 deletions
diff --git a/platform/darwin/test/MGLCoordinateFormatterTests.m b/platform/darwin/test/MGLCoordinateFormatterTests.m
index 84a17596b1..6a6c7a3b2e 100644
--- a/platform/darwin/test/MGLCoordinateFormatterTests.m
+++ b/platform/darwin/test/MGLCoordinateFormatterTests.m
@@ -8,8 +8,41 @@
@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");
+ MGLCoordinateFormatter *shortFormatter = [[MGLCoordinateFormatter alloc] init];
+ shortFormatter.unitStyle = NSFormattingUnitStyleShort;
+ XCTAssertTrue(shortFormatter.allowsSeconds, @"Arcseconds should be allowed by default.");
+ XCTAssertTrue(shortFormatter.allowsMinutes, @"Arcminutes should be allowed by default.");
+
+ MGLCoordinateFormatter *mediumFormatter = [[MGLCoordinateFormatter alloc] init];
+ XCTAssertEqual(mediumFormatter.unitStyle, NSFormattingUnitStyleMedium, @"Unit style should be medium by default.");
+
+ MGLCoordinateFormatter *longFormatter = [[MGLCoordinateFormatter alloc] init];
+ longFormatter.unitStyle = NSFormattingUnitStyleLong;
+
+ CLLocationCoordinate2D coordinate;
+
+ coordinate = CLLocationCoordinate2DMake(38.9131982, -77.0325453144239);
+ XCTAssertEqualObjects([shortFormatter stringFromCoordinate:coordinate], @"38°54′48″N, 77°1′57″W");
+ XCTAssertEqualObjects([mediumFormatter stringFromCoordinate:coordinate], @"38°54′48″ north, 77°1′57″ west");
+ XCTAssertEqualObjects([longFormatter stringFromCoordinate:coordinate], @"38 degrees, 54 minutes, and 48 seconds north by 77 degrees, 1 minute, and 57 seconds west");
+
+ shortFormatter.allowsSeconds = NO;
+ mediumFormatter.allowsSeconds = NO;
+ longFormatter.allowsSeconds = NO;
+
+ coordinate = CLLocationCoordinate2DMake(38.9131982, -77.0325453144239);
+ XCTAssertEqualObjects([shortFormatter stringFromCoordinate:coordinate], @"38°55′N, 77°2′W");
+ XCTAssertEqualObjects([mediumFormatter stringFromCoordinate:coordinate], @"38°55′ north, 77°2′ west");
+ XCTAssertEqualObjects([longFormatter stringFromCoordinate:coordinate], @"38 degrees and 55 minutes north by 77 degrees and 2 minutes west");
+
+ shortFormatter.allowsMinutes = NO;
+ mediumFormatter.allowsMinutes = NO;
+ longFormatter.allowsMinutes = NO;
+
+ coordinate = CLLocationCoordinate2DMake(38.9131982, -77.0325453144239);
+ XCTAssertEqualObjects([shortFormatter stringFromCoordinate:coordinate], @"39°N, 77°W");
+ XCTAssertEqualObjects([mediumFormatter stringFromCoordinate:coordinate], @"39° north, 77° west");
+ XCTAssertEqualObjects([longFormatter stringFromCoordinate:coordinate], @"39 degrees north by 77 degrees west");
}
@end