Files
MapLibreParticleLab/platform/darwin/test/MGLClockDirectionFormatterTests.m
Minh Nguyễn e4752912da [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.
2016-04-24 16:13:54 -07:00

55 lines
2.4 KiB
Objective-C
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#import <Mapbox/Mapbox.h>
#import <XCTest/XCTest.h>
static NSString * const MGLTestLocaleIdentifier = @"en-US";
@interface MGLClockDirectionFormatterTests : XCTestCase
@end
@implementation MGLClockDirectionFormatterTests
- (void)testClockDirections {
MGLClockDirectionFormatter *shortFormatter = [[MGLClockDirectionFormatter alloc] init];
shortFormatter.unitStyle = NSFormattingUnitStyleShort;
MGLClockDirectionFormatter *mediumFormatter = [[MGLClockDirectionFormatter alloc] init];
MGLClockDirectionFormatter *longFormatter = [[MGLClockDirectionFormatter alloc] init];
longFormatter.unitStyle = NSFormattingUnitStyleLong;
CLLocationDirection direction;
direction = -90;
XCTAssertEqualObjects(@"9:00", [shortFormatter stringFromDirection:direction]);
XCTAssertEqualObjects(@"9 o’clock", [mediumFormatter stringFromDirection:direction]);
XCTAssertEqualObjects(@"9 o’clock", [longFormatter stringFromDirection:direction]);
direction = 0;
XCTAssertEqualObjects(@"12:00", [shortFormatter stringFromDirection:direction]);
XCTAssertEqualObjects(@"12 o’clock", [mediumFormatter stringFromDirection:direction]);
XCTAssertEqualObjects(@"12 o’clock", [longFormatter stringFromDirection:direction]);
direction = 45;
XCTAssertEqualObjects(@"2:00", [shortFormatter stringFromDirection:direction]);
XCTAssertEqualObjects(@"2 o’clock", [mediumFormatter stringFromDirection:direction]);
XCTAssertEqualObjects(@"2 o’clock", [longFormatter stringFromDirection:direction]);
direction = 90;
XCTAssertEqualObjects(@"3:00", [shortFormatter stringFromDirection:direction]);
XCTAssertEqualObjects(@"3 o’clock", [mediumFormatter stringFromDirection:direction]);
XCTAssertEqualObjects(@"3 o’clock", [longFormatter stringFromDirection:direction]);
direction = 180;
XCTAssertEqualObjects(@"6:00", [shortFormatter stringFromDirection:direction]);
XCTAssertEqualObjects(@"6 o’clock", [mediumFormatter stringFromDirection:direction]);
XCTAssertEqualObjects(@"6 o’clock", [longFormatter stringFromDirection:direction]);
direction = 270;
XCTAssertEqualObjects(@"9:00", [shortFormatter stringFromDirection:direction]);
XCTAssertEqualObjects(@"9 o’clock", [mediumFormatter stringFromDirection:direction]);
XCTAssertEqualObjects(@"9 o’clock", [longFormatter stringFromDirection:direction]);
}
@end