X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/4388f060552cc537e71e957d32f35e9d75a61233..e4f10fab0c078f399c9deef476d9c9b73b47dff8:/icuSources/test/intltest/dtfmrgts.cpp diff --git a/icuSources/test/intltest/dtfmrgts.cpp b/icuSources/test/intltest/dtfmrgts.cpp index 1f12b65e..220c2739 100644 --- a/icuSources/test/intltest/dtfmrgts.cpp +++ b/icuSources/test/intltest/dtfmrgts.cpp @@ -56,6 +56,7 @@ DateFormatRegressionTest::runIndexedTest( int32_t index, UBool exec, const char* CASE(25,Test1684) CASE(26,Test5554) CASE(27,Test9237) + CASE(28,TestParsing) default: name = ""; break; } } @@ -133,8 +134,8 @@ void DateFormatRegressionTest::Test4052408(void) str = fmt->format(dt, str); logln(str); - if(str != "5/3/97 8:55 AM") - errln("Fail: Test broken; Want 5/3/97 8:55 AM Got " + str); + if(str != "5/3/97, 8:55 AM") + errln("Fail: Test broken; Want 5/3/97, 8:55 AM Got " + str); UnicodeString expected[] = { (UnicodeString) "", //"ERA_FIELD", @@ -719,8 +720,8 @@ void DateFormatRegressionTest::Test4101483(void) sdf->format(d, buf, fp); //logln(sdf.format(d, buf, fp).toString()); logln(dateToString(d) + " => " + buf); - logln("beginIndex = " + fp.getBeginIndex()); - logln("endIndex = " + fp.getEndIndex()); + logln(UnicodeString("beginIndex = ") + fp.getBeginIndex()); + logln(UnicodeString("endIndex = ") + fp.getEndIndex()); if (fp.getBeginIndex() == fp.getEndIndex()) errln("Fail: Empty field"); @@ -842,7 +843,7 @@ void DateFormatRegressionTest::Test4104136(void) logln(" index: %d", pos.getIndex()); logln((UnicodeString) " result: " + d); if(pos.getIndex() != finish.getIndex()) - errln("Fail: Expected pos " + finish.getIndex()); + errln(UnicodeString("Fail: Expected pos ") + finish.getIndex()); if (! ((d == 0 && exp == -1) || (d == exp))) errln((UnicodeString) "Fail: Expected result " + exp); } @@ -1496,6 +1497,34 @@ void DateFormatRegressionTest::Test9237(void) } } +void DateFormatRegressionTest::TestParsing(void) { + UErrorCode status = U_ZERO_ERROR; + UnicodeString pattern("EEE-WW-MMMM-yyyy"); + UnicodeString text("mon-02-march-2011"); + int32_t expectedDay = 7; + + SimpleDateFormat format(pattern, status); + if (U_FAILURE(status)) { + dataerrln("Unable to create SimpleDateFormat - %s", u_errorName(status)); + return; + } + + Calendar *cal = new GregorianCalendar(status); + if (cal == NULL || U_FAILURE(status)) { + errln("Unable to create calendar - %s", u_errorName(status)); + return; + } + + ParsePosition pos(0); + format.parse(text, *cal, pos); + + if (cal->get(UCAL_DAY_OF_MONTH, status) != expectedDay) { + errln("Parsing failed: day of month should be '7' with pattern: \"" + pattern + "\" for text: \"" + text + "\""); + } + + delete cal; +} + #endif /* #if !UCONFIG_NO_FORMATTING */ //eof