From d2df1e1fdd3d320d9f4189026d2ad477b8f53a0a Mon Sep 17 00:00:00 2001 From: Vladimir Weinstein Date: Tue, 19 Jul 2005 05:12:33 +0000 Subject: [PATCH] ICU-4175 test showing that on ICU4C aliasing timezones work correctly X-SVN-Rev: 18280 --- icu4c/source/test/intltest/tztest.cpp | 185 ++++++++++++++++++++++++++ icu4c/source/test/intltest/tztest.h | 4 +- 2 files changed, 188 insertions(+), 1 deletion(-) diff --git a/icu4c/source/test/intltest/tztest.cpp b/icu4c/source/test/intltest/tztest.cpp index ee081d85a98..9ec3b8e09f3 100644 --- a/icu4c/source/test/intltest/tztest.cpp +++ b/icu4c/source/test/intltest/tztest.cpp @@ -47,6 +47,7 @@ void TimeZoneTest::runIndexedTest( int32_t index, UBool exec, const char* &name, CASE(10,TestCountries); CASE(11,TestHistorical); CASE(12,TestEquivalentIDs); + CASE(13, TestAliasedNames); default: name = ""; break; } } @@ -864,6 +865,190 @@ void TimeZoneTest::TestCustomParse() } } + +void +TimeZoneTest::TestAliasedNames() +{ + struct { + const char *from; + const char *to; + } kData[] = { + /* Generated by org.unicode.cldr.tool.CountItems */ + { "America/Argentina/Buenos_Aires", "America/Buenos_Aires" }, + { "America/Argentina/Catamarca", "America/Catamarca" }, + { "America/Argentina/Cordoba", "America/Cordoba" }, + { "America/Argentina/Jujuy", "America/Jujuy" }, + { "America/Argentina/Mendoza", "America/Mendoza" }, + { "America/Atka", "America/Adak" }, + { "America/Ensenada", "America/Tijuana" }, + { "America/Fort_Wayne", "America/Indianapolis" }, + { "America/Indiana/Indianapolis", "America/Indianapolis" }, + { "America/Kentucky/Louisville", "America/Louisville" }, + { "America/Knox_IN", "America/Indiana/Knox" }, + { "America/Porto_Acre", "America/Rio_Branco" }, + { "America/Rosario", "America/Cordoba" }, + { "America/Virgin", "America/St_Thomas" }, + { "Asia/Ashkhabad", "Asia/Ashgabat" }, + { "Asia/Chungking", "Asia/Chongqing" }, + { "Asia/Dacca", "Asia/Dhaka" }, + { "Asia/Istanbul", "Europe/Istanbul" }, + { "Asia/Macao", "Asia/Macau" }, + { "Asia/Tel_Aviv", "Asia/Jerusalem" }, + { "Asia/Thimbu", "Asia/Thimphu" }, + { "Asia/Ujung_Pandang", "Asia/Makassar" }, + { "Asia/Ulan_Bator", "Asia/Ulaanbaatar" }, + { "Australia/ACT", "Australia/Sydney" }, + { "Australia/Canberra", "Australia/Sydney" }, + { "Australia/LHI", "Australia/Lord_Howe" }, + { "Australia/NSW", "Australia/Sydney" }, + { "Australia/North", "Australia/Darwin" }, + { "Australia/Queensland", "Australia/Brisbane" }, + { "Australia/South", "Australia/Adelaide" }, + { "Australia/Tasmania", "Australia/Hobart" }, + { "Australia/Victoria", "Australia/Melbourne" }, + { "Australia/West", "Australia/Perth" }, + { "Australia/Yancowinna", "Australia/Broken_Hill" }, + { "Brazil/Acre", "America/Rio_Branco" }, + { "Brazil/DeNoronha", "America/Noronha" }, + { "Brazil/East", "America/Sao_Paulo" }, + { "Brazil/West", "America/Manaus" }, + { "CST6CDT", "America/Chicago" }, + { "Canada/Atlantic", "America/Halifax" }, + { "Canada/Central", "America/Winnipeg" }, + { "Canada/East-Saskatchewan", "America/Regina" }, + { "Canada/Eastern", "America/Toronto" }, + { "Canada/Mountain", "America/Edmonton" }, + { "Canada/Newfoundland", "America/St_Johns" }, + { "Canada/Pacific", "America/Vancouver" }, + { "Canada/Saskatchewan", "America/Regina" }, + { "Canada/Yukon", "America/Whitehorse" }, + { "Chile/Continental", "America/Santiago" }, + { "Chile/EasterIsland", "Pacific/Easter" }, + { "Cuba", "America/Havana" }, + { "EST", "America/Indianapolis" }, + { "EST5EDT", "America/New_York" }, + { "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" }, + { "Europe/Nicosia", "Asia/Nicosia" }, + { "Europe/Tiraspol", "Europe/Chisinau" }, + { "GB", "Europe/London" }, + { "GB-Eire", "Europe/London" }, + { "GMT", "Etc/GMT" }, + { "GMT+0", "Etc/GMT" }, + { "GMT-0", "Etc/GMT" }, + { "GMT0", "Etc/GMT" }, + { "Greenwich", "Etc/GMT" }, + { "HST", "Pacific/Honolulu" }, + { "Hongkong", "Asia/Hong_Kong" }, + { "Iceland", "Atlantic/Reykjavik" }, + { "Iran", "Asia/Tehran" }, + { "Israel", "Asia/Jerusalem" }, + { "Jamaica", "America/Jamaica" }, + { "Japan", "Asia/Tokyo" }, + { "Kwajalein", "Pacific/Kwajalein" }, + { "Libya", "Africa/Tripoli" }, + { "MST", "America/Phoenix" }, + { "MST7MDT", "America/Denver" }, + { "Mexico/BajaNorte", "America/Tijuana" }, + { "Mexico/BajaSur", "America/Mazatlan" }, + { "Mexico/General", "America/Mexico_City" }, + { "NZ", "Pacific/Auckland" }, + { "NZ-CHAT", "Pacific/Chatham" }, + { "Navajo", "America/Denver" }, + { "PRC", "Asia/Shanghai" }, + { "PST8PDT", "America/Los_Angeles" }, + { "Pacific/Samoa", "Pacific/Pago_Pago" }, + { "Poland", "Europe/Warsaw" }, + { "Portugal", "Europe/Lisbon" }, + { "ROC", "Asia/Taipei" }, + { "ROK", "Asia/Seoul" }, + { "Singapore", "Asia/Singapore" }, + { "SystemV/AST4", "America/Puerto_Rico" }, + { "SystemV/AST4ADT", "America/Halifax" }, + { "SystemV/CST6", "America/Regina" }, + { "SystemV/CST6CDT", "America/Chicago" }, + { "SystemV/EST5", "America/Indianapolis" }, + { "SystemV/EST5EDT", "America/New_York" }, + { "SystemV/HST10", "Pacific/Honolulu" }, + { "SystemV/MST7", "America/Phoenix" }, + { "SystemV/MST7MDT", "America/Denver" }, + { "SystemV/PST8", "Pacific/Pitcairn" }, + { "SystemV/PST8PDT", "America/Los_Angeles" }, + { "SystemV/YST9", "Pacific/Gambier" }, + { "SystemV/YST9YDT", "America/Anchorage" }, + { "Turkey", "Europe/Istanbul" }, + { "UCT", "Etc/GMT" }, + { "US/Alaska", "America/Anchorage" }, + { "US/Aleutian", "America/Adak" }, + { "US/Arizona", "America/Phoenix" }, + { "US/Central", "America/Chicago" }, + { "US/East-Indiana", "America/Indianapolis" }, + { "US/Eastern", "America/New_York" }, + { "US/Hawaii", "Pacific/Honolulu" }, + { "US/Indiana-Starke", "America/Indiana/Knox" }, + { "US/Michigan", "America/Detroit" }, + { "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" }, + { "W-SU", "Europe/Moscow" }, + { "Zulu", "Etc/GMT" } + /* Total: 129 */ + + }; + + TimeZone::EDisplayType styles[] = { TimeZone::SHORT, TimeZone::LONG }; + UBool useDst[] = { FALSE, TRUE }; + int32_t noLoc = uloc_countAvailable(); + + UErrorCode status = U_ZERO_ERROR; + int32_t i, j, k, loc; + UnicodeString fromName, toName; + TimeZone *from = NULL, *to = NULL; + for(i = 0; i < sizeof(kData)/sizeof(kData[0]); i++) { + from = TimeZone::createTimeZone(kData[i].from); + to = TimeZone::createTimeZone(kData[i].to); + if(!from->hasSameRules(*to)) { + errln("different at %i\n", i); + } + if(!quick) { + for(loc = 0; loc < noLoc; loc++) { + for(j = 0; j < sizeof(styles)/sizeof(styles[0]); j++) { + for(k = 0; k < sizeof(useDst)/sizeof(useDst[0]); k++) { + fromName.remove(); + toName.remove(); + from->getDisplayName(useDst[k], styles[j], uloc_getAvailable(loc), fromName); + to->getDisplayName(useDst[k], styles[j], uloc_getAvailable(loc), toName); + if(fromName.compare(toName) != 0) { + errln("Fail: Expected "+toName+" but got " + fromName); + } + } + } + } + } else { + fromName.remove(); + toName.remove(); + from->getDisplayName(fromName); + to->getDisplayName(toName); + if(fromName.compare(toName) != 0) { + errln("Fail: Expected "+toName+" but got " + fromName); + } + } + delete from; + delete to; + } +} + /** * Test the basic functionality of the getDisplayName() API. * diff --git a/icu4c/source/test/intltest/tztest.h b/icu4c/source/test/intltest/tztest.h index 310a304b585..5e24930bb4b 100644 --- a/icu4c/source/test/intltest/tztest.h +++ b/icu4c/source/test/intltest/tztest.h @@ -1,7 +1,7 @@ /******************************************************************** * COPYRIGHT: - * Copyright (c) 1997-2003, International Business Machines Corporation and + * Copyright (c) 1997-2005, International Business Machines Corporation and * others. All Rights Reserved. ********************************************************************/ @@ -83,6 +83,8 @@ public: void TestEquivalentIDs(void); + void TestAliasedNames(void); + static const UDate INTERVAL; private: