X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/b75a7d8f3b4adbae880cab104ce2c6a50eee4db2..e4f10fab0c078f399c9deef476d9c9b73b47dff8:/icuSources/test/intltest/miscdtfm.cpp?ds=sidebyside diff --git a/icuSources/test/intltest/miscdtfm.cpp b/icuSources/test/intltest/miscdtfm.cpp index f7bd3842..838f1ba8 100644 --- a/icuSources/test/intltest/miscdtfm.cpp +++ b/icuSources/test/intltest/miscdtfm.cpp @@ -1,8 +1,7 @@ -/******************************************************************** - * COPYRIGHT: - * Copyright (c) 1997-2001, International Business Machines Corporation and - * others. All Rights Reserved. - ********************************************************************/ +/*********************************************************************** + * Copyright (c) 1997-2011, International Business Machines Corporation + * and others. All Rights Reserved. + ***********************************************************************/ #include "unicode/utypes.h" @@ -44,7 +43,7 @@ UBool DateFormatMiscTests::failure(UErrorCode status, const char* msg) { if(U_FAILURE(status)) { - errln(UnicodeString("FAIL: ") + msg + " failed, error " + u_errorName(status)); + errcheckln(status, UnicodeString("FAIL: ") + msg + " failed, error " + u_errorName(status)); return TRUE; } @@ -114,7 +113,10 @@ DateFormatMiscTests::test4097450() UErrorCode status = U_ZERO_ERROR; SimpleDateFormat *formatter; SimpleDateFormat *resultFormatter = new SimpleDateFormat((UnicodeString)"yyyy", status); - failure(status, "new SimpleDateFormat"); + if (U_FAILURE(status)) { + dataerrln("Fail new SimpleDateFormat: %s", u_errorName(status)); + return; + } logln("Format\tSource\tResult"); logln("-------\t-------\t-------"); @@ -122,7 +124,7 @@ DateFormatMiscTests::test4097450() { log(dformat[i] + "\t" + dstring[i] + "\t"); formatter = new SimpleDateFormat(dformat[i], status); - failure(status, "new SimpleDateFormat"); + if(failure(status, "new SimpleDateFormat")) return; //try { UnicodeString str; FieldPosition pos(FieldPosition::DONT_CARE); @@ -157,9 +159,12 @@ DateFormatMiscTests::test4099975() { UErrorCode status = U_ZERO_ERROR; DateFormatSymbols* symbols = new DateFormatSymbols(Locale::getUS(), status); - failure(status, "new DateFormatSymbols"); + if (U_FAILURE(status)) { + dataerrln("Unable to create DateFormatSymbols - %s", u_errorName(status)); + return; + } SimpleDateFormat *df = new SimpleDateFormat(UnicodeString("E hh:mm"), *symbols, status); - failure(status, "new SimpleDateFormat"); + if(failure(status, "new SimpleDateFormat")) return; UnicodeString format0; format0 = df->format(d, format0); UnicodeString localizedPattern0; @@ -189,9 +194,9 @@ DateFormatMiscTests::test4099975() { UErrorCode status = U_ZERO_ERROR; DateFormatSymbols* symbols = new DateFormatSymbols(Locale::getUS(), status); - failure(status, "new DateFormatSymbols"); + if(failure(status, "new DateFormatSymbols")) return; SimpleDateFormat *df = new SimpleDateFormat(UnicodeString("E hh:mm"), status); - failure(status, "new SimpleDateFormat"); + if(failure(status, "new SimpleDateFormat")) return; df->setDateFormatSymbols(*symbols); UnicodeString format0; format0 = df->format(d, format0); @@ -220,9 +225,9 @@ DateFormatMiscTests::test4099975() { UErrorCode status = U_ZERO_ERROR; DateFormatSymbols* symbols = new DateFormatSymbols(Locale::getUS(), status); - failure(status, "new DateFormatSymbols"); + if(failure(status, "new DateFormatSymbols")) return; SimpleDateFormat *df = new SimpleDateFormat(UnicodeString("E hh:mm"), symbols, status); - failure(status, "new SimpleDateFormat"); + if(failure(status, "new SimpleDateFormat")) return; UnicodeString format0; format0 = df->format(d, format0); UnicodeString localizedPattern0; @@ -251,7 +256,7 @@ DateFormatMiscTests::test4099975() DateFormatSymbols* symbols = new DateFormatSymbols(Locale::getUS(), status); failure(status, "new DateFormatSymbols"); SimpleDateFormat *df = new SimpleDateFormat(UnicodeString("E hh:mm"), status); - failure(status, "new SimpleDateFormat"); + if(failure(status, "new SimpleDateFormat")) return; df-> adoptDateFormatSymbols(symbols); UnicodeString format0; format0 = df->format(d, format0); @@ -308,21 +313,27 @@ DateFormatMiscTests::test4117335() 0x6e96, 0x6642 }; - UnicodeString jstLong(jstLongC, 5, 5); + UChar jdtLongC [] = {0x65E5, 0x672C, 0x590F, 0x6642, 0x9593}; - UnicodeString jstShort = "JST"; + UnicodeString jstLong(jstLongC, 5, 5); +// UnicodeString jstShort = "JST"; + UnicodeString tzID = "Asia/Tokyo"; + + UnicodeString jdtLong(jdtLongC, 5, 5); + +// UnicodeString jdtShort = "JDT"; UErrorCode status = U_ZERO_ERROR; DateFormatSymbols *symbols = new DateFormatSymbols(Locale::getJapan(), status); if(U_FAILURE(status)) { - errln("Failure creating DateFormatSymbols, %s", u_errorName(status)); + dataerrln("Failure creating DateFormatSymbols, %s", u_errorName(status)); delete symbols; return; } failure(status, "new DateFormatSymbols"); int32_t eraCount = 0; - const UnicodeString *eras = symbols->getEras(eraCount); + const UnicodeString *eras = symbols->getEraNames(eraCount); logln(UnicodeString("BC = ") + eras[0]); if (eras[0] != bc) { @@ -338,26 +349,34 @@ DateFormatMiscTests::test4117335() int32_t rowCount, colCount; const UnicodeString **zones = symbols->getZoneStrings(rowCount, colCount); - logln(UnicodeString("Long zone name = ") + zones[0][1]); - if (zones[0][1] != jstLong) { - errln("*** Should have been " + jstLong); - //throw new Exception("Error in long TZ name"); - } - logln(UnicodeString("Short zone name = ") + zones[0][2]); - if (zones[0][2] != jstShort) { - errln("*** Should have been " + jstShort); - //throw new Exception("Error in short TZ name"); + //don't hard code the index .. compute it. + int32_t index = -1; + for (int32_t i = 0; i < rowCount; ++i) { + if (tzID == (zones[i][0])) { + index = i; + break; + } } - logln(UnicodeString("Long zone name = ") + zones[0][3]); - if (zones[0][3] != jstLong) { - errln("*** Should have been " + jstLong); + logln(UnicodeString("Long zone name = ") + zones[index][1]); + if (zones[index][1] != jstLong) { + errln("*** Should have been " + prettify(jstLong)+ " but it is: " + prettify(zones[index][1])); //throw new Exception("Error in long TZ name"); } - logln(UnicodeString("SHORT zone name = ") + zones[0][4]); - if (zones[0][4] != jstShort) { - errln("*** Should have been " + jstShort); - //throw new Exception("Error in short TZ name"); +// logln(UnicodeString("Short zone name = ") + zones[index][2]); +// if (zones[index][2] != jstShort) { +// errln("*** Should have been " + prettify(jstShort) + " but it is: " + prettify(zones[index][2])); +// //throw new Exception("Error in short TZ name"); +// } + logln(UnicodeString("Long zone name = ") + zones[index][3]); + if (zones[index][3] != jdtLong) { + errln("*** Should have been " + prettify(jstLong) + " but it is: " + prettify(zones[index][3])); + //throw new Exception("Error in long TZ name"); } +// logln(UnicodeString("SHORT zone name = ") + zones[index][4]); +// if (zones[index][4] != jdtShort) { +// errln("*** Should have been " + prettify(jstShort)+ " but it is: " + prettify(zones[index][4])); +// //throw new Exception("Error in short TZ name"); +// } delete symbols; }