mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-08 06:53:45 +00:00
ICU-2039 calendar code coverage improvements
X-SVN-Rev: 12444
This commit is contained in:
parent
c681c1aadb
commit
9ae7f6b85a
2 changed files with 64 additions and 0 deletions
|
@ -529,6 +529,30 @@ void CalendarRegressionTest::dowTest(UBool lenient)
|
|||
if (dow != UCAL_SUNDAY)
|
||||
errln("FAIL: Day of week should be SUNDAY Got " + dow);
|
||||
|
||||
if(U_FAILURE(status)) {
|
||||
errln("Error checking Calendar: %s", u_errorName(status));
|
||||
delete cal;
|
||||
return;
|
||||
}
|
||||
|
||||
if(cal->getActualMinimum(UCAL_DAY_OF_WEEK) != min) {
|
||||
errln("FAIL: actual minimum differs from minimum");
|
||||
}
|
||||
if(cal->getActualMinimum(Calendar::DAY_OF_WEEK) != min) {
|
||||
errln("FAIL: actual minimum (Calendar::DAY_OF_WEEK) differs from minimum");
|
||||
}
|
||||
if(((Calendar*)cal)->getActualMinimum(UCAL_DAY_OF_WEEK, status) != min) {
|
||||
errln("FAIL: actual minimum (UCAL_DAY_OF_WEEK, status) differs from minimum");
|
||||
}
|
||||
// Does not exist!
|
||||
// if(((Calendar*)cal)->getActualMinimum(Calendar::DAY_OF_WEEK, status) != min) {
|
||||
// errln("FAIL: actual minimum (Calendar::DAY_OF_WEEK, status) differs from minimum");
|
||||
// }
|
||||
if(U_FAILURE(status)) {
|
||||
errln("Error getting actual minimum: %s", u_errorName(status));
|
||||
return;
|
||||
}
|
||||
|
||||
delete cal;
|
||||
}
|
||||
|
||||
|
@ -2134,6 +2158,13 @@ void CalendarRegressionTest::TestJ438(void) {
|
|||
int32_t dd = cal.fieldDifference(date2, UCAL_DATE, ec);
|
||||
if (failure(ec, "fieldDifference"))
|
||||
break;
|
||||
int32_t dd_x=cal.fieldDifference(date2, Calendar::DATE,ec);
|
||||
if (failure(ec, "fieldDifference(date, Calendar::DATE, ec)"))
|
||||
break;
|
||||
if(dd_x != dd){
|
||||
errln("fieldDifference(UCAL_DATE) and fieldDifference(Calendar::DATE) give different results.\n");
|
||||
}
|
||||
|
||||
|
||||
logln(UnicodeString("") +
|
||||
fmt.format(date2, s.remove()) + " - " +
|
||||
|
|
|
@ -460,6 +460,39 @@ void IntlCalendarTest::TestJapaneseFormat() {
|
|||
}
|
||||
delete fmt;
|
||||
}
|
||||
|
||||
// Test parse with incomplete information
|
||||
fmt = new SimpleDateFormat(UnicodeString("G y"), Locale("en_US"), status);
|
||||
aDate = -3197120400000.;
|
||||
CHECK(status, "creating date format instance");
|
||||
if(!fmt) {
|
||||
errln("Coudln't create en_US instance");
|
||||
} else {
|
||||
UnicodeString str;
|
||||
fmt->format(aDate, str);
|
||||
logln(UnicodeString() + "Test Date: " + str);
|
||||
str.remove();
|
||||
fmt->adoptCalendar(cal2->clone());
|
||||
fmt->format(aDate, str);
|
||||
logln(UnicodeString() + "as Japanese Calendar: " + str);
|
||||
UnicodeString expected("Meiji 1");
|
||||
if(str != expected) {
|
||||
errln("Expected " + expected + " but got " + str);
|
||||
}
|
||||
UDate otherDate = fmt->parse(expected, status);
|
||||
if(otherDate != aDate) {
|
||||
UnicodeString str3;
|
||||
ParsePosition pp;
|
||||
fmt->parse(expected, *cal2, pp);
|
||||
fmt->format(otherDate, str3);
|
||||
errln("Parse incorrect of " + expected + " - wanted " + aDate + " but got " + " = " +
|
||||
otherDate + ", " + str3 + " = " + calToStr(*cal2) );
|
||||
} else {
|
||||
logln("Parsed OK: " + expected);
|
||||
}
|
||||
delete fmt;
|
||||
}
|
||||
|
||||
delete cal;
|
||||
delete cal2;
|
||||
CHECK(status, "Error occured");
|
||||
|
|
Loading…
Add table
Reference in a new issue