X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/4388f060552cc537e71e957d32f35e9d75a61233..08b89b0a244153b9f5bbb2f49c55ab0f7298122e:/icuSources/test/intltest/dtifmtts.cpp diff --git a/icuSources/test/intltest/dtifmtts.cpp b/icuSources/test/intltest/dtifmtts.cpp index 361007a3..9102cf6c 100644 --- a/icuSources/test/intltest/dtifmtts.cpp +++ b/icuSources/test/intltest/dtifmtts.cpp @@ -1,7 +1,7 @@ /******************************************************************** * COPYRIGHT: - * Copyright (c) 1997-2012, International Business Machines Corporation and + * Copyright (c) 1997-2013, International Business Machines Corporation and * others. All Rights Reserved. ********************************************************************/ @@ -25,6 +25,7 @@ #include "unicode/dtintrv.h" #include "unicode/dtitvinf.h" #include "unicode/dtitvfmt.h" +#include "unicode/localpointer.h" #include "unicode/timezone.h" @@ -45,7 +46,9 @@ void DateIntervalFormatTest::runIndexedTest( int32_t index, UBool exec, const ch TESTCASE(0, testAPI); TESTCASE(1, testFormat); TESTCASE(2, testFormatUserDII); - TESTCASE(3, testStress); + TESTCASE(3, testSetIntervalPatternNoSideEffect); + TESTCASE(4, testYearFormats); + TESTCASE(5, testStress); default: name = ""; break; } } @@ -137,6 +140,59 @@ void DateIntervalFormatTest::testAPI() { dataerrln("ERROR: getDateIntervalInfo/setDateIntervalInfo failed"); } + { + // We make sure that setDateIntervalInfo does not corrupt the cache. See ticket 9919. + status = U_ZERO_ERROR; + logln("Testing DateIntervalFormat setDateIntervalInfo"); + const Locale &enLocale = Locale::getEnglish(); + LocalPointer dif(DateIntervalFormat::createInstance("yMd", enLocale, status)); + if (U_FAILURE(status)) { + errln("Failure encountered: %s", u_errorName(status)); + return; + } + UnicodeString expected; + LocalPointer fromTime(Calendar::createInstance(enLocale, status)); + LocalPointer toTime(Calendar::createInstance(enLocale, status)); + if (U_FAILURE(status)) { + errln("Failure encountered: %s", u_errorName(status)); + return; + } + FieldPosition pos = 0; + fromTime->set(2013, 3, 26); + toTime->set(2013, 3, 28); + dif->format(*fromTime, *toTime, expected, pos, status); + if (U_FAILURE(status)) { + errln("Failure encountered: %s", u_errorName(status)); + return; + } + LocalPointer dii(new DateIntervalInfo(Locale::getEnglish(), status)); + if (U_FAILURE(status)) { + errln("Failure encountered: %s", u_errorName(status)); + return; + } + dii->setIntervalPattern(ctou("yMd"), UCAL_DATE, ctou("M/d/y \\u2013 d"), status); + dif->setDateIntervalInfo(*dii, status); + if (U_FAILURE(status)) { + errln("Failure encountered: %s", u_errorName(status)); + return; + } + dif.adoptInstead(DateIntervalFormat::createInstance("yMd", enLocale, status)); + if (U_FAILURE(status)) { + errln("Failure encountered: %s", u_errorName(status)); + return; + } + UnicodeString actual; + pos = 0; + dif->format(*fromTime, *toTime, actual, pos, status); + if (U_FAILURE(status)) { + errln("Failure encountered: %s", u_errorName(status)); + return; + } + if (expected != actual) { + errln("DateIntervalFormat.setIntervalInfo should have no side effects."); + } + } + /* status = U_ZERO_ERROR; DateIntervalInfo* nonConstInf = inf->clone(); @@ -274,8 +330,8 @@ void DateIntervalFormatTest::testAPI() { DateInterval * dtitv12 = new DateInterval(date1, date2); TimeZone * tzCalif = TimeZone::createTimeZone("US/Pacific"); TimeZone * tzTokyo = TimeZone::createTimeZone("Asia/Tokyo"); - UnicodeString fmtCalif = UnicodeString(ctou("Mar 2 10:30 - Mar 2 17:30")); - UnicodeString fmtTokyo = UnicodeString(ctou("Mar 3 03:30 - Mar 3 10:30")); + UnicodeString fmtCalif = UnicodeString(ctou("Mar 2, 10:30 - 17:30")); + UnicodeString fmtTokyo = UnicodeString(ctou("Mar 3, 03:30 - 10:30")); dtitvfmt->adoptTimeZone(tzCalif); res.remove(); @@ -346,7 +402,7 @@ void DateIntervalFormatTest::testFormat() { const char* DATA[] = { "yyyy MM dd HH:mm:ss", // test root - "root", "2007 11 10 10:10:10", "2007 12 10 10:10:10", "yM", "2007-11 \\u2013 12", + "root", "2007 11 10 10:10:10", "2007 12 10 10:10:10", "yM", "2007-11 \\u2013 2007-12", // test 'H' and 'h', using availableFormat in fallback "en", "2007 11 10 10:10:10", "2007 11 10 15:10:10", "Hms", "10:10:10 - 15:10:10", @@ -355,9 +411,9 @@ void DateIntervalFormatTest::testFormat() { "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "MMMM", "October 2007 - October 2008", "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "MMM", "Oct 2007 - Oct 2008", // test skeleton with both date and time - "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "dMMMyhm", "Nov 10, 2007 10:10 AM - Nov 20, 2007 10:10 AM", + "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "dMMMyhm", "Nov 10, 2007, 10:10 AM - Nov 20, 2007, 10:10 AM", - "en", "2007 11 10 10:10:10", "2007 11 10 11:10:10", "dMMMyhm", "Nov 10, 2007 10:10 - 11:10 AM", + "en", "2007 11 10 10:10:10", "2007 11 10 11:10:10", "dMMMyhm", "Nov 10, 2007, 10:10 - 11:10 AM", "en", "2007 11 10 10:10:10", "2007 11 10 11:10:10", "hms", "10:10:10 AM - 11:10:10 AM", "en", "2007 11 10 10:10:10", "2007 11 10 11:10:10", "Hms", "10:10:10 - 11:10:10", @@ -383,53 +439,53 @@ void DateIntervalFormatTest::testFormat() { "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "EdMMM", "Wed, Oct 10, 2007 - Fri, Oct 10, 2008", - "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "EdMy", "Wed, 10/10/07 - Fri, 10/10/08", + "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "EdMy", "Wed, 10/10/2007 - Fri, 10/10/2008", - "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "dMy", "10/10/07 - 10/10/08", + "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "dMy", "10/10/2007 - 10/10/2008", - "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "dM", "10/10/07 - 10/10/08", + "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "dM", "10/10/2007 - 10/10/2008", - "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "My", "10/07 - 10/08", + "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "My", "10/2007 - 10/2008", - "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "EdM", "Wed, 10/10/07 - Fri, 10/10/08", + "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "EdM", "Wed, 10/10/2007 - Fri, 10/10/2008", - "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "d", "10/10/07 - 10/10/08", + "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "d", "10/10/2007 - 10/10/2008", "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "Ed", "10 Wed - 10 Fri", "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "y", "2007 - 2008", - "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "M", "10/07 - 10/08", + "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "M", "10/2007 - 10/2008", - "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "hm", "10/10/2007 10:10 AM - 10/10/2008 10:10 AM", - "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "Hm", "10/10/2007 10:10 - 10/10/2008 10:10", - "en", "2007 10 10 20:10:10", "2008 10 10 20:10:10", "Hm", "10/10/2007 20:10 - 10/10/2008 20:10", + "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "hm", "10/10/2007, 10:10 AM - 10/10/2008, 10:10 AM", + "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "Hm", "10/10/2007, 10:10 - 10/10/2008, 10:10", + "en", "2007 10 10 20:10:10", "2008 10 10 20:10:10", "Hm", "10/10/2007, 20:10 - 10/10/2008, 20:10", - "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "hmv", "10/10/2007 10:10 AM PT - 10/10/2008 10:10 AM PT", + "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "hmv", "10/10/2007, 10:10 AM PT - 10/10/2008, 10:10 AM PT", - "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "hmz", "10/10/2007 10:10 AM PDT - 10/10/2008 10:10 AM PDT", + "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "hmz", "10/10/2007, 10:10 AM PDT - 10/10/2008, 10:10 AM PDT", - "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "h", "10/10/2007 10 AM - 10/10/2008 10 AM", + "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "h", "10/10/2007, 10 AM - 10/10/2008, 10 AM", - "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "hv", "10/10/2007 10 AM PT - 10/10/2008 10 AM PT", + "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "hv", "10/10/2007, 10 AM PT - 10/10/2008, 10 AM PT", - "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "hz", "10/10/2007 10 AM PDT - 10/10/2008 10 AM PDT", + "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "hz", "10/10/2007, 10 AM PDT - 10/10/2008, 10 AM PDT", - "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "EEddMMyyyy", "Wed, 10/10/07 - Fri, 10/10/08", + "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "EEddMMyyyy", "Wed, 10/10/2007 - Fri, 10/10/2008", - "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "EddMMy", "Wed, 10/10/07 - Fri, 10/10/08", + "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "EddMMy", "Wed, 10/10/2007 - Fri, 10/10/2008", - "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "hhmm", "10/10/2007 10:10 AM - 10/10/2008 10:10 AM", + "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "hhmm", "10/10/2007, 10:10 AM - 10/10/2008, 10:10 AM", - "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "hhmmzz", "10/10/2007 10:10 AM PDT - 10/10/2008 10:10 AM PDT", + "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "hhmmzz", "10/10/2007, 10:10 AM PDT - 10/10/2008, 10:10 AM PDT", - "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "hms", "10/10/2007 10:10:10 AM - 10/10/2008 10:10:10 AM", + "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "hms", "10/10/2007, 10:10:10 AM - 10/10/2008, 10:10:10 AM", "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "dMMMMMy", "O 10, 2007 - O 10, 2008", - "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "EEEEEdM", "W, 10/10/07 - F, 10/10/08", + "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "EEEEEdM", "W, 10/10/2007 - F, 10/10/2008", "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "EEEEdMMMMy", "Wednesday, October 10 - Saturday, November 10, 2007", @@ -451,12 +507,12 @@ void DateIntervalFormatTest::testFormat() { "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "EdMMM", "Wed, Oct 10 - Sat, Nov 10", - "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "EdMy", "Wed, 10/10/07 - Sat, 11/10/07", + "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "EdMy", "Wed, 10/10/2007 - Sat, 11/10/2007", - "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "dMy", "10/10/07 - 11/10/07", + "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "dMy", "10/10/2007 - 11/10/2007", - "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "My", "10/07 - 11/07", + "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "My", "10/2007 - 11/2007", "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "EdM", "Wed, 10/10 - Sat, 11/10", @@ -472,28 +528,28 @@ void DateIntervalFormatTest::testFormat() { "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "MMMM", "October - November", - "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "hm", "10/10/2007 10:10 AM - 11/10/2007 10:10 AM", - "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "Hm", "10/10/2007 10:10 - 11/10/2007 10:10", - "en", "2007 10 10 20:10:10", "2007 11 10 20:10:10", "Hm", "10/10/2007 20:10 - 11/10/2007 20:10", + "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "hm", "10/10/2007, 10:10 AM - 11/10/2007, 10:10 AM", + "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "Hm", "10/10/2007, 10:10 - 11/10/2007, 10:10", + "en", "2007 10 10 20:10:10", "2007 11 10 20:10:10", "Hm", "10/10/2007, 20:10 - 11/10/2007, 20:10", - "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "hmv", "10/10/2007 10:10 AM PT - 11/10/2007 10:10 AM PT", + "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "hmv", "10/10/2007, 10:10 AM PT - 11/10/2007, 10:10 AM PT", - "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "hmz", "10/10/2007 10:10 AM PDT - 11/10/2007 10:10 AM PST", + "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "hmz", "10/10/2007, 10:10 AM PDT - 11/10/2007, 10:10 AM PST", - "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "h", "10/10/2007 10 AM - 11/10/2007 10 AM", + "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "h", "10/10/2007, 10 AM - 11/10/2007, 10 AM", - "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "hv", "10/10/2007 10 AM PT - 11/10/2007 10 AM PT", + "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "hv", "10/10/2007, 10 AM PT - 11/10/2007, 10 AM PT", - "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "hz", "10/10/2007 10 AM PDT - 11/10/2007 10 AM PST", + "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "hz", "10/10/2007, 10 AM PDT - 11/10/2007, 10 AM PST", - "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "EEddMMyyyy", "Wed, 10/10/07 - Sat, 11/10/07", + "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "EEddMMyyyy", "Wed, 10/10/2007 - Sat, 11/10/2007", - "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "EddMMy", "Wed, 10/10/07 - Sat, 11/10/07", + "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "EddMMy", "Wed, 10/10/2007 - Sat, 11/10/2007", - "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "hhmmzz", "10/10/2007 10:10 AM PDT - 11/10/2007 10:10 AM PST", + "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "hhmmzz", "10/10/2007, 10:10 AM PDT - 11/10/2007, 10:10 AM PST", - "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "hms", "10/10/2007 10:10:10 AM - 11/10/2007 10:10:10 AM", + "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "hms", "10/10/2007, 10:10:10 AM - 11/10/2007, 10:10:10 AM", "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "dMMMMMy", "O 10 - N 10, 2007", @@ -518,9 +574,9 @@ void DateIntervalFormatTest::testFormat() { "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EdMMM", "Sat, Nov 10 - Tue, Nov 20", - "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EdMy", "Sat, 11/10/07 - Tue, 11/20/07", + "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EdMy", "Sat, 11/10/2007 - Tue, 11/20/2007", - "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "dMy", "11/10/07 - 11/20/07", + "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "dMy", "11/10/2007 - 11/20/2007", "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "dM", "11/10 - 11/20", @@ -540,31 +596,31 @@ void DateIntervalFormatTest::testFormat() { "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "MMMM", "November", - "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "hm", "11/10/2007 10:10 AM - 11/20/2007 10:10 AM", - "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "Hm", "11/10/2007 10:10 - 11/20/2007 10:10", - "en", "2007 11 10 20:10:10", "2007 11 20 20:10:10", "Hm", "11/10/2007 20:10 - 11/20/2007 20:10", + "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "hm", "11/10/2007, 10:10 AM - 11/20/2007, 10:10 AM", + "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "Hm", "11/10/2007, 10:10 - 11/20/2007, 10:10", + "en", "2007 11 10 20:10:10", "2007 11 20 20:10:10", "Hm", "11/10/2007, 20:10 - 11/20/2007, 20:10", - "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "hmv", "11/10/2007 10:10 AM PT - 11/20/2007 10:10 AM PT", + "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "hmv", "11/10/2007, 10:10 AM PT - 11/20/2007, 10:10 AM PT", - "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "hmz", "11/10/2007 10:10 AM PST - 11/20/2007 10:10 AM PST", + "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "hmz", "11/10/2007, 10:10 AM PST - 11/20/2007, 10:10 AM PST", - "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "h", "11/10/2007 10 AM - 11/20/2007 10 AM", + "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "h", "11/10/2007, 10 AM - 11/20/2007, 10 AM", - "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "hv", "11/10/2007 10 AM PT - 11/20/2007 10 AM PT", + "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "hv", "11/10/2007, 10 AM PT - 11/20/2007, 10 AM PT", - "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "hz", "11/10/2007 10 AM PST - 11/20/2007 10 AM PST", + "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "hz", "11/10/2007, 10 AM PST - 11/20/2007, 10 AM PST", - "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EEddMMyyyy", "Sat, 11/10/07 - Tue, 11/20/07", + "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EEddMMyyyy", "Sat, 11/10/2007 - Tue, 11/20/2007", - "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EddMMy", "Sat, 11/10/07 - Tue, 11/20/07", + "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EddMMy", "Sat, 11/10/2007 - Tue, 11/20/2007", - "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "hhmm", "11/10/2007 10:10 AM - 11/20/2007 10:10 AM", + "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "hhmm", "11/10/2007, 10:10 AM - 11/20/2007, 10:10 AM", - "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "hhmmzz", "11/10/2007 10:10 AM PST - 11/20/2007 10:10 AM PST", + "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "hhmmzz", "11/10/2007, 10:10 AM PST - 11/20/2007, 10:10 AM PST", - "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "hms", "11/10/2007 10:10:10 AM - 11/20/2007 10:10:10 AM", - "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "Hms", "11/10/2007 10:10:10 - 11/20/2007 10:10:10", - "en", "2007 11 10 20:10:10", "2007 11 20 20:10:10", "Hms", "11/10/2007 20:10:10 - 11/20/2007 20:10:10", + "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "hms", "11/10/2007, 10:10:10 AM - 11/20/2007, 10:10:10 AM", + "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "Hms", "11/10/2007, 10:10:10 - 11/20/2007, 10:10:10", + "en", "2007 11 10 20:10:10", "2007 11 20 20:10:10", "Hms", "11/10/2007, 20:10:10 - 11/20/2007, 20:10:10", "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "dMMMMMy", "N 10 - 20, 2007", @@ -765,7 +821,7 @@ void DateIntervalFormatTest::testFormat() { "zh", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "MMMMy", "2007\\u5e7410\\u6708\\u81f311\\u6708", - "zh", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "hmv", "2007\\u5e7410\\u670810\\u65e5 \\u4e0a\\u534810:10 \\u7f8e\\u56fd\\u65F6\\u95F4\\uff08\\u6d1b\\u6749\\u77f6\\uff09\\u81f32007\\u5e7411\\u670810\\u65e5 \\u4e0a\\u534810:10 \\u7f8e\\u56fd\\u65F6\\u95F4\\uff08\\u6d1b\\u6749\\u77f6\\uff09", + "zh", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "hmv", "2007/10/10 \\u6D1B\\u6749\\u77F6\\u65F6\\u95F4\\u4E0A\\u534810:10 \\u2013 2007/11/10 \\u6D1B\\u6749\\u77F6\\u65F6\\u95F4\\u4E0A\\u534810:10", "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EEEEdMMMMy", "2007\\u5e7411\\u670810\\u65e5\\u661f\\u671f\\u516d\\u81f320\\u65e5\\u661f\\u671f\\u4e8c", @@ -777,87 +833,87 @@ void DateIntervalFormatTest::testFormat() { "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EEEEdMMMM", "11\\u670810\\u65e5\\u661f\\u671f\\u516d\\u81f320\\u65e5\\u661f\\u671f\\u4e8c", - "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EdMy", "07-11-10\\u5468\\u516d\\u81f307-11-20\\u5468\\u4e8c", + "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EdMy", "2007/11/10\\u5468\\u516d\\u81f32007/11/20\\u5468\\u4e8c", - "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "dM", "11-10\\u81f311-20", + "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "dM", "11/10 \\u2013 11/20", - "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "My", "2007-11", + "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "My", "2007/11", - "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EdM", "11-10\\u5468\\u516d\\u81f311-20\\u5468\\u4e8c", + "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EdM", "11/10\\u5468\\u516d\\u81f311/20\\u5468\\u4e8c", "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "y", "2007\\u5E74", // (fixed expected result per ticket:6626:) "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "M", "11\\u6708", - "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "MMM", "11\\u6708", + "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "MMM", "11\\u6708", // (fixed expected result per ticket:6626: and others) - "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "hmz", "2007\\u5e7411\\u670810\\u65e5 \\u4e0a\\u534810:10 GMT-0800\\u81f32007\\u5e7411\\u670820\\u65e5 \\u4e0a\\u534810:10 GMT-0800", + "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "hmz", "2007/11/10 GMT-8\\u4e0a\\u534810:10 \\u2013 2007/11/20 GMT-8\\u4e0a\\u534810:10", - "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "h", "2007\\u5e7411\\u670810\\u65e5 \\u4e0a\\u534810\\u65f6\\u81f32007\\u5e7411\\u670820\\u65e5 \\u4e0a\\u534810\\u65f6", + "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "h", "2007/11/10 \\u4e0a\\u534810\\u65f6 \\u2013 2007/11/20 \\u4e0a\\u534810\\u65f6", - "zh", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "EEEEdMMMMy", "2007\\u5e741\\u670810\\u65e5\\u661f\\u671f\\u4e09", // (fixed expected result per ticket:6626:) + "zh", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "EEEEdMMMMy", "2007\\u5e741\\u670810\\u65e5 \\u661f\\u671f\\u4e09", // (fixed expected result per ticket:6626:) "zh", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "hm", "\\u4e0a\\u534810:00\\u81f3\\u4e0b\\u53482:10", - "zh", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "hmz", "GMT-0800\\u4e0a\\u534810:00\\u81f3\\u4e0b\\u53482:10", + "zh", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "hmz", "GMT-8\\u4e0a\\u534810:00\\u81f3\\u4e0b\\u53482:10", - "zh", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "h", "\\u4e0a\\u534810\\u81f3\\u4e0b\\u53482\\u65f6", + "zh", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "h", "\\u4e0a\\u534810\\u65F6\\u81f3\\u4e0b\\u53482\\u65f6", - "zh", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "hv", "\\u7f8e\\u56fd\\u65F6\\u95F4\\uff08\\u6d1b\\u6749\\u77f6\\uff09\\u4e0a\\u534810\\u81f3\\u4e0b\\u53482\\u65f6", + "zh", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "hv", "\\u6D1B\\u6749\\u77F6\\u65F6\\u95F4\\u4E0A\\u534810\\u65F6\\u81F3\\u4E0B\\u53482\\u65F6", "zh", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "hm", "\\u4e0a\\u534810:00\\u81f310:20", - "zh", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "hmv", "\\u7f8e\\u56fd\\u65F6\\u95F4\\uff08\\u6d1b\\u6749\\u77f6\\uff09\\u4e0a\\u534810:00\\u81f310:20", + "zh", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "hmv", "\\u6D1B\\u6749\\u77F6\\u65F6\\u95F4\\u4E0A\\u534810:00\\u81F310:20", - "zh", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "hz", "\\u4e0a\\u534810\\u65f6 GMT-0800", + "zh", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "hz", "GMT-8\\u4e0a\\u534810\\u65f6", "zh", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "hm", "\\u4e0a\\u534810:10", "zh", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "h", "\\u4e0a\\u534810\\u65f6", - "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "EEEEdMMMy", "Mittwoch, 10. Okt 2007 - Freitag, 10. Okt 2008", + "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "EEEEdMMMy", "Mittwoch, 10. Okt. 2007 - Freitag, 10. Okt. 2008", - "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "dMMM", "10. Okt 2007 - 10. Okt 2008", + "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "dMMM", "10. Okt. 2007 - 10. Okt. 2008", - "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "MMMy", "Okt 2007 - Okt 2008", + "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "MMMy", "Okt. 2007 - Okt. 2008", - "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "EdMy", "Mi., 10.10.07 - Fr., 10.10.08", + "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "EdMy", "Mi., 10.10.2007 - Fr., 10.10.2008", - "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "dMy", "10.10.07 - 10.10.08", + "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "dMy", "10.10.2007 - 10.10.2008", - "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "My", "10.07 - 10.08", + "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "My", "10.2007 - 10.2008", - "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "EdM", "Mi., 10.10.07 - Fr., 10.10.08", + "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "EdM", "Mi., 10.10.2007 - Fr., 10.10.2008", "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "y", "2007-2008", - "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "M", "10.07 - 10.08", + "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "M", "10.2007 - 10.2008", "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "hm", "10.10.2007 10:10 vorm. - 10.10.2008 10:10 vorm.", "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "Hm", "10.10.2007 10:10 - 10.10.2008 10:10", - "de", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "EEEEdMMMy", "Mittwoch, 10. Okt - Samstag, 10. Nov 2007", + "de", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "EEEEdMMMy", "Mittwoch, 10. Okt. - Samstag, 10. Nov. 2007", - "de", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "dMMM", "10. Okt - 10. Nov", + "de", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "dMMM", "10. Okt. - 10. Nov.", - "de", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "MMMy", "Okt-Nov 2007", + "de", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "MMMy", "Okt.-Nov. 2007", - "de", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "EEEEdMMM", "Mittwoch, 10. Okt - Samstag, 10. Nov", + "de", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "EEEEdMMM", "Mittwoch, 10. Okt. - Samstag, 10. Nov.", "de", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "dM", "10.10. - 10.11.", - "de", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "My", "10.07 - 11.07", + "de", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "My", "10.2007 - 11.2007", "de", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "d", "10.10. - 10.11.", @@ -865,22 +921,22 @@ void DateIntervalFormatTest::testFormat() { "de", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "y", "2007", - "de", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "MMM", "Okt-Nov", + "de", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "MMM", "Okt.-Nov.", "de", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "hms", "10.10.2007 10:10:10 vorm. - 10.11.2007 10:10:10 vorm.", "de", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "Hms", "10.10.2007 10:10:10 - 10.11.2007 10:10:10", - "de", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EEEEdMMMy", "Samstag, 10. - Dienstag, 20. Nov 2007", + "de", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EEEEdMMMy", "Samstag, 10. - Dienstag, 20. Nov. 2007", - "de", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "dMMMy", "10.-20. Nov 2007", + "de", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "dMMMy", "10.-20. Nov. 2007", - "de", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "MMMy", "Nov 2007", + "de", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "MMMy", "Nov. 2007", - "de", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EEEEdMMM", "Samstag, 10. - Dienstag, 20. Nov", + "de", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EEEEdMMM", "Samstag, 10. - Dienstag, 20. Nov.", - "de", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EdMy", "Sa., 10.11.07 - Di., 20.11.07", + "de", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EdMy", "Sa., 10.11.2007 - Di., 20.11.2007", "de", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "dM", "10.11. - 20.11.", @@ -893,45 +949,45 @@ void DateIntervalFormatTest::testFormat() { "de", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "y", "2007", - "de", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "hmv", "10.11.2007 10:10 vorm. Vereinigte Staaten Zeit (Los Angeles) - 20.11.2007 10:10 vorm. Vereinigte Staaten Zeit (Los Angeles)", + "de", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "hmv", "10.11.2007 10:10 vorm. Los Angeles Zeit - 20.11.2007 10:10 vorm. Los Angeles Zeit", - "de", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "EEEEdMMMy", "Mittwoch, 10. Jan 2007", + "de", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "EEEEdMMMy", "Mittwoch, 10. Jan. 2007", - "de", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "dMMM", "10. Jan", + "de", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "dMMM", "10. Jan.", - "de", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "MMMy", "Jan 2007", + "de", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "MMMy", "Jan. 2007", - "de", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "EEEEdMMM", "Mittwoch, 10. Jan", + "de", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "EEEEdMMM", "Mittwoch, 10. Jan.", "de", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "h", "10 vorm. - 2 nachm.", "de", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "H", "10-14 Uhr", - "de", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "EEEEdMMM", "Mittwoch, 10. Jan", + "de", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "EEEEdMMM", "Mittwoch, 10. Jan.", - "de", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "hmv", "10:00-10:20 vorm. Vereinigte Staaten Zeit (Los Angeles)", + "de", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "hmv", "10:00-10:20 vorm. Los Angeles Zeit", - "de", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "hmz", "10:00-10:20 vorm. GMT-08:00", + "de", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "hmz", "10:00-10:20 vorm. GMT-8", "de", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "h", "10 vorm.", "de", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "H", "10 Uhr", - "de", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "hz", "10 vorm. GMT-08:00", + "de", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "hz", "10 vorm. GMT-8", - "de", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "EEEEdMMMy", "Mittwoch, 10. Jan 2007", + "de", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "EEEEdMMMy", "Mittwoch, 10. Jan. 2007", - "de", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "hmv", "10:10 vorm. Vereinigte Staaten Zeit (Los Angeles)", + "de", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "hmv", "10:10 vorm. Los Angeles Zeit", - "de", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "hmz", "10:10 vorm. GMT-08:00", + "de", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "hmz", "10:10 vorm. GMT-8", - "de", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "hv", "10 vorm. Vereinigte Staaten Zeit (Los Angeles)", + "de", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "hv", "10 vorm. Los Angeles Zeit", - "de", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "hz", "10 vorm. GMT-08:00", + "de", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "hz", "10 vorm. GMT-8", // Thai (default calendar buddhist) @@ -943,19 +999,19 @@ void DateIntervalFormatTest::testFormat() { "th", "2550 10 10 10:10:10", "2551 10 10 10:10:10", "MMMy", "\\u0E15.\\u0E04. 2550 - \\u0E15.\\u0E04. 2551", - "th", "2550 10 10 10:10:10", "2551 10 10 10:10:10", "EdMy", "\\u0E1E. 10/10/50 - \\u0E28. 10/10/51", + "th", "2550 10 10 10:10:10", "2551 10 10 10:10:10", "EdMy", "\\u0E1E. 10/10/2550 - \\u0E28. 10/10/2551", - "th", "2550 10 10 10:10:10", "2551 10 10 10:10:10", "dMy", "10/10/50 - 10/10/51", + "th", "2550 10 10 10:10:10", "2551 10 10 10:10:10", "dMy", "10/10/2550 - 10/10/2551", - "th", "2550 10 10 10:10:10", "2551 10 10 10:10:10", "My", "10/50 - 10/51", + "th", "2550 10 10 10:10:10", "2551 10 10 10:10:10", "My", "10/2550 - 10/2551", - "th", "2550 10 10 10:10:10", "2551 10 10 10:10:10", "EdM", "\\u0E1E. 10/10/50 - \\u0E28. 10/10/51", + "th", "2550 10 10 10:10:10", "2551 10 10 10:10:10", "EdM", "\\u0E1E. 10/10/2550 - \\u0E28. 10/10/2551", "th", "2550 10 10 10:10:10", "2551 10 10 10:10:10", "y", "2550-2551", - "th", "2550 10 10 10:10:10", "2551 10 10 10:10:10", "M", "10/50 - 10/51", + "th", "2550 10 10 10:10:10", "2551 10 10 10:10:10", "M", "10/2550 - 10/2551", "th", "2550 10 10 10:10:10", "2550 11 10 10:10:10", "EEEEdMMMy", "\\u0E27\\u0E31\\u0E19\\u0E1E\\u0E38\\u0E18 10 \\u0E15.\\u0E04. - \\u0E27\\u0E31\\u0E19\\u0E40\\u0E2A\\u0E32\\u0E23\\u0E4C 10 \\u0E1E.\\u0E22. 2550", @@ -967,7 +1023,7 @@ void DateIntervalFormatTest::testFormat() { "th", "2550 10 10 10:10:10", "2550 11 10 10:10:10", "dM", "10/10 - 10/11", - "th", "2550 10 10 10:10:10", "2550 11 10 10:10:10", "My", "10/50 - 11/50", + "th", "2550 10 10 10:10:10", "2550 11 10 10:10:10", "My", "10/2550 - 11/2550", "th", "2550 10 10 10:10:10", "2550 11 10 10:10:10", "d", "10/10 - 10/11", @@ -1076,14 +1132,14 @@ void DateIntervalFormatTest::testFormatUserDII() { "zh", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "2007\\u5e741\\u670810\\u65e5", // (fixed expected result per ticket:6626:) - "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "10. Okt 2007 --- 10. Okt 2008", + "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "10. Okt. 2007 --- 10. Okt. 2008", - "de", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "10. Nov 2007 --- 20. Nov 2007", + "de", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "10. Nov. 2007 --- 20. Nov. 2007", - "de", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "10. Jan 2007", + "de", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "10. Jan. 2007", - "de", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "10. Jan 2007", + "de", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "10. Jan. 2007", "es", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "10 oct 2007 --- 10 oct 2008", @@ -1102,6 +1158,106 @@ void DateIntervalFormatTest::testFormatUserDII() { } +void DateIntervalFormatTest::testSetIntervalPatternNoSideEffect() { + UErrorCode ec = U_ZERO_ERROR; + LocalPointer dtitvinf(new DateIntervalInfo(ec)); + if (U_FAILURE(ec)) { + errln("Failure encountered: %s", u_errorName(ec)); + return; + } + UnicodeString expected; + dtitvinf->getIntervalPattern(ctou("yMd"), UCAL_DATE, expected, ec); + dtitvinf->setIntervalPattern(ctou("yMd"), UCAL_DATE, ctou("M/d/y \\u2013 d"), ec); + if (U_FAILURE(ec)) { + errln("Failure encountered: %s", u_errorName(ec)); + return; + } + dtitvinf.adoptInstead(new DateIntervalInfo(ec)); + if (U_FAILURE(ec)) { + errln("Failure encountered: %s", u_errorName(ec)); + return; + } + UnicodeString actual; + dtitvinf->getIntervalPattern(ctou("yMd"), UCAL_DATE, actual, ec); + if (U_FAILURE(ec)) { + errln("Failure encountered: %s", u_errorName(ec)); + return; + } + if (expected != actual) { + errln("DateIntervalInfo.setIntervalPattern should have no side effects."); + } +} + +void DateIntervalFormatTest::testYearFormats() { + const Locale &enLocale = Locale::getEnglish(); + UErrorCode status = U_ZERO_ERROR; + LocalPointer fromTime(Calendar::createInstance(enLocale, status)); + LocalPointer toTime(Calendar::createInstance(enLocale, status)); + if (U_FAILURE(status)) { + errln("Failure encountered: %s", u_errorName(status)); + return; + } + // April 26, 113. Three digit year so that we can test 2 digit years; + // 4 digit years with padded 0's and full years. + fromTime->set(113, 3, 26); + // April 28, 113. + toTime->set(113, 3, 28); + { + LocalPointer dif(DateIntervalFormat::createInstance("yyyyMd", enLocale, status)); + if (U_FAILURE(status)) { + dataerrln("Failure encountered: %s", u_errorName(status)); + return; + } + UnicodeString actual; + UnicodeString expected(ctou("4/26/0113 - 4/28/0113")); + FieldPosition pos = 0; + dif->format(*fromTime, *toTime, actual, pos, status); + if (U_FAILURE(status)) { + errln("Failure encountered: %s", u_errorName(status)); + return; + } + if (actual != expected) { + errln("Expected " + expected + ", got: " + actual); + } + } + { + LocalPointer dif(DateIntervalFormat::createInstance("yyMd", enLocale, status)); + if (U_FAILURE(status)) { + errln("Failure encountered: %s", u_errorName(status)); + return; + } + UnicodeString actual; + UnicodeString expected(ctou("4/26/13 - 4/28/13")); + FieldPosition pos = 0; + dif->format(*fromTime, *toTime, actual, pos, status); + if (U_FAILURE(status)) { + errln("Failure encountered: %s", u_errorName(status)); + return; + } + if (actual != expected) { + errln("Expected " + expected + ", got: " + actual); + } + } + { + LocalPointer dif(DateIntervalFormat::createInstance("yMd", enLocale, status)); + if (U_FAILURE(status)) { + errln("Failure encountered: %s", u_errorName(status)); + return; + } + UnicodeString actual; + UnicodeString expected(ctou("4/26/113 - 4/28/113")); + FieldPosition pos = 0; + dif->format(*fromTime, *toTime, actual, pos, status); + if (U_FAILURE(status)) { + errln("Failure encountered: %s", u_errorName(status)); + return; + } + if (actual != expected) { + errln("Expected " + expected + ", got: " + actual); + } + } +} + void DateIntervalFormatTest::expectUserDII(const char** data, int32_t data_length) { int32_t i = 0;