]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/test/intltest/tztest.cpp
ICU-62141.0.1.tar.gz
[apple/icu.git] / icuSources / test / intltest / tztest.cpp
index d9d3737d2e715bc09078937467359b5cf549e509..31a34c64198ac9b67fcb5c5d2240600fd768e6b8 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2016 and later: Unicode, Inc. and others.
+// © 2016 and later: Unicode, Inc. and others.
 // License & terms of use: http://www.unicode.org/copyright.html
 /***********************************************************************
  * COPYRIGHT: 
@@ -138,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;
@@ -148,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);
@@ -1205,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"},
@@ -1257,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"},
@@ -1277,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"},
@@ -1285,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"},
@@ -1313,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 };
@@ -1954,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.
@@ -2409,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",         "Aus Central W. Standard Time"}, // Now has Windows ID mapping
+        {"Australia/Eucla",         "Aus Central W. Standard Time"}, // formerly no Windows ID mapping, now has one
         {"Bogus",                   ""},
         {0,                         0},
     };