diff --git a/Tests/FoundationInternationalizationTests/TimeZoneTests.swift b/Tests/FoundationInternationalizationTests/TimeZoneTests.swift index 724b15799..daec2d656 100644 --- a/Tests/FoundationInternationalizationTests/TimeZoneTests.swift +++ b/Tests/FoundationInternationalizationTests/TimeZoneTests.swift @@ -59,7 +59,7 @@ private struct TimeZoneTests { } @Test func localizedName_103036605() { - func test(_ tzIdentifier: String, _ localeIdentifier: String, _ style: TimeZone.NameStyle, _ expected: String?, sourceLocation: SourceLocation = #_sourceLocation) { + func test(_ tzIdentifier: String, _ localeIdentifier: String, _ style: TimeZone.NameStyle, _ expected: String?, _ expectedDST: String?, sourceLocation: SourceLocation = #_sourceLocation) { let tz = TimeZone(identifier: tzIdentifier) guard let expected else { #expect(tz == nil, sourceLocation: sourceLocation) @@ -67,29 +67,33 @@ private struct TimeZoneTests { } let locale = Locale(identifier: localeIdentifier) - #expect(tz?.localizedName(for: .generic, locale: locale) == expected, sourceLocation: sourceLocation) + if let tz, tz.isDaylightSavingTime(for: .now) { + #expect(tz.localizedName(for: style, locale: locale) == expectedDST, sourceLocation: sourceLocation) + } else { + #expect(tz?.localizedName(for: style, locale: locale) == expected, sourceLocation: sourceLocation) + } } - test("America/Los_Angeles", "en_US", .generic, "Pacific Time") - test("Europe/Berlin", "en_US", .generic, "Central European Time") - test("Antarctica/Vostok", "en_US", .generic, "Vostok Time") - test("Asia/Chongqing", "en_US", .generic, "China Standard Time") - test("America/Sao_Paulo", "en_US", .generic, "Brasilia Standard Time") + test("America/Los_Angeles", "en_US", .generic, "Pacific Time", "Pacific Time") + test("Europe/Paris", "en_US", .generic, "Central European Time", "Central European Time") + test("Antarctica/Vostok", "en_US", .generic, "Vostok Time", "Vostok Time") + test("Asia/Chongqing", "en_US", .generic, "China Standard Time", "China Standard Time") + test("America/Sao_Paulo", "en_US", .generic, "Brasilia Standard Time", "Brasilia Standard Time") - test("America/Los_Angeles", "zh_TW", .shortStandard, "太平洋時間") - test("Europe/Berlin", "zh_TW", .shortStandard, "中歐時間") - test("Antarctica/Vostok", "zh_TW", .shortStandard, "沃斯托克時間") - test("Asia/Chongqing", "zh_TW", .shortStandard, "中國標準時間") - test("America/Sao_Paulo", "zh_TW", .shortStandard, "巴西利亞標準時間") + test("America/Los_Angeles", "zh_TW", .shortStandard, "PST", "PST") + test("Europe/Paris", "zh_TW", .shortStandard, "GMT+1", "GMT+2") + test("Antarctica/Davis", "zh_TW", .shortStandard, "GMT+7", "GMT+7") + test("Asia/Chongqing", "zh_TW", .shortStandard, "GMT+8", "GMT+8") + test("America/Sao_Paulo", "zh_TW", .shortStandard, "GMT-3", "GMT-3") // abbreviation - test("GMT", "en_US", .standard, "Greenwich Mean Time") - test("GMT+8", "en_US", .standard, "GMT+08:00") - test("PST", "en_US", .standard, "Pacific Time") + test("GMT", "en_US", .standard, "Greenwich Mean Time", "Greenwich Mean Time") + test("GMT+8", "en_US", .standard, "GMT+08:00", "GMT+08:00") + test("PST", "en_US", .standard, "Pacific Standard Time", "Pacific Standard Time") // invalid names - test("XYZ", "en_US", .standard, nil) - test("BOGUS/BOGUS", "en_US", .standard, nil) + test("XYZ", "en_US", .standard, nil, nil) + test("BOGUS/BOGUS", "en_US", .standard, nil, nil) } @Test func timeZoneName_103097012() throws {