Files
MapLibreParticleLab/platform/darwin/test/MGLClockDirectionFormatterTests.m
Minh Nguyễn 2a1a5f0885 [ios, osx] Split MGLDirectionFormatter in two
Split MGLDirectionFormatter into MGLClockDirectionFormatter, which specializes in clock positions, and MGLCompassDirectionFormatter, which boxes the compass. This neatly avoids any confusion that might arise if the developer fails to read the documentation and thinks the original unified formatter can convert between the two types of directions.
2016-04-22 11:29:10 -07:00

50 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;
shortFormatter.locale = [NSLocale localeWithLocaleIdentifier:MGLTestLocaleIdentifier];
MGLClockDirectionFormatter *mediumFormatter = [[MGLClockDirectionFormatter alloc] init];
mediumFormatter.locale = [NSLocale localeWithLocaleIdentifier:MGLTestLocaleIdentifier];
MGLClockDirectionFormatter *longFormatter = [[MGLClockDirectionFormatter alloc] init];
longFormatter.unitStyle = NSFormattingUnitStyleLong;
longFormatter.locale = [NSLocale localeWithLocaleIdentifier:MGLTestLocaleIdentifier];
XCTAssertEqualObjects(@"9:00", [shortFormatter stringFromDirection:-90]);
XCTAssertEqualObjects(@"9 o’clock", [mediumFormatter stringFromDirection:-90]);
XCTAssertEqualObjects(@"nine o’clock", [longFormatter stringFromDirection:-90]);
XCTAssertEqualObjects(@"12:00", [shortFormatter stringFromDirection:0]);
XCTAssertEqualObjects(@"12 o’clock", [mediumFormatter stringFromDirection:0]);
XCTAssertEqualObjects(@"twelve o’clock", [longFormatter stringFromDirection:0]);
XCTAssertEqualObjects(@"2:00", [shortFormatter stringFromDirection:45]);
XCTAssertEqualObjects(@"2 o’clock", [mediumFormatter stringFromDirection:45]);
XCTAssertEqualObjects(@"two o’clock", [longFormatter stringFromDirection:45]);
XCTAssertEqualObjects(@"3:00", [shortFormatter stringFromDirection:90]);
XCTAssertEqualObjects(@"3 o’clock", [mediumFormatter stringFromDirection:90]);
XCTAssertEqualObjects(@"three o’clock", [longFormatter stringFromDirection:90]);
XCTAssertEqualObjects(@"6:00", [shortFormatter stringFromDirection:180]);
XCTAssertEqualObjects(@"6 o’clock", [mediumFormatter stringFromDirection:180]);
XCTAssertEqualObjects(@"six o’clock", [longFormatter stringFromDirection:180]);
XCTAssertEqualObjects(@"9:00", [shortFormatter stringFromDirection:270]);
XCTAssertEqualObjects(@"9 o’clock", [mediumFormatter stringFromDirection:270]);
XCTAssertEqualObjects(@"nine o’clock", [longFormatter stringFromDirection:270]);
}
@end