+// test item for a particular locale + calendar and date format
+typedef struct {
+ int32_t era;
+ int32_t year;
+ int32_t month;
+ int32_t day;
+ int32_t hour;
+ int32_t minute;
+ UnicodeString formattedDate;
+} CalAndFmtTestItem;
+
+// test item giving locale + calendar, date format, and CalAndFmtTestItems
+typedef struct {
+ const char * locale; // with calendar
+ DateFormat::EStyle style;
+ UnicodeString pattern; // ignored unless style == DateFormat::kNone
+ const CalAndFmtTestItem *caftItems;
+} TestNonGregoItem;
+
+void DateFormatTest::TestNonGregoFmtParse()
+{
+ // test items for he@calendar=hebrew, long date format
+ const CalAndFmtTestItem cafti_he_hebrew_long[] = {
+ { 0, 4999, 12, 29, 12, 0, CharsToUnicodeString("\\u05DB\\u05F4\\u05D8 \\u05D1\\u05D0\\u05DC\\u05D5\\u05DC \\u05D3\\u05F3\\u05EA\\u05EA\\u05E7\\u05E6\\u05F4\\u05D8") },
+ { 0, 5100, 0, 1, 12, 0, CharsToUnicodeString("\\u05D0\\u05F3 \\u05D1\\u05EA\\u05E9\\u05E8\\u05D9 \\u05E7\\u05F3") },
+ { 0, 5774, 5, 1, 12, 0, CharsToUnicodeString("\\u05D0\\u05F3 \\u05D1\\u05D0\\u05D3\\u05E8 \\u05D0\\u05F3 \\u05EA\\u05E9\\u05E2\\u05F4\\u05D3") },
+ { 0, 5999, 12, 29, 12, 0, CharsToUnicodeString("\\u05DB\\u05F4\\u05D8 \\u05D1\\u05D0\\u05DC\\u05D5\\u05DC \\u05EA\\u05EA\\u05E7\\u05E6\\u05F4\\u05D8") },
+ { 0, 6100, 0, 1, 12, 0, CharsToUnicodeString("\\u05D0\\u05F3 \\u05D1\\u05EA\\u05E9\\u05E8\\u05D9 \\u05D5\\u05F3\\u05E7\\u05F3") },
+ { 0, 0, 0, 0, 0, 0, UnicodeString("") } // terminator
+ };
+ const CalAndFmtTestItem cafti_zh_chinese_custU[] = {
+ { 78, 31, 0, 1, 12, 0, CharsToUnicodeString("2014\\u7532\\u5348\\u5E74\\u6B63\\u67081") },
+ { 77, 31, 0, 1, 12, 0, CharsToUnicodeString("1954\\u7532\\u5348\\u5E74\\u6B63\\u67081") },
+ { 0, 0, 0, 0, 0, 0, UnicodeString("") } // terminator
+ };
+ const CalAndFmtTestItem cafti_zh_chinese_custNoU[] = {
+ { 78, 31, 0, 1, 12, 0, CharsToUnicodeString("2014\\u5E74\\u6B63\\u67081") },
+ { 77, 31, 0, 1, 12, 0, CharsToUnicodeString("1954\\u5E74\\u6B63\\u67081") },
+ { 0, 0, 0, 0, 0, 0, UnicodeString("") } // terminator
+ };
+ const CalAndFmtTestItem cafti_ja_japanese_custGy[] = {
+ {235, 26, 2, 5, 12, 0, CharsToUnicodeString("2014(\\u5E73\\u621026)\\u5E743\\u67085\\u65E5") },
+ {234, 60, 2, 5, 12, 0, CharsToUnicodeString("1985(\\u662D\\u548C60)\\u5E743\\u67085\\u65E5") },
+ { 0, 0, 0, 0, 0, 0, UnicodeString("") } // terminator
+ };
+ const CalAndFmtTestItem cafti_ja_japanese_custNoGy[] = {
+ {235, 26, 2, 5, 12, 0, CharsToUnicodeString("2014\\u5E743\\u67085\\u65E5") },
+ {234, 60, 2, 5, 12, 0, CharsToUnicodeString("1985\\u5E743\\u67085\\u65E5") },
+ { 0, 0, 0, 0, 0, 0, UnicodeString("") } // terminator
+ };
+ const CalAndFmtTestItem cafti_en_islamic_cust[] = {
+ { 0, 1384, 0, 1, 12, 0, UnicodeString("1 Muh. 1384 AH, 1964") },
+ { 0, 1436, 0, 1, 12, 0, UnicodeString("1 Muh. 1436 AH, 2014") },
+ { 0, 1487, 0, 1, 12, 0, UnicodeString("1 Muh. 1487 AH, 2064") },
+ { 0, 0, 0, 0, 0, 0, UnicodeString("") } // terminator
+ };
+ // overal test items
+ const TestNonGregoItem items[] = {
+ { "he@calendar=hebrew", DateFormat::kLong, UnicodeString(""), cafti_he_hebrew_long },
+ { "zh@calendar=chinese", DateFormat::kNone, CharsToUnicodeString("rU\\u5E74MMMd"), cafti_zh_chinese_custU },
+ { "zh@calendar=chinese", DateFormat::kNone, CharsToUnicodeString("r\\u5E74MMMd"), cafti_zh_chinese_custNoU },
+ { "ja@calendar=japanese", DateFormat::kNone, CharsToUnicodeString("r(Gy)\\u5E74M\\u6708d\\u65E5"), cafti_ja_japanese_custGy },
+ { "ja@calendar=japanese", DateFormat::kNone, CharsToUnicodeString("r\\u5E74M\\u6708d\\u65E5"), cafti_ja_japanese_custNoGy },
+ { "en@calendar=islamic", DateFormat::kNone, UnicodeString("d MMM y G, r"), cafti_en_islamic_cust },
+ { NULL, DateFormat::kNone, UnicodeString(""), NULL } // terminator
+ };
+ const TestNonGregoItem * itemPtr;
+ for (itemPtr = items; itemPtr->locale != NULL; itemPtr++) {
+ Locale locale = Locale::createFromName(itemPtr->locale);
+ DateFormat * dfmt = NULL;
+ UErrorCode status = U_ZERO_ERROR;
+ if (itemPtr->style != DateFormat::kNone) {
+ dfmt = DateFormat::createDateInstance(itemPtr->style, locale);
+ } else {
+ dfmt = new SimpleDateFormat(itemPtr->pattern, locale, status);
+ }
+ if (U_FAILURE(status)) {
+ dataerrln("new SimpleDateFormat fails for locale %s", itemPtr->locale);
+ } else if (dfmt == NULL) {
+ dataerrln("DateFormat::createDateInstance fails for locale %s", itemPtr->locale);
+ } else {
+ Calendar * cal = (dfmt->getCalendar())->clone();
+ if (cal == NULL) {
+ dataerrln("(DateFormat::getCalendar)->clone() fails for locale %s", itemPtr->locale);
+ } else {
+ const CalAndFmtTestItem * caftItemPtr;
+ for (caftItemPtr = itemPtr->caftItems; caftItemPtr->year != 0; caftItemPtr++) {
+ cal->clear();
+ cal->set(UCAL_ERA, caftItemPtr->era);
+ cal->set(UCAL_YEAR, caftItemPtr->year);
+ cal->set(UCAL_MONTH, caftItemPtr->month);
+ cal->set(UCAL_DATE, caftItemPtr->day);
+ cal->set(UCAL_HOUR_OF_DAY, caftItemPtr->hour);
+ cal->set(UCAL_MINUTE, caftItemPtr->minute);
+ UnicodeString result;
+ FieldPosition fpos(0);
+ dfmt->format(*cal, result, fpos);
+ if ( result.compare(caftItemPtr->formattedDate) != 0 ) {
+ errln( UnicodeString("FAIL: date format for locale ") + UnicodeString(itemPtr->locale) + ", style " + itemPtr->style +
+ ", expected \"" + caftItemPtr->formattedDate + "\", got \"" + result + "\"");
+ } else {
+ // formatted OK, try parse
+ ParsePosition ppos(0);
+ dfmt->parse(result, *cal, ppos);
+ status = U_ZERO_ERROR;
+ int32_t era = cal->get(UCAL_ERA, status);
+ int32_t year = cal->get(UCAL_YEAR, status);
+ int32_t month = cal->get(UCAL_MONTH, status);
+ int32_t day = cal->get(UCAL_DATE, status);
+ if ( U_FAILURE(status) || ppos.getIndex() < result.length() || era != caftItemPtr->era ||
+ year != caftItemPtr->year || month != caftItemPtr->month || day != caftItemPtr->day ) {
+ errln( UnicodeString("FAIL: date parse for locale ") + UnicodeString(itemPtr->locale) +
+ ", style " + itemPtr->style + ", string \"" + result + "\", expected " +
+ caftItemPtr->era +":"+caftItemPtr->year +"-"+caftItemPtr->month+"-"+caftItemPtr->day + ", got pos " +
+ ppos.getIndex() + " " + year +"-"+month+"-"+day + " status " + UnicodeString(u_errorName(status)) );
+ }
+ }
+ }
+ delete cal;
+ }
+ delete dfmt;
+ }
+ }
+}
+
+static const UDate TEST_DATE = 1326585600000.; // 2012-jan-15
+
+void DateFormatTest::TestDotAndAtLeniency() {
+ // Test for date/time parsing regression with CLDR 22.1/ICU 50 pattern strings.
+ // For details see http://bugs.icu-project.org/trac/ticket/9789
+ static const char *locales[] = { "en", "fr" };
+ for (int32_t i = 0; i < LENGTHOF(locales); ++i) {
+ Locale locale(locales[i]);
+
+ for (DateFormat::EStyle dateStyle = DateFormat::FULL; dateStyle <= DateFormat::SHORT;
+ dateStyle = static_cast<DateFormat::EStyle>(dateStyle + 1)) {
+ LocalPointer<DateFormat> dateFormat(DateFormat::createDateInstance(dateStyle, locale));
+
+ for (DateFormat::EStyle timeStyle = DateFormat::FULL; timeStyle <= DateFormat::SHORT;
+ timeStyle = static_cast<DateFormat::EStyle>(timeStyle + 1)) {
+ LocalPointer<DateFormat> format(DateFormat::createDateTimeInstance(dateStyle, timeStyle, locale));
+ LocalPointer<DateFormat> timeFormat(DateFormat::createTimeInstance(timeStyle, locale));
+ UnicodeString formattedString;
+ if (format.isNull()) {
+ dataerrln("Unable to create DateFormat");
+ continue;
+ }
+ format->format(TEST_DATE, formattedString);
+
+ if (!showParse(*format, formattedString)) {
+ errln(UnicodeString(" with date-time: dateStyle=") + dateStyle + " timeStyle=" + timeStyle);
+ }
+
+ UnicodeString ds, ts;
+ formattedString = dateFormat->format(TEST_DATE, ds) + " " + timeFormat->format(TEST_DATE, ts);
+ if (!showParse(*format, formattedString)) {
+ errln(UnicodeString(" with date sp sp time: dateStyle=") + dateStyle + " timeStyle=" + timeStyle);
+ }
+ if (formattedString.indexOf("n ") >= 0) { // will add "." after the end of text ending in 'n', like Jan.
+ UnicodeString plusDot(formattedString);
+ plusDot.findAndReplace("n ", "n. ").append(".");
+ if (!showParse(*format, plusDot)) {
+ errln(UnicodeString(" with date plus-dot time: dateStyle=") + dateStyle + " timeStyle=" + timeStyle);
+ }
+ }
+ if (formattedString.indexOf(". ") >= 0) { // will subtract "." at the end of strings.
+ UnicodeString minusDot(formattedString);
+ minusDot.findAndReplace(". ", " ");
+ if (!showParse(*format, minusDot)) {
+ errln(UnicodeString(" with date minus-dot time: dateStyle=") + dateStyle + " timeStyle=" + timeStyle);
+ }
+ }
+ }
+ }
+ }
+}
+
+UBool DateFormatTest::showParse(DateFormat &format, const UnicodeString &formattedString) {
+ ParsePosition parsePosition;
+ UDate parsed = format.parse(formattedString, parsePosition);
+ UBool ok = TEST_DATE == parsed && parsePosition.getIndex() == formattedString.length();
+ UnicodeString pattern;
+ static_cast<SimpleDateFormat &>(format).toPattern(pattern);
+ if (ok) {
+ logln(pattern + " parsed: " + formattedString);
+ } else {
+ errln(pattern + " fails to parse: " + formattedString);
+ }
+ return ok;
+}
+
+
+typedef struct {
+ const char * locale;
+ UBool leniency;
+ UnicodeString parseString;
+ UnicodeString pattern;
+ UnicodeString expectedResult; // empty string indicates expected error
+} TestDateFormatLeniencyItem;
+
+void DateFormatTest::TestDateFormatLeniency() {
+ // For details see http://bugs.icu-project.org/trac/ticket/10261
+
+ const UDate july022008 = 1215000001979.0;
+ const TestDateFormatLeniencyItem items[] = {
+ //locale leniency parse String pattern expected result
+ { "en", true, UnicodeString("2008-07 02"), UnicodeString("yyyy-LLLL dd"), UnicodeString("2008-July 02") },
+ { "en", false, UnicodeString("2008-07 02"), UnicodeString("yyyy-LLLL dd"), UnicodeString("") },
+ { "en", true, UnicodeString("2008-Jan 02"), UnicodeString("yyyy-LLL. dd"), UnicodeString("2008-Jan. 02") },
+ { "en", false, UnicodeString("2008-Jan 02"), UnicodeString("yyyy-LLL. dd"), UnicodeString("") },
+ { "en", true, UnicodeString("2008-Jan--02"), UnicodeString("yyyy-MMM' -- 'dd"), UnicodeString("2008-Jan -- 02") },
+ { "en", false, UnicodeString("2008-Jan--02"), UnicodeString("yyyy-MMM' -- 'dd"), UnicodeString("") },
+ // terminator
+ { NULL, true, UnicodeString(""), UnicodeString(""), UnicodeString("") }
+ };
+ UErrorCode status = U_ZERO_ERROR;
+ LocalPointer<Calendar> cal(Calendar::createInstance(status));
+ if (U_FAILURE(status)) {
+ dataerrln(UnicodeString("FAIL: Unable to create Calendar for default timezone and locale."));
+ return;
+ }
+ cal->setTime(july022008, status);
+ const TestDateFormatLeniencyItem * itemPtr;
+ LocalPointer<SimpleDateFormat> sdmft;
+ for (itemPtr = items; itemPtr->locale != NULL; itemPtr++ ) {
+
+ Locale locale = Locale::createFromName(itemPtr->locale);
+ status = U_ZERO_ERROR;
+ ParsePosition pos(0);
+ sdmft.adoptInstead(new SimpleDateFormat(itemPtr->pattern, locale, status));
+ if (U_FAILURE(status)) {
+ dataerrln("Unable to create SimpleDateFormat - %s", u_errorName(status));
+ continue;
+ }
+ sdmft->setBooleanAttribute(UDAT_PARSE_ALLOW_WHITESPACE, itemPtr->leniency, status).
+ setBooleanAttribute(UDAT_PARSE_ALLOW_NUMERIC, itemPtr->leniency, status).
+ setBooleanAttribute(UDAT_PARSE_PARTIAL_MATCH, itemPtr->leniency, status);
+ UDate d = sdmft->parse(itemPtr->parseString, pos);
+
+ if(itemPtr->expectedResult.length() == 0) {
+ if(pos.getErrorIndex() != -1) {
+ continue;
+ } else {
+ errln("error: unexpected parse success - " + itemPtr->parseString +
+ " - pattern " + itemPtr->pattern +
+ " - error index " + pos.getErrorIndex() +
+ " - leniency " + itemPtr->leniency);
+ continue;
+ }
+ }
+ if(pos.getErrorIndex() != -1) {
+ errln("error: parse error for string - " + itemPtr->parseString +
+ " - pattern " + itemPtr->pattern +
+ " - idx " + pos.getIndex() +
+ " - error index "+pos.getErrorIndex() +
+ " - leniency " + itemPtr->leniency);
+ continue;
+ }
+
+ UnicodeString formatResult("");
+ sdmft->format(d, formatResult);
+ if(formatResult.compare(itemPtr->expectedResult) != 0) {
+ errln("error: unexpected format result. pattern["+itemPtr->pattern+"] expected[" + itemPtr->expectedResult + "] but result was[" + formatResult + "]");
+ continue;
+ } else {
+ logln("formatted results match! - " + formatResult);
+ }
+
+ }
+}
+
+
+typedef struct {
+ UBool leniency;
+ UnicodeString parseString;
+ UnicodeString pattern;
+ UnicodeString expectedResult; // empty string indicates expected error
+} TestMultiPatternMatchItem;
+
+void DateFormatTest::TestParseMultiPatternMatch() {
+ // For details see http://bugs.icu-project.org/trac/ticket/10336
+ const TestMultiPatternMatchItem items[] = {
+ // leniency parse String pattern expected result
+ {true, UnicodeString("2013-Sep 13"), UnicodeString("yyyy-MMM dd"), UnicodeString("2013-Sep 13")},
+ {true, UnicodeString("2013-September 14"), UnicodeString("yyyy-MMM dd"), UnicodeString("2013-Sep 14")},
+ {false, UnicodeString("2013-September 15"), UnicodeString("yyyy-MMM dd"), UnicodeString("")},
+ {false, UnicodeString("2013-September 16"), UnicodeString("yyyy-MMMM dd"), UnicodeString("2013-September 16")},
+ {true, UnicodeString("2013-Sep 17"), UnicodeString("yyyy-LLL dd"), UnicodeString("2013-Sep 17")},
+ {true, UnicodeString("2013-September 18"), UnicodeString("yyyy-LLL dd"), UnicodeString("2013-Sep 18")},
+ {false, UnicodeString("2013-September 19"), UnicodeString("yyyy-LLL dd"), UnicodeString("")},
+ {false, UnicodeString("2013-September 20"), UnicodeString("yyyy-LLLL dd"), UnicodeString("2013-September 20")},
+ {true, UnicodeString("2013 Sat Sep 21"), UnicodeString("yyyy EEE MMM dd"), UnicodeString("2013 Sat Sep 21")},
+ {true, UnicodeString("2013 Sunday Sep 22"), UnicodeString("yyyy EEE MMM dd"), UnicodeString("2013 Sun Sep 22")},
+ {false, UnicodeString("2013 Monday Sep 23"), UnicodeString("yyyy EEE MMM dd"), UnicodeString("")},
+ {false, UnicodeString("2013 Tuesday Sep 24"), UnicodeString("yyyy EEEE MMM dd"), UnicodeString("2013 Tuesday Sep 24")},
+ {true, UnicodeString("2013 Wed Sep 25"), UnicodeString("yyyy eee MMM dd"), UnicodeString("2013 Wed Sep 25")},
+ {true, UnicodeString("2013 Thu Sep 26"), UnicodeString("yyyy eee MMM dd"), UnicodeString("2013 Thu Sep 26")},
+ {false, UnicodeString("2013 Friday Sep 27"), UnicodeString("yyyy eee MMM dd"), UnicodeString("")},
+ {false, UnicodeString("2013 Saturday Sep 28"), UnicodeString("yyyy eeee MMM dd"), UnicodeString("2013 Saturday Sep 28")},
+ {true, UnicodeString("2013 Sun Sep 29"), UnicodeString("yyyy ccc MMM dd"), UnicodeString("2013 Sun Sep 29")},
+ {true, UnicodeString("2013 Monday Sep 30"), UnicodeString("yyyy ccc MMM dd"), UnicodeString("2013 Mon Sep 30")},
+ {false, UnicodeString("2013 Sunday Oct 13"), UnicodeString("yyyy ccc MMM dd"), UnicodeString("")},
+ {false, UnicodeString("2013 Monday Oct 14"), UnicodeString("yyyy cccc MMM dd"), UnicodeString("2013 Monday Oct 14")},
+ {true, UnicodeString("2013 Oct 15 Q4"), UnicodeString("yyyy MMM dd QQQ"), UnicodeString("2013 Oct 15 Q4")},
+ {true, UnicodeString("2013 Oct 16 4th quarter"), UnicodeString("yyyy MMM dd QQQ"), UnicodeString("2013 Oct 16 Q4")},
+ {false, UnicodeString("2013 Oct 17 4th quarter"), UnicodeString("yyyy MMM dd QQQ"), UnicodeString("")},
+ {false, UnicodeString("2013 Oct 18 Q4"), UnicodeString("yyyy MMM dd QQQ"), UnicodeString("2013 Oct 18 Q4")},
+ {true, UnicodeString("2013 Oct 19 Q4"), UnicodeString("yyyy MMM dd qqqq"), UnicodeString("2013 Oct 19 4th quarter")},
+ {true, UnicodeString("2013 Oct 20 4th quarter"), UnicodeString("yyyy MMM dd qqqq"), UnicodeString("2013 Oct 20 4th quarter")},
+ {false, UnicodeString("2013 Oct 21 Q4"), UnicodeString("yyyy MMM dd qqqq"), UnicodeString("")},
+ {false, UnicodeString("2013 Oct 22 4th quarter"), UnicodeString("yyyy MMM dd qqqq"), UnicodeString("2013 Oct 22 4th quarter")},
+ {false, UnicodeString("--end--"), UnicodeString(""), UnicodeString("")},
+ };
+
+ UErrorCode status = U_ZERO_ERROR;
+ LocalPointer<Calendar> cal(Calendar::createInstance(status));
+ if (U_FAILURE(status)) {
+ dataerrln(UnicodeString("FAIL: Unable to create Calendar for default timezone and locale."));
+ return;
+ }
+ const TestMultiPatternMatchItem * itemPtr;
+ DateFormat* sdmft = DateFormat::createDateInstance();
+ if (sdmft == NULL) {
+ dataerrln(UnicodeString("FAIL: Unable to create DateFormat"));
+ return;
+ }
+ for (itemPtr = items; itemPtr->parseString != "--end--"; itemPtr++ ) {
+ status = U_ZERO_ERROR;
+ ParsePosition pos(0);
+ ((SimpleDateFormat*) sdmft)->applyPattern(itemPtr->pattern);
+ if (U_FAILURE(status)) {
+ dataerrln("Unable to create SimpleDateFormat - %s", u_errorName(status));
+ continue;
+ }
+ sdmft->setBooleanAttribute(UDAT_PARSE_MULTIPLE_PATTERNS_FOR_MATCH, itemPtr->leniency, status);
+ UDate d = sdmft->parse(itemPtr->parseString, pos);
+
+ if(itemPtr->expectedResult.length() == 0) {
+ if(pos.getErrorIndex() != -1) {
+ continue;
+ } else {
+ errln("error: unexpected parse success - " + itemPtr->parseString +
+ " - error index " + pos.getErrorIndex() +
+ " - leniency " + itemPtr->leniency);
+ continue;
+ }
+ }
+ if(pos.getErrorIndex() != -1) {
+ errln("error: parse error for string - " +itemPtr->parseString + " -- idx["+pos.getIndex()+"] errIdx["+pos.getErrorIndex()+"]");
+ continue;
+ }
+
+ UnicodeString formatResult("");
+ sdmft->format(d, formatResult);
+ if(formatResult.compare(itemPtr->expectedResult) != 0) {
+ errln("error: unexpected format result. expected[" + itemPtr->expectedResult + "] but result was[" + formatResult + "]");
+ } else {
+ logln("formatted results match! - " + formatResult);
+ }
+ }
+ delete sdmft;
+}
+
+void DateFormatTest::TestParseLeniencyAPIs() {
+ UErrorCode status = U_ZERO_ERROR;
+ LocalPointer<DateFormat> dateFormat(DateFormat::createDateInstance());
+ DateFormat *fmt = dateFormat.getAlias();
+
+ assertTrue("isLenient default", fmt->isLenient());
+ assertTrue("isCalendarLenient default", fmt->isCalendarLenient());
+ assertTrue("ALLOW_WHITESPACE default", fmt->getBooleanAttribute(UDAT_PARSE_ALLOW_WHITESPACE, status));
+ assertTrue("ALLOW_NUMERIC default", fmt->getBooleanAttribute(UDAT_PARSE_ALLOW_NUMERIC, status));
+ assertTrue("PARTIAL_MATCH default", fmt->getBooleanAttribute(UDAT_PARSE_PARTIAL_MATCH, status));
+ assertTrue("MULTIPLE_PATTERNS default", fmt->getBooleanAttribute(UDAT_PARSE_MULTIPLE_PATTERNS_FOR_MATCH, status));
+
+ // Set calendar to strict
+ fmt->setCalendarLenient(FALSE);
+
+ assertFalse("isLeninent after setCalendarLenient(FALSE)", fmt->isLenient());
+ assertFalse("isCalendarLenient after setCalendarLenient(FALSE)", fmt->isCalendarLenient());
+ assertTrue("ALLOW_WHITESPACE after setCalendarLenient(FALSE)", fmt->getBooleanAttribute(UDAT_PARSE_ALLOW_WHITESPACE, status));
+ assertTrue("ALLOW_NUMERIC after setCalendarLenient(FALSE)", fmt->getBooleanAttribute(UDAT_PARSE_ALLOW_NUMERIC, status));
+
+ // Set to strict
+ fmt->setLenient(FALSE);
+
+ assertFalse("isLeninent after setLenient(FALSE)", fmt->isLenient());
+ assertFalse("isCalendarLenient after setLenient(FALSE)", fmt->isCalendarLenient());
+ assertFalse("ALLOW_WHITESPACE after setLenient(FALSE)", fmt->getBooleanAttribute(UDAT_PARSE_ALLOW_WHITESPACE, status));
+ assertFalse("ALLOW_NUMERIC after setLenient(FALSE)", fmt->getBooleanAttribute(UDAT_PARSE_ALLOW_NUMERIC, status));
+ // These two boolean attributes are NOT affected according to the API specification
+ assertTrue("PARTIAL_MATCH after setLenient(FALSE)", fmt->getBooleanAttribute(UDAT_PARSE_PARTIAL_MATCH, status));
+ assertTrue("MULTIPLE_PATTERNS after setLenient(FALSE)", fmt->getBooleanAttribute(UDAT_PARSE_MULTIPLE_PATTERNS_FOR_MATCH, status));
+
+ // Allow white space leniency
+ fmt->setBooleanAttribute(UDAT_PARSE_ALLOW_WHITESPACE, TRUE, status);
+
+ assertFalse("isLeninent after ALLOW_WHITESPACE/TRUE", fmt->isLenient());
+ assertFalse("isCalendarLenient after ALLOW_WHITESPACE/TRUE", fmt->isCalendarLenient());
+ assertTrue("ALLOW_WHITESPACE after ALLOW_WHITESPACE/TRUE", fmt->getBooleanAttribute(UDAT_PARSE_ALLOW_WHITESPACE, status));
+ assertFalse("ALLOW_NUMERIC after ALLOW_WHITESPACE/TRUE", fmt->getBooleanAttribute(UDAT_PARSE_ALLOW_NUMERIC, status));
+
+ // Set to lenient
+ fmt->setLenient(TRUE);
+
+ assertTrue("isLenient after setLenient(TRUE)", fmt->isLenient());
+ assertTrue("isCalendarLenient after setLenient(TRUE)", fmt->isCalendarLenient());
+ assertTrue("ALLOW_WHITESPACE after setLenient(TRUE)", fmt->getBooleanAttribute(UDAT_PARSE_ALLOW_WHITESPACE, status));
+ assertTrue("ALLOW_NUMERIC after setLenient(TRUE)", fmt->getBooleanAttribute(UDAT_PARSE_ALLOW_NUMERIC, status));
+}
+