Skip to content

Tests for TimeZone.localizedName #612

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 1, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion TestFoundation/TestNSTimeZone.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class TestNSTimeZone: XCTestCase {
("test_computedPropertiesMatchMethodReturnValues", test_computedPropertiesMatchMethodReturnValues),
("test_initializingTimeZoneWithOffset", test_initializingTimeZoneWithOffset),
("test_initializingTimeZoneWithAbbreviation", test_initializingTimeZoneWithAbbreviation),

("test_localizedName", test_localizedName),
// Also disabled due to https://bugs.swift.org/browse/SR-300
// ("test_systemTimeZoneUsesSystemTime", test_systemTimeZoneUsesSystemTime),
]
Expand Down Expand Up @@ -117,6 +117,20 @@ class TestNSTimeZone: XCTestCase {
let known = NSTimeZone.knownTimeZoneNames
XCTAssertNotEqual([], known, "known time zone names not expected to be empty")
}

func test_localizedName() {
let initialTimeZone = NSTimeZone.default
NSTimeZone.default = TimeZone(identifier: "America/New_York")!
let defaultTimeZone = NSTimeZone.default
let locale = Locale(identifier: "en_US")
XCTAssertEqual(defaultTimeZone.localizedName(for: .standard, locale: locale), "Eastern Standard Time")
XCTAssertEqual(defaultTimeZone.localizedName(for: .shortStandard, locale: locale), "EST")
XCTAssertEqual(defaultTimeZone.localizedName(for: .generic, locale: locale), "Eastern Time")
XCTAssertEqual(defaultTimeZone.localizedName(for: .daylightSaving, locale: locale), "Eastern Daylight Time")
XCTAssertEqual(defaultTimeZone.localizedName(for: .shortDaylightSaving, locale: locale), "EDT")
XCTAssertEqual(defaultTimeZone.localizedName(for: .shortGeneric, locale: locale), "ET")
NSTimeZone.default = initialTimeZone //reset the TimeZone
}

func test_initializingTimeZoneWithOffset() {
let tz = TimeZone(identifier: "GMT-0400")
Expand Down