CASE(25,Test1684)
CASE(26,Test5554)
CASE(27,Test9237)
+ CASE(28,TestParsing)
default: name = ""; break;
}
}
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",
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");
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);
}
}
}
+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