/***********************************************************************
* COPYRIGHT:
- * Copyright (c) 1997-2004, International Business Machines Corporation
+ * Copyright (c) 1997-2006, International Business Machines Corporation
* and others. All Rights Reserved.
***********************************************************************/
CASE(10,TestCountries);
CASE(11,TestHistorical);
CASE(12,TestEquivalentIDs);
+ CASE(13, TestAliasedNames);
+ CASE(14, TestFractionalDST);
default: name = ""; break;
}
}
{"PNT", -420, FALSE},
{"MST", -420, FALSE}, // updated Aug 2003 aliu
{"CST", -360, TRUE},
- {"IET", -300, FALSE},
+ {"IET", -300, TRUE}, // updated Jan 2006 srl
{"EST", -300, FALSE}, // updated Aug 2003 aliu
{"PRT", -240, FALSE},
{"CNT", -210, TRUE},
kData[] =
{
// ID Expected offset in minutes
- //"GMT", kUnparseable, Isn't custom. Can't test it here. [returns normal GMT]
+ //{"GMT", kUnparseable}, //Isn't custom. Can't test it here. [returns normal GMT]
{"GMT-YOUR.AD.HERE", kUnparseable},
// {"GMT0", kUnparseable}, // ICU 2.8: An Olson zone ID
// {"GMT+0", (0)}, // ICU 2.8: An Olson zone ID
{
UnicodeString id(kData[i].customId);
int32_t exp = kData[i].expectedOffset;
+/*
+ { // for no data test Jitterbug 4354
+ UErrorCode success = U_ZERO_ERROR;
+ NumberFormat* numberFormat = NumberFormat::createInstance(success);
+ if (U_FAILURE(success)) {
+ dataerrln(" NumberFormat::createInstance() error");
+ return;
+ }
+ delete numberFormat;
+ }
+ */
TimeZone *zone = TimeZone::createTimeZone(id);
UnicodeString itsID, temp;
}
}
+static const UVersionInfo ICU_37 = {3,7,0,0};
+
+void
+TimeZoneTest::TestAliasedNames()
+{
+ struct {
+ const char *from;
+ const char *to;
+ } kData[] = {
+ /* Generated by org.unicode.cldr.tool.CountItems */
+
+ /* zoneID, canonical zoneID */
+ {"Africa/Timbuktu", "Africa/Bamako"},
+ {"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/Atka", "America/Adak"},
+ {"America/Ensenada", "America/Tijuana"},
+ {"America/Fort_Wayne", "America/Indiana/Indianapolis"},
+ {"America/Indianapolis", "America/Indiana/Indianapolis"},
+ {"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"},
+ {"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"},
+ {"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"},
+ {"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/Belfast", "Europe/London"},
+ {"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"},
+ {"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"},
+ {"Mexico/BajaNorte", "America/Tijuana"},
+ {"Mexico/BajaSur", "America/Mazatlan"},
+ {"Mexico/General", "America/Mexico_City"},
+ {"NZ", "Pacific/Auckland"},
+ {"NZ-CHAT", "Pacific/Chatham"},
+ {"Navajo", "America/Shiprock"},
+ {"PRC", "Asia/Shanghai"},
+ {"Pacific/Samoa", "Pacific/Pago_Pago"},
+ {"Pacific/Yap", "Pacific/Truk"},
+ {"Poland", "Europe/Warsaw"},
+ {"Portugal", "Europe/Lisbon"},
+ {"ROC", "Asia/Taipei"},
+ {"ROK", "Asia/Seoul"},
+ {"Singapore", "Asia/Singapore"},
+ {"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/Indiana/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: 113 */
+
+ };
+
+ TimeZone::EDisplayType styles[] = { TimeZone::SHORT, TimeZone::LONG };
+ UBool useDst[] = { FALSE, TRUE };
+ int32_t noLoc = uloc_countAvailable();
+
+ if(isICUVersionAtLeast(ICU_37)) {
+ errln("This test needs to be fixed. This test fails in exhaustive mode because we need to implement generic timezones.\n");
+ }
+
+ 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++) {
+ from = TimeZone::createTimeZone(kData[i].from);
+ to = TimeZone::createTimeZone(kData[i].to);
+ if(!from->hasSameRules(*to)) {
+ errln("different at %i\n", i);
+ }
+ if(!quick && isICUVersionAtLeast(ICU_37)) {
+ errln("This test needs to be fixed. This test fails in exhaustive mode because we need to implement generic timezones.\n");
+ 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++) {
+ fromName.remove();
+ toName.remove();
+ from->getDisplayName(useDst[k], styles[j],locale, fromName);
+ to->getDisplayName(useDst[k], styles[j], locale, toName);
+ if(fromName.compare(toName) != 0) {
+ errln("Fail: Expected "+toName+" but got " + prettify(fromName)
+ + " for locale: " + locale + " index: "+ loc
+ + " to id "+ kData[i].to
+ + " from id " + kData[i].from);
+ }
+ }
+ }
+ }
+ } 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.
*
+ (offset / U_MILLIS_PER_HOUR) + " hours.");
}
+void TimeZoneTest::TestFractionalDST() {
+ const char* tzName = "Australia/Lord_Howe"; // 30 min offset
+ TimeZone* tz_icu = TimeZone::createTimeZone(tzName);
+ int dst_icu = tz_icu->getDSTSavings();
+ UnicodeString id;
+ int32_t expected = 1800000;
+ if (expected != dst_icu) {
+ errln(UnicodeString("java reports dst savings of ") + expected +
+ " but icu reports " + dst_icu +
+ " for tz " + tz_icu->getID(id));
+ } else {
+ logln(UnicodeString("both java and icu report dst savings of ") + expected + " for tz " + tz_icu->getID(id));
+ }
+ delete tz_icu;
+}
+
/**
* Test country code support. Jitterbug 776.
*/