X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/b331163bffd790ced0e88b73f44f86d49ccc48a5..249c4c5ea9376c24572daf9c2effa7484a282f14:/icuSources/test/intltest/tztest.cpp diff --git a/icuSources/test/intltest/tztest.cpp b/icuSources/test/intltest/tztest.cpp index 80035322..31a34c64 100644 --- a/icuSources/test/intltest/tztest.cpp +++ b/icuSources/test/intltest/tztest.cpp @@ -1,6 +1,8 @@ +// © 2016 and later: Unicode, Inc. and others. +// License & terms of use: http://www.unicode.org/copyright.html /*********************************************************************** * COPYRIGHT: - * Copyright (c) 1997-2015, International Business Machines Corporation + * Copyright (c) 1997-2016, International Business Machines Corporation * and others. All Rights Reserved. ***********************************************************************/ @@ -136,8 +138,11 @@ TimeZoneTest::TestGenericAPI() } TimeZone* hostZone = TimeZone::detectHostTimeZone(); + int32_t hostZoneRawOffset = hostZone->getRawOffset(); + logln("hostZone->getRawOffset() = %d , tzoffset = %d", hostZoneRawOffset, tzoffset * (-1000)); + /* Host time zone's offset should match the offset returned by uprv_timezone() */ - if (hostZone->getRawOffset() != tzoffset * (-1000)) { + if (hostZoneRawOffset != tzoffset * (-1000)) { errln("FAIL: detectHostTimeZone()'s raw offset != host timezone's offset"); } delete hostZone; @@ -146,7 +151,7 @@ TimeZoneTest::TestGenericAPI() const char* tzver = TimeZone::getTZDataVersion(status); if (U_FAILURE(status)) { errcheckln(status, "FAIL: getTZDataVersion failed - %s", u_errorName(status)); - } else if (uprv_strlen(tzver) != 5 /* 4 digits + 1 letter */) { + } else if (uprv_strlen(tzver) < 5 || uprv_strlen(tzver) > 7 /*4 digits + 1-3 letters*/) { errln((UnicodeString)"FAIL: getTZDataVersion returned " + tzver); } else { logln((UnicodeString)"tzdata version: " + tzver); @@ -1203,31 +1208,43 @@ TimeZoneTest::TestAliasedNames() /* Generated by org.unicode.cldr.tool.CountItems */ /* zoneID, canonical zoneID */ - {"Africa/Timbuktu", "Africa/Bamako"}, + {"Africa/Asmara", "Africa/Addis_Ababa"}, + {"Africa/Timbuktu", "Africa/Abidjan"}, {"America/Argentina/Buenos_Aires", "America/Buenos_Aires"}, {"America/Argentina/Catamarca", "America/Catamarca"}, {"America/Argentina/ComodRivadavia", "America/Catamarca"}, {"America/Argentina/Cordoba", "America/Cordoba"}, {"America/Argentina/Jujuy", "America/Jujuy"}, {"America/Argentina/Mendoza", "America/Mendoza"}, + {"America/Atikokan", "America/Coral_Harbour"}, {"America/Atka", "America/Adak"}, {"America/Ensenada", "America/Tijuana"}, - {"America/Fort_Wayne", "America/Indiana/Indianapolis"}, - {"America/Indianapolis", "America/Indiana/Indianapolis"}, + {"America/Fort_Wayne", "America/Indianapolis"}, + {"America/Indiana/Indianapolis", "America/Indianapolis"}, + {"America/Kentucky/Louisville", "America/Louisville"}, {"America/Knox_IN", "America/Indiana/Knox"}, - {"America/Louisville", "America/Kentucky/Louisville"}, {"America/Porto_Acre", "America/Rio_Branco"}, {"America/Rosario", "America/Cordoba"}, - {"America/Virgin", "America/St_Thomas"}, + {"America/Shiprock", "America/Denver"}, + {"America/Virgin", "America/Anguilla"}, + {"Antarctica/South_Pole", "Antarctica/McMurdo"}, {"Asia/Ashkhabad", "Asia/Ashgabat"}, - {"Asia/Chungking", "Asia/Chongqing"}, + {"Asia/Chongqing", "Asia/Shanghai"}, + {"Asia/Chungking", "Asia/Shanghai"}, {"Asia/Dacca", "Asia/Dhaka"}, + {"Asia/Harbin", "Asia/Shanghai"}, + {"Asia/Ho_Chi_Minh", "Asia/Saigon"}, {"Asia/Istanbul", "Europe/Istanbul"}, + {"Asia/Kashgar", "Asia/Urumqi"}, + {"Asia/Kathmandu", "Asia/Katmandu"}, + {"Asia/Kolkata", "Asia/Calcutta"}, {"Asia/Macao", "Asia/Macau"}, {"Asia/Tel_Aviv", "Asia/Jerusalem"}, {"Asia/Thimbu", "Asia/Thimphu"}, {"Asia/Ujung_Pandang", "Asia/Makassar"}, {"Asia/Ulan_Bator", "Asia/Ulaanbaatar"}, + {"Atlantic/Faroe", "Atlantic/Faeroe"}, + {"Atlantic/Jan_Mayen", "Arctic/Longyearbyen"}, {"Australia/ACT", "Australia/Sydney"}, {"Australia/Canberra", "Australia/Sydney"}, {"Australia/LHI", "Australia/Lord_Howe"}, @@ -1255,16 +1272,16 @@ TimeZoneTest::TestAliasedNames() {"Chile/Continental", "America/Santiago"}, {"Chile/EasterIsland", "Pacific/Easter"}, {"Cuba", "America/Havana"}, + {"EST", "Etc/GMT+5"}, {"Egypt", "Africa/Cairo"}, {"Eire", "Europe/Dublin"}, {"Etc/GMT+0", "Etc/GMT"}, {"Etc/GMT-0", "Etc/GMT"}, {"Etc/GMT0", "Etc/GMT"}, {"Etc/Greenwich", "Etc/GMT"}, - {"Etc/UCT", "Etc/GMT"}, - {"Etc/UTC", "Etc/GMT"}, - {"Etc/Universal", "Etc/GMT"}, - {"Etc/Zulu", "Etc/GMT"}, + {"Etc/UCT", "Etc/UTC"}, + {"Etc/Universal", "Etc/UTC"}, + {"Etc/Zulu", "Etc/UTC"}, {"Europe/Belfast", "Europe/London"}, {"Europe/Nicosia", "Asia/Nicosia"}, {"Europe/Tiraspol", "Europe/Chisinau"}, @@ -1275,6 +1292,7 @@ TimeZoneTest::TestAliasedNames() {"GMT-0", "Etc/GMT"}, {"GMT0", "Etc/GMT"}, {"Greenwich", "Etc/GMT"}, + {"HST", "Etc/GMT+10"}, {"Hongkong", "Asia/Hong_Kong"}, {"Iceland", "Atlantic/Reykjavik"}, {"Iran", "Asia/Tehran"}, @@ -1283,27 +1301,37 @@ TimeZoneTest::TestAliasedNames() {"Japan", "Asia/Tokyo"}, {"Kwajalein", "Pacific/Kwajalein"}, {"Libya", "Africa/Tripoli"}, + {"MST", "Etc/GMT+7"}, {"Mexico/BajaNorte", "America/Tijuana"}, {"Mexico/BajaSur", "America/Mazatlan"}, {"Mexico/General", "America/Mexico_City"}, - {"NZ", "Pacific/Auckland"}, + {"NZ", "Antarctica/McMurdo"}, {"NZ-CHAT", "Pacific/Chatham"}, - {"Navajo", "America/Shiprock"}, + {"Navajo", "America/Denver"}, {"PRC", "Asia/Shanghai"}, - {"Pacific/Samoa", "Pacific/Pago_Pago"}, + {"Pacific/Chuuk", "Pacific/Truk"}, + {"Pacific/Pohnpei", "Pacific/Ponape"}, + {"Pacific/Samoa", "Pacific/Midway"}, {"Pacific/Yap", "Pacific/Truk"}, {"Poland", "Europe/Warsaw"}, {"Portugal", "Europe/Lisbon"}, {"ROC", "Asia/Taipei"}, {"ROK", "Asia/Seoul"}, {"Singapore", "Asia/Singapore"}, + {"SystemV/AST4", "Etc/GMT+4"}, + {"SystemV/CST6", "Etc/GMT+6"}, + {"SystemV/EST5", "Etc/GMT+5"}, + {"SystemV/HST10", "Etc/GMT+10"}, + {"SystemV/MST7", "Etc/GMT+7"}, + {"SystemV/PST8", "Etc/GMT+8"}, + {"SystemV/YST9", "Etc/GMT+9"}, {"Turkey", "Europe/Istanbul"}, - {"UCT", "Etc/GMT"}, + {"UCT", "Etc/UTC"}, {"US/Alaska", "America/Anchorage"}, {"US/Aleutian", "America/Adak"}, {"US/Arizona", "America/Phoenix"}, {"US/Central", "America/Chicago"}, - {"US/East-Indiana", "America/Indiana/Indianapolis"}, + {"US/East-Indiana", "America/Indianapolis"}, {"US/Eastern", "America/New_York"}, {"US/Hawaii", "Pacific/Honolulu"}, {"US/Indiana-Starke", "America/Indiana/Knox"}, @@ -1311,13 +1339,12 @@ TimeZoneTest::TestAliasedNames() {"US/Mountain", "America/Denver"}, {"US/Pacific", "America/Los_Angeles"}, {"US/Pacific-New", "America/Los_Angeles"}, - {"US/Samoa", "Pacific/Pago_Pago"}, - {"UTC", "Etc/GMT"}, - {"Universal", "Etc/GMT"}, + {"US/Samoa", "Pacific/Midway"}, + {"UTC", "Etc/UTC"}, + {"Universal", "Etc/UTC"}, {"W-SU", "Europe/Moscow"}, - {"Zulu", "Etc/GMT"}, - /* Total: 113 */ - + {"Zulu", "Etc/UTC"}, + /* Total: 136 */ }; TimeZone::EDisplayType styles[] = { TimeZone::SHORT, TimeZone::LONG }; @@ -1327,7 +1354,7 @@ TimeZoneTest::TestAliasedNames() int32_t i, j, k, loc; UnicodeString fromName, toName; TimeZone *from = NULL, *to = NULL; - for(i = 0; i < (int32_t)(sizeof(kData)/sizeof(kData[0])); i++) { + for(i = 0; i < UPRV_LENGTHOF(kData); i++) { from = TimeZone::createTimeZone(kData[i].from); to = TimeZone::createTimeZone(kData[i].to); if(!from->hasSameRules(*to)) { @@ -1336,8 +1363,8 @@ TimeZoneTest::TestAliasedNames() if(!quick) { for(loc = 0; loc < noLoc; loc++) { const char* locale = uloc_getAvailable(loc); - for(j = 0; j < (int32_t)(sizeof(styles)/sizeof(styles[0])); j++) { - for(k = 0; k < (int32_t)(sizeof(useDst)/sizeof(useDst[0])); k++) { + for(j = 0; j < UPRV_LENGTHOF(styles); j++) { + for(k = 0; k < UPRV_LENGTHOF(useDst); k++) { fromName.remove(); toName.remove(); from->getDisplayName(useDst[k], styles[j],locale, fromName); @@ -1952,14 +1979,14 @@ void TimeZoneTest::TestCanonicalIDAPI() { UnicodeString canonicalID; UErrorCode ec = U_ZERO_ERROR; UnicodeString *pResult = &TimeZone::getCanonicalID(bogus, canonicalID, ec); - assertEquals("TimeZone::getCanonicalID(bogus) should fail", U_ILLEGAL_ARGUMENT_ERROR, ec); + assertEquals("TimeZone::getCanonicalID(bogus) should fail", (int32_t)U_ILLEGAL_ARGUMENT_ERROR, ec); assertTrue("TimeZone::getCanonicalID(bogus) should return the dest string", pResult == &canonicalID); // U_FAILURE on input. UnicodeString berlin("Europe/Berlin"); ec = U_MEMORY_ALLOCATION_ERROR; pResult = &TimeZone::getCanonicalID(berlin, canonicalID, ec); - assertEquals("TimeZone::getCanonicalID(failure) should fail", U_MEMORY_ALLOCATION_ERROR, ec); + assertEquals("TimeZone::getCanonicalID(failure) should fail", (int32_t)U_MEMORY_ALLOCATION_ERROR, ec); assertTrue("TimeZone::getCanonicalID(failure) should return the dest string", pResult == &canonicalID); // Valid input should un-bogus the dest string. @@ -2025,6 +2052,7 @@ void TimeZoneTest::TestCanonicalID() { {"America/Marigot", "America/Port_of_Spain"}, {"America/Montserrat", "America/Port_of_Spain"}, {"America/Panama", "America/Cayman"}, + {"America/Santa_Isabel", "America/Tijuana"}, {"America/Shiprock", "America/Denver"}, {"America/St_Barthelemy", "America/Port_of_Spain"}, {"America/St_Kitts", "America/Port_of_Spain"}, @@ -2406,7 +2434,7 @@ void TimeZoneTest::TestGetWindowsID(void) { {"America/Indianapolis", "US Eastern Standard Time"}, // CLDR canonical name {"America/Indiana/Indianapolis", "US Eastern Standard Time"}, // tzdb canonical name {"Asia/Khandyga", "Yakutsk Standard Time"}, - {"Australia/Eucla", ""}, // No Windows ID mapping + {"Australia/Eucla", "Aus Central W. Standard Time"}, // formerly no Windows ID mapping, now has one {"Bogus", ""}, {0, 0}, };