ICU-2943 improve test output for calendars
X-SVN-Rev: 13553
This commit is contained in:
parent
af6e74535c
commit
1829aafdfe
@ -1956,8 +1956,10 @@ void CalendarRegressionTest::TestJ81() {
|
|||||||
fmt.setCalendar(cal);
|
fmt.setCalendar(cal);
|
||||||
// Get the Gregorian cutover
|
// Get the Gregorian cutover
|
||||||
UDate cutover = cal.getGregorianChange();
|
UDate cutover = cal.getGregorianChange();
|
||||||
|
UDate days = ONE_DAY;
|
||||||
|
days = cutover/days;
|
||||||
logln(UnicodeString("Cutover: {") +
|
logln(UnicodeString("Cutover: {") +
|
||||||
fmt.format(cutover, temp) + "}(" + cutover/ONE_DAY + ")");
|
fmt.format(cutover, temp) + "}(epoch days-" + (int)days + ", jd" + (2440588 + days) +")");
|
||||||
|
|
||||||
// Check woy and doy handling. Reference data:
|
// Check woy and doy handling. Reference data:
|
||||||
/* w40 d274 Mon 1 Oct 1582
|
/* w40 d274 Mon 1 Oct 1582
|
||||||
@ -1993,25 +1995,12 @@ void CalendarRegressionTest::TestJ81() {
|
|||||||
26, 42, 289, UCAL_TUESDAY,
|
26, 42, 289, UCAL_TUESDAY,
|
||||||
27, 42, 290, UCAL_WEDNESDAY,
|
27, 42, 290, UCAL_WEDNESDAY,
|
||||||
28, 42, 291, UCAL_THURSDAY,
|
28, 42, 291, UCAL_THURSDAY,
|
||||||
|
|
||||||
#ifdef _TMP_ROLLOVER_28
|
|
||||||
29, 42, 292, UCAL_FRIDAY,
|
29, 42, 292, UCAL_FRIDAY,
|
||||||
30, 42, 293, UCAL_SATURDAY,
|
30, 42, 293, UCAL_SATURDAY,
|
||||||
31, 43, 294, UCAL_SUNDAY
|
31, 43, 294, UCAL_SUNDAY
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
int32_t DOY_DATA_length = (int32_t)(sizeof(DOY_DATA) / sizeof(DOY_DATA[0]));
|
int32_t DOY_DATA_length = (int32_t)(sizeof(DOY_DATA) / sizeof(DOY_DATA[0]));
|
||||||
|
|
||||||
#ifndef _TMP_ROLLOVER_28
|
|
||||||
static const UDate kExpire = 1067480869000.0;
|
|
||||||
|
|
||||||
if(Calendar::getNow() >= kExpire) {
|
|
||||||
errln("FAIL: please remove #ifdef _TMP_ROLLOVER_28 and fix this code - [%s:%d]", __FILE__, __LINE__);
|
|
||||||
} else {
|
|
||||||
logln("WARNING: %.0lf days until gregorian cutover test reenabled - please #define _TMP_ROLLOVER_28 or remove these #ifdefs [%s:%d]\n", (kExpire-Calendar::getNow())/86400000.0, __FILE__, __LINE__);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
for (i=0; i<DOY_DATA_length; i+=4) {
|
for (i=0; i<DOY_DATA_length; i+=4) {
|
||||||
// Test time->fields
|
// Test time->fields
|
||||||
cal.set(1582, UCAL_OCTOBER, DOY_DATA[i]);
|
cal.set(1582, UCAL_OCTOBER, DOY_DATA[i]);
|
||||||
@ -2025,7 +2014,8 @@ void CalendarRegressionTest::TestJ81() {
|
|||||||
if (woy != DOY_DATA[i+1] || doy != DOY_DATA[i+2] || dow != DOY_DATA[i+3]) {
|
if (woy != DOY_DATA[i+1] || doy != DOY_DATA[i+2] || dow != DOY_DATA[i+3]) {
|
||||||
errln((UnicodeString)"Fail: expect woy=" + DOY_DATA[i+1] +
|
errln((UnicodeString)"Fail: expect woy=" + DOY_DATA[i+1] +
|
||||||
", doy=" + DOY_DATA[i+2] + ", dow=" + DOY_DATA[i+3] + " on " +
|
", doy=" + DOY_DATA[i+2] + ", dow=" + DOY_DATA[i+3] + " on " +
|
||||||
fmt.format(cal.getTime(status), temp.remove()));
|
fmt.format(cal.getTime(status), temp.remove()) +
|
||||||
|
" set(1582,OCTOBER, " + DOY_DATA[i] + ")");
|
||||||
logln(CalendarTest::calToStr(cal));
|
logln(CalendarTest::calToStr(cal));
|
||||||
status = U_ZERO_ERROR;
|
status = U_ZERO_ERROR;
|
||||||
} else {
|
} else {
|
||||||
@ -2035,7 +2025,6 @@ void CalendarRegressionTest::TestJ81() {
|
|||||||
logln(CalendarTest::calToStr(cal));
|
logln(CalendarTest::calToStr(cal));
|
||||||
status = U_ZERO_ERROR;
|
status = U_ZERO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test fields->time for WOY
|
// Test fields->time for WOY
|
||||||
cal.clear();
|
cal.clear();
|
||||||
cal.set(UCAL_YEAR, 1582);
|
cal.set(UCAL_YEAR, 1582);
|
||||||
@ -2051,6 +2040,7 @@ void CalendarRegressionTest::TestJ81() {
|
|||||||
" dow=" + DOY_DATA[i+3] + " => " +
|
" dow=" + DOY_DATA[i+3] + " => " +
|
||||||
fmt.format(cal.getTime(status), temp.remove()) +
|
fmt.format(cal.getTime(status), temp.remove()) +
|
||||||
", expected 1582 Oct " + DOY_DATA[i]);
|
", expected 1582 Oct " + DOY_DATA[i]);
|
||||||
|
logln(CalendarTest::calToStr(cal));
|
||||||
status = U_ZERO_ERROR;
|
status = U_ZERO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2073,11 +2063,6 @@ void CalendarRegressionTest::TestJ81() {
|
|||||||
}
|
}
|
||||||
status = U_ZERO_ERROR;
|
status = U_ZERO_ERROR;
|
||||||
|
|
||||||
#ifndef _TMP_ROLLOVER_28
|
|
||||||
logln("warning: %s:%d exitting early\n", __FILE__, __LINE__);
|
|
||||||
return;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define ADD_ROLL ADD|ROLL
|
#define ADD_ROLL ADD|ROLL
|
||||||
#define PLUS_MINUS PLUS|MINUS
|
#define PLUS_MINUS PLUS|MINUS
|
||||||
// Test cases
|
// Test cases
|
||||||
|
@ -1294,17 +1294,7 @@ CalendarTest::TestDOW_LOCALandYEAR_WOY()
|
|||||||
yearAddTest(*cal, status); // aliu
|
yearAddTest(*cal, status); // aliu
|
||||||
loop_addroll(cal, /*sdf,*/ times, UCAL_DOW_LOCAL, UCAL_DAY_OF_WEEK, status);
|
loop_addroll(cal, /*sdf,*/ times, UCAL_DOW_LOCAL, UCAL_DAY_OF_WEEK, status);
|
||||||
if (U_FAILURE(status)) { errln("Error in parse/calculate test for 1998"); return; }
|
if (U_FAILURE(status)) { errln("Error in parse/calculate test for 1998"); return; }
|
||||||
#ifndef _TMP_ROLLOVER_28
|
|
||||||
static const UDate kExpire = 1067480869000.0;
|
|
||||||
|
|
||||||
if(Calendar::getNow() >= kExpire) {
|
|
||||||
errln("FAIL: please remove #ifdef _TMP_ROLLOVER_28 and fix this code - [%s:%d]", __FILE__, __LINE__);
|
|
||||||
} else {
|
|
||||||
logln("WARNING: %.0lf days until gregorian cutover test reenabled - please #define _TMP_ROLLOVER_28 or remove these #ifdefs [%s:%d]\n", (kExpire-Calendar::getNow())/86400000.0, __FILE__, __LINE__);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef _TMP_ROLLOVER_28
|
|
||||||
cal->clear();
|
cal->clear();
|
||||||
cal->set(1582, UCAL_OCTOBER, 1);
|
cal->set(1582, UCAL_OCTOBER, 1);
|
||||||
doYEAR_WOYLoop(cal, sdf, times, status);
|
doYEAR_WOYLoop(cal, sdf, times, status);
|
||||||
@ -1312,7 +1302,6 @@ CalendarTest::TestDOW_LOCALandYEAR_WOY()
|
|||||||
yearAddTest(*cal, status); // aliu
|
yearAddTest(*cal, status); // aliu
|
||||||
loop_addroll(cal, /*sdf,*/ times, UCAL_DOW_LOCAL, UCAL_DAY_OF_WEEK, status);
|
loop_addroll(cal, /*sdf,*/ times, UCAL_DOW_LOCAL, UCAL_DAY_OF_WEEK, status);
|
||||||
if (U_FAILURE(status)) { errln("Error in parse/calculate test for 1582"); return; }
|
if (U_FAILURE(status)) { errln("Error in parse/calculate test for 1582"); return; }
|
||||||
#endif
|
|
||||||
delete sdf;
|
delete sdf;
|
||||||
delete cal;
|
delete cal;
|
||||||
|
|
||||||
@ -1453,28 +1442,29 @@ CalendarTest::doYEAR_WOYLoop(Calendar *cal, SimpleDateFormat *sdf,
|
|||||||
if(original!=tst) {
|
if(original!=tst) {
|
||||||
us.remove();
|
us.remove();
|
||||||
sdf->format(Formattable(original, Formattable::kIsDate), us, errorCode);
|
sdf->format(Formattable(original, Formattable::kIsDate), us, errorCode);
|
||||||
errln("Parsed time doesn't match with regular");
|
errln("FAIL: Parsed time doesn't match with regular");
|
||||||
logln("expected "+us);
|
logln("expected "+us + " " + calToStr(*cal));
|
||||||
us.remove();
|
us.remove();
|
||||||
sdf->format(Formattable(tst, Formattable::kIsDate), us, errorCode);
|
sdf->format(Formattable(tst, Formattable::kIsDate), us, errorCode);
|
||||||
logln("got "+us);
|
logln("got "+us + " " + calToStr(*tstres));
|
||||||
}
|
}
|
||||||
tstres->clear();
|
tstres->clear();
|
||||||
tstres->set(UCAL_YEAR_WOY, cal->get(UCAL_YEAR_WOY, errorCode));
|
tstres->set(UCAL_YEAR_WOY, cal->get(UCAL_YEAR_WOY, errorCode));
|
||||||
tstres->set(UCAL_WEEK_OF_YEAR, cal->get(UCAL_WEEK_OF_YEAR, errorCode));
|
tstres->set(UCAL_WEEK_OF_YEAR, cal->get(UCAL_WEEK_OF_YEAR, errorCode));
|
||||||
tstres->set(UCAL_DOW_LOCAL, cal->get(UCAL_DOW_LOCAL, errorCode));
|
tstres->set(UCAL_DOW_LOCAL, cal->get(UCAL_DOW_LOCAL, errorCode));
|
||||||
if(cal->get(UCAL_YEAR, errorCode) != tstres->get(UCAL_YEAR, errorCode)) {
|
if(cal->get(UCAL_YEAR, errorCode) != tstres->get(UCAL_YEAR, errorCode)) {
|
||||||
errln("Different Year!");
|
errln("FAIL: Different Year!");
|
||||||
logln((UnicodeString)"Expected "+cal->get(UCAL_YEAR, errorCode));
|
logln((UnicodeString)"Expected "+cal->get(UCAL_YEAR, errorCode));
|
||||||
logln((UnicodeString)"Got "+tstres->get(UCAL_YEAR, errorCode));
|
logln((UnicodeString)"Got "+tstres->get(UCAL_YEAR, errorCode));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(cal->get(UCAL_DAY_OF_YEAR, errorCode) != tstres->get(UCAL_DAY_OF_YEAR, errorCode)) {
|
if(cal->get(UCAL_DAY_OF_YEAR, errorCode) != tstres->get(UCAL_DAY_OF_YEAR, errorCode)) {
|
||||||
errln("Different Day Of Year!");
|
errln("FAIL: Different Day Of Year!");
|
||||||
logln((UnicodeString)"Expected "+cal->get(UCAL_DAY_OF_YEAR, errorCode));
|
logln((UnicodeString)"Expected "+cal->get(UCAL_DAY_OF_YEAR, errorCode));
|
||||||
logln((UnicodeString)"Got "+tstres->get(UCAL_DAY_OF_YEAR, errorCode));
|
logln((UnicodeString)"Got "+tstres->get(UCAL_DAY_OF_YEAR, errorCode));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
//logln(calToStr(*cal));
|
||||||
cal->add(UCAL_DATE, 1, errorCode);
|
cal->add(UCAL_DATE, 1, errorCode);
|
||||||
if (U_FAILURE(errorCode)) { errln("Add error"); return; }
|
if (U_FAILURE(errorCode)) { errln("Add error"); return; }
|
||||||
us.remove();
|
us.remove();
|
||||||
|
Loading…
Reference in New Issue
Block a user