X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/73c04bcfe1096173b00431f0cdc742894b15eef0..b331163bffd790ced0e88b73f44f86d49ccc48a5:/icuSources/test/intltest/sdtfmtts.cpp diff --git a/icuSources/test/intltest/sdtfmtts.cpp b/icuSources/test/intltest/sdtfmtts.cpp index 064acba3..546b43cc 100644 --- a/icuSources/test/intltest/sdtfmtts.cpp +++ b/icuSources/test/intltest/sdtfmtts.cpp @@ -1,7 +1,7 @@ /******************************************************************** * COPYRIGHT: - * Copyright (c) 1997-2006, International Business Machines Corporation and + * Copyright (c) 1997-2014, International Business Machines Corporation and * others. All Rights Reserved. ********************************************************************/ @@ -58,10 +58,13 @@ void IntlTestSimpleDateFormatAPI::testAPI(/*char *par*/) } status = U_ZERO_ERROR; - const UnicodeString pattern("yyyy.MM.dd G 'at' hh:mm:ss z"); + const UnicodeString pattern("yyyy.MM.dd G 'at' hh:mm:ss z", ""); + const UnicodeString override("y=hebr;d=thai;s=arab", ""); /* use invariant converter */ + const UnicodeString override_bogus("y=hebr;d=thai;s=bogus", ""); + SimpleDateFormat pat(pattern, status); if(U_FAILURE(status)) { - errln("ERROR: Could not create SimpleDateFormat (pattern)"); + errln("ERROR: Could not create SimpleDateFormat (pattern) - %s", u_errorName(status)); } status = U_ZERO_ERROR; @@ -89,6 +92,27 @@ void IntlTestSimpleDateFormatAPI::testAPI(/*char *par*/) errln("ERROR: Could not create SimpleDateFormat (pattern, symbols)"); } + status = U_ZERO_ERROR; + logln(UnicodeString("Override with: ") + override); + SimpleDateFormat ovr1(pattern, override, status); + if(U_FAILURE(status)) { + errln("ERROR: Could not create SimpleDateFormat (pattern, override) - %s", u_errorName(status)); + } + + status = U_ZERO_ERROR; + SimpleDateFormat ovr2(pattern, override, Locale::getGerman(), status); + if(U_FAILURE(status)) { + errln("ERROR: Could not create SimpleDateFormat (pattern, override, locale) - %s", u_errorName(status)); + } + + status = U_ZERO_ERROR; + logln(UnicodeString("Override with: ") + override_bogus); + SimpleDateFormat ovr3(pattern, override_bogus, Locale::getGerman(), status); + if(U_SUCCESS(status)) { + errln("ERROR: Should not have been able to create SimpleDateFormat (pattern, override, locale) with a bogus override"); + } + + SimpleDateFormat copy(pat); // ======= Test clone(), assignment, and equality @@ -205,7 +229,7 @@ void IntlTestSimpleDateFormatAPI::testAPI(/*char *par*/) status = U_ZERO_ERROR; pat.applyLocalizedPattern(p1, status); if(U_FAILURE(status)) { - errln("ERROR: applyPattern() failed with " + (int32_t) status); + errln("ERROR: applyPattern() failed with %s", u_errorName(status)); } UnicodeString s3; status = U_ZERO_ERROR; @@ -231,8 +255,26 @@ void IntlTestSimpleDateFormatAPI::testAPI(/*char *par*/) if(test->getDynamicClassID() != SimpleDateFormat::getStaticClassID()) { errln("ERROR: getDynamicClassID() didn't return the expected value"); } - + delete test; + +// ======= Test Ticket 5684 (Parsing with 'e' and 'Y') + SimpleDateFormat object(UNICODE_STRING_SIMPLE("YYYY'W'wwe"), status); + if(U_FAILURE(status)) { + errln("ERROR: Couldn't create a SimpleDateFormat"); + } + object.setLenient(false); + ParsePosition pp(0); + UDate udDate = object.parse("2007W014", pp); + if ((double)udDate == 0.0) { + errln("ERROR: Parsing failed using 'Y' and 'e'"); + } + +// ====== Test ticket 11295 getNumberFormatForField returns wild pointer + if (object.getNumberFormatForField('B') != NULL) { + errln("B is not a valid field, " + "getNumberFormatForField should return NULL"); + } } #endif /* #if !UCONFIG_NO_FORMATTING */