]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/test/intltest/tztest.cpp
ICU-551.51.tar.gz
[apple/icu.git] / icuSources / test / intltest / tztest.cpp
index 31abe0decd2dd09af64300243cc921a8600e3115..15a251dc9022ecea2c004c62ff5789fce81f4ebe 100644 (file)
@@ -1,6 +1,6 @@
 /***********************************************************************
  * COPYRIGHT: 
- * Copyright (c) 1997-2014, International Business Machines Corporation
+ * Copyright (c) 1997-2016, International Business Machines Corporation
  * and others. All Rights Reserved.
  ***********************************************************************/
 
@@ -21,8 +21,6 @@
 #include "cstring.h"
 #include "olsontz.h"
 
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
-
 #define CASE(id,test) case id:                               \
                           name = #test;                      \
                           if (exec) {                        \
@@ -137,6 +135,13 @@ TimeZoneTest::TestGenericAPI()
         infoln("WARNING: t_timezone may be incorrect. It is not a multiple of 15min.", tzoffset);
     }
 
+    TimeZone* hostZone = TimeZone::detectHostTimeZone();
+    /* Host time zone's offset should match the offset returned by uprv_timezone() */
+    if (hostZone->getRawOffset() != tzoffset * (-1000)) {
+        errln("FAIL: detectHostTimeZone()'s raw offset != host timezone's offset");
+    }
+    delete hostZone;
+
     UErrorCode status = U_ZERO_ERROR;
     const char* tzver = TimeZone::getTZDataVersion(status);
     if (U_FAILURE(status)) {
@@ -855,8 +860,8 @@ void TimeZoneTest::TestShortZoneIDs()
         {"UTC", 0, FALSE},    // Olson etcetera 0
         {"ECT", 60, TRUE},    // ICU Link - Europe/Paris
         {"MET", 60, TRUE},    // Olson europe 1:00 C-Eur
-        {"CAT", 120, FALSE},  // ICU Link - Africa/Harare
-        {"ART", 120, TRUE},   // ICU Link - Africa/Cairo
+        {"CAT", 120, FALSE},  // ICU Link - Africa/Maputo
+        {"ART", 120, FALSE},  // ICU Link - Africa/Cairo
         {"EET", 120, TRUE},   // Olson europe 2:00 EU
         {"EAT", 180, FALSE},  // ICU Link - Africa/Addis_Ababa
         {"NET", 240, FALSE},  // ICU Link - Asia/Yerevan
@@ -954,7 +959,7 @@ void TimeZoneTest::TestShortZoneIDs()
         "AST", "America/Anchorage",
         "BET", "America/Sao_Paulo",
         "BST", "Asia/Dhaka", // # spelling changed in 2000h; was Asia/Dacca
-        "CAT", "Africa/Harare",
+        "CAT", "Africa/Maputo",
         "CNT", "America/St_Johns",
         "CST", "America/Chicago",
         "CTT", "Asia/Shanghai",
@@ -1907,9 +1912,9 @@ void TimeZoneTest::TestFebruary() {
     TimeZone *tz;
     UDate dt;
     int32_t t, i, raw, dst;
-    for (t = 0; t < LENGTHOF(timezones); ++t) {
+    for (t = 0; t < UPRV_LENGTHOF(timezones); ++t) {
         tz = timezones[t];
-        for (i = 0; i < LENGTHOF(data); ++i) {
+        for (i = 0; i < UPRV_LENGTHOF(data); ++i) {
             gc.set(data[i].year, data[i].month, data[i].day,
                    data[i].hour, data[i].minute, data[i].second);
             dt = gc.getTime(status);
@@ -1975,44 +1980,69 @@ void TimeZoneTest::TestCanonicalID() {
         const char *alias;
         const char *zone;
     } excluded1[] = {
+        {"Africa/Addis_Ababa", "Africa/Nairobi"},
+        {"Africa/Asmera", "Africa/Nairobi"},
         {"Africa/Bamako", "Africa/Abidjan"},
+        {"Africa/Bangui", "Africa/Lagos"},
         {"Africa/Banjul", "Africa/Abidjan"},
-        {"Africa/Brazzaville", "Africa/Bangui"},
+        {"Africa/Blantyre", "Africa/Maputo"},
+        {"Africa/Brazzaville", "Africa/Lagos"},
+        {"Africa/Bujumbura", "Africa/Maputo"},
         {"Africa/Conakry", "Africa/Abidjan"},
         {"Africa/Dakar", "Africa/Abidjan"},
-        {"Africa/Douala", "Africa/Bangui"},
+        {"Africa/Dar_es_Salaam", "Africa/Nairobi"},
+        {"Africa/Djibouti", "Africa/Nairobi"},
+        {"Africa/Douala", "Africa/Lagos"},
         {"Africa/Freetown", "Africa/Abidjan"},
+        {"Africa/Gaborone", "Africa/Maputo"},
+        {"Africa/Harare", "Africa/Maputo"},
+        {"Africa/Kampala", "Africa/Nairobi"},
         {"Africa/Khartoum", "Africa/Juba"},
-        {"Africa/Kinshasa", "Africa/Bangui"},
-        {"Africa/Lagos", "Africa/Bangui"},
-        {"Africa/Libreville", "Africa/Bangui"},
+        {"Africa/Kigali", "Africa/Maputo"},
+        {"Africa/Kinshasa", "Africa/Lagos"},
+        {"Africa/Libreville", "Africa/Lagos"},
         {"Africa/Lome", "Africa/Abidjan"},
-        {"Africa/Luanda", "Africa/Bangui"},
-        {"Africa/Malabo", "Africa/Bangui"},
-        {"Africa/Niamey", "Africa/Bangui"},
+        {"Africa/Luanda", "Africa/Lagos"},
+        {"Africa/Lubumbashi", "Africa/Maputo"},
+        {"Africa/Lusaka", "Africa/Maputo"},
+        {"Africa/Maseru", "Africa/Johannesburg"},
+        {"Africa/Malabo", "Africa/Lagos"},
+        {"Africa/Mbabane", "Africa/Johannesburg"},
+        {"Africa/Mogadishu", "Africa/Nairobi"},
+        {"Africa/Niamey", "Africa/Lagos"},
         {"Africa/Nouakchott", "Africa/Abidjan"},
         {"Africa/Ouagadougou", "Africa/Abidjan"},
-        {"Africa/Porto-Novo", "Africa/Bangui"},
+        {"Africa/Porto-Novo", "Africa/Lagos"},
         {"Africa/Sao_Tome", "Africa/Abidjan"},
+        {"America/Antigua", "America/Port_of_Spain"},
+        {"America/Anguilla", "America/Port_of_Spain"},
         {"America/Curacao", "America/Aruba"},
-        {"America/Dominica", "America/Anguilla"},
-        {"America/Grenada", "America/Anguilla"},
-        {"America/Guadeloupe", "America/Anguilla"},
+        {"America/Dominica", "America/Port_of_Spain"},
+        {"America/Grenada", "America/Port_of_Spain"},
+        {"America/Guadeloupe", "America/Port_of_Spain"},
         {"America/Kralendijk", "America/Aruba"},
         {"America/Lower_Princes", "America/Aruba"},
-        {"America/Marigot", "America/Anguilla"},
-        {"America/Montserrat", "America/Anguilla"},
-        {"America/Port_of_Spain", "America/Anguilla"},
-        {"America/Shiprock", "America/Denver"}, // America/Shiprock is defined as a Link to America/Denver in tzdata
-        {"America/St_Barthelemy", "America/Anguilla"},
-        {"America/St_Kitts", "America/Anguilla"},
-        {"America/St_Lucia", "America/Anguilla"},
-        {"America/St_Thomas", "America/Anguilla"},
-        {"America/St_Vincent", "America/Anguilla"},
-        {"America/Tortola", "America/Anguilla"},
-        {"America/Virgin", "America/Anguilla"},
+        {"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"},
+        {"America/St_Lucia", "America/Port_of_Spain"},
+        {"America/St_Thomas", "America/Port_of_Spain"},
+        {"America/St_Vincent", "America/Port_of_Spain"},
+        {"America/Toronto", "America/Montreal"},
+        {"America/Tortola", "America/Port_of_Spain"},
+        {"America/Virgin", "America/Port_of_Spain"},
         {"Antarctica/South_Pole", "Antarctica/McMurdo"},
         {"Arctic/Longyearbyen", "Europe/Oslo"},
+        {"Asia/Kuwait", "Asia/Aden"},
+        {"Asia/Muscat", "Asia/Dubai"},
+        {"Asia/Phnom_Penh", "Asia/Bangkok"},
+        {"Asia/Qatar", "Asia/Bahrain"},
+        {"Asia/Riyadh", "Asia/Aden"},
+        {"Asia/Vientiane", "Asia/Bangkok"},
         {"Atlantic/Jan_Mayen", "Europe/Oslo"},
         {"Atlantic/St_Helena", "Africa/Abidjan"},
         {"Europe/Bratislava", "Europe/Prague"},
@@ -2029,8 +2059,13 @@ void TimeZoneTest::TestCanonicalID() {
         {"Europe/Vaduz", "Europe/Zurich"},
         {"Europe/Vatican", "Europe/Rome"},
         {"Europe/Zagreb", "Europe/Belgrade"},
+        {"Indian/Antananarivo", "Africa/Nairobi"},
+        {"Indian/Comoro", "Africa/Nairobi"},
+        {"Indian/Mayotte", "Africa/Nairobi"},
         {"Pacific/Auckland", "Antarctica/McMurdo"},
         {"Pacific/Johnston", "Pacific/Honolulu"},
+        {"Pacific/Midway", "Pacific/Pago_Pago"},
+        {"Pacific/Saipan", "Pacific/Guam"},
         {0, 0}
     };