ICU-3009 calendar code coverage & bug fixes
X-SVN-Rev: 12406
This commit is contained in:
parent
0c0cc0ffde
commit
477dbae103
@ -79,6 +79,7 @@ CalendarRegressionTest::runIndexedTest( int32_t index, UBool exec, const char* &
|
||||
CASE(41,test4092362);
|
||||
CASE(42,TestWeekShift);
|
||||
CASE(43,TestTimeZoneTransitionAdd);
|
||||
CASE(44,TestDeprecates);
|
||||
default: name = ""; break;
|
||||
}
|
||||
}
|
||||
@ -1242,6 +1243,43 @@ void CalendarRegressionTest::test4118384()
|
||||
cal->getActualMaximum(UCAL_HOUR,status) != 11)
|
||||
errln("Fail: maximum of HOUR field should be 11");
|
||||
|
||||
// test deprecated functions
|
||||
if (cal->getLeastMaximum(Calendar::HOUR) != 11 ||
|
||||
cal->getMaximum(Calendar::HOUR) != 11) {
|
||||
errln("Fail: [deprecated functions] maximum of HOUR field should be 11\n");
|
||||
}
|
||||
|
||||
if (cal->getGreatestMinimum(Calendar::HOUR) != 0 ||
|
||||
cal->getMinimum(Calendar::HOUR) != 0) {
|
||||
errln("Fail: [deprecated functions] minimum of HOUR field should be 1\n");
|
||||
}
|
||||
|
||||
delete cal;
|
||||
cal = Calendar::createInstance(Locale("th_TH_TRADITIONAL"),status);
|
||||
// test deprecated functions
|
||||
if (cal->getLeastMaximum(Calendar::HOUR) != 11 ||
|
||||
cal->getMaximum(Calendar::HOUR) != 11) {
|
||||
errln("Fail: Buddhist:[deprecated functions] maximum of HOUR field should be 11\n");
|
||||
}
|
||||
|
||||
if (cal->getGreatestMinimum(Calendar::HOUR) != 0 ||
|
||||
cal->getMinimum(Calendar::HOUR) != 0) {
|
||||
errln("Fail: Buddhist:[deprecated functions] minimum of HOUR field should be 1\n");
|
||||
}
|
||||
|
||||
delete cal;
|
||||
// test deprecated functions
|
||||
cal = Calendar::createInstance(Locale("ja_JP_TRADITIONAL"),status);
|
||||
if (cal->getLeastMaximum(Calendar::HOUR) != 11 ||
|
||||
cal->getMaximum(Calendar::HOUR) != 11) {
|
||||
errln("Fail: Japanese:[deprecated functions] maximum of HOUR field should be 11\n");
|
||||
}
|
||||
|
||||
if (cal->getGreatestMinimum(Calendar::HOUR) != 0 ||
|
||||
cal->getMinimum(Calendar::HOUR) != 0) {
|
||||
errln("Fail: Japanese:[deprecated functions] minimum of HOUR field should be 1\n");
|
||||
}
|
||||
|
||||
delete cal;
|
||||
}
|
||||
|
||||
@ -2382,4 +2420,90 @@ CalendarRegressionTest::makeDate(int32_t y, int32_t m, int32_t d,
|
||||
return result;
|
||||
}
|
||||
|
||||
void CalendarRegressionTest::TestDeprecates(void)
|
||||
{
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
Calendar *c1 = Calendar::createInstance("ja_JP_TRADITIONAL",status);
|
||||
Calendar *c2 = Calendar::createInstance("ja_JP_TRADITIONAL",status);
|
||||
|
||||
if(!c1 || !c2 || U_FAILURE(status)) {
|
||||
errln("Couldn't create calendars for roll of HOUR");
|
||||
return;
|
||||
}
|
||||
|
||||
c2->set(UCAL_HOUR,2);
|
||||
c1->setTime(c2->getTime(status),status);
|
||||
// *c1 = *c2;
|
||||
|
||||
c1->roll(Calendar::HOUR,(int32_t)3,status);
|
||||
c2->roll(UCAL_HOUR,(int32_t)3,status);
|
||||
|
||||
if(U_FAILURE(status)) {
|
||||
errln("Error code when trying to roll");
|
||||
} else if(*c1 != *c2) {
|
||||
errln("roll(EDateField) had different effect than roll(UCalendarField)");
|
||||
}
|
||||
|
||||
delete c1;
|
||||
delete c2;
|
||||
|
||||
status = U_ZERO_ERROR;
|
||||
|
||||
c1 = Calendar::createInstance("th_TH_TRADITIONAL",status);
|
||||
c2 = Calendar::createInstance("th_TH_TRADITIONAL",status);
|
||||
|
||||
if(!c1 || !c2 || U_FAILURE(status)) {
|
||||
errln("Couldn't create calendars for add of HOUR");
|
||||
return;
|
||||
}
|
||||
|
||||
c2->set(UCAL_HOUR,2);
|
||||
c1->setTime(c2->getTime(status),status);
|
||||
//*c1 = *c2;
|
||||
|
||||
c1->add(Calendar::HOUR,(int32_t)1,status);
|
||||
|
||||
if(U_FAILURE(status)) {
|
||||
errln("Error code when trying to add Calendar::HOUR - %s", u_errorName(status));
|
||||
}
|
||||
|
||||
c2->add(UCAL_HOUR,(int32_t)1,status);
|
||||
|
||||
if(U_FAILURE(status)) {
|
||||
errln("Error code when trying to add - UCAL_HOUR %s", u_errorName(status));
|
||||
} else if(*c1 != *c2) {
|
||||
errln("add(EDateField) had different effect than add(UCalendarField)");
|
||||
}
|
||||
|
||||
delete c1;
|
||||
delete c2;
|
||||
|
||||
status = U_ZERO_ERROR;
|
||||
|
||||
c1 = Calendar::createInstance("es_ES",status);
|
||||
c2 = Calendar::createInstance("es_ES",status);
|
||||
|
||||
if(!c1 || !c2 || U_FAILURE(status)) {
|
||||
errln("Couldn't create calendars for add of YEAR");
|
||||
return;
|
||||
}
|
||||
|
||||
c2->set(UCAL_YEAR,1900);
|
||||
c1->setTime(c2->getTime(status),status);
|
||||
//*c1 = *c2;
|
||||
|
||||
c1->add(Calendar::YEAR,(int32_t)9,status);
|
||||
c2->add(UCAL_YEAR,(int32_t)9,status);
|
||||
|
||||
if(U_FAILURE(status)) {
|
||||
errln("Error code when trying to add YEARs");
|
||||
} else if(*c1 != *c2) {
|
||||
errln("add(EDateField YEAR) had different effect than add(UCalendarField YEAR)");
|
||||
}
|
||||
|
||||
delete c1;
|
||||
delete c2;
|
||||
}
|
||||
|
||||
|
||||
#endif /* #if !UCONFIG_NO_FORMATTING */
|
||||
|
@ -68,6 +68,7 @@ public:
|
||||
void TestMalaysianInstance(void);
|
||||
void TestWeekShift(void);
|
||||
void TestTimeZoneTransitionAdd(void);
|
||||
void TestDeprecates(void);
|
||||
|
||||
void printdate(GregorianCalendar *cal, const char *string);
|
||||
void dowTest(UBool lenient) ;
|
||||
|
@ -276,6 +276,8 @@ CalendarTest::TestGenericAPI()
|
||||
{
|
||||
cal->setFirstDayOfWeek((UCalendarDaysOfWeek)i);
|
||||
if (cal->getFirstDayOfWeek() != i) errln("FAIL: set/getFirstDayOfWeek failed");
|
||||
UErrorCode aStatus = U_ZERO_ERROR;
|
||||
if (cal->getFirstDayOfWeek(aStatus) != i || U_FAILURE(aStatus)) errln("FAIL: getFirstDayOfWeek(status) failed");
|
||||
}
|
||||
|
||||
for (i=1; i<=7; ++i)
|
||||
|
@ -233,6 +233,7 @@ void IntlCalendarTest::quasiGregorianTest(Calendar& cal, const Locale& gcl, cons
|
||||
|
||||
// Verify that Gregorian works like Gregorian
|
||||
void IntlCalendarTest::TestGregorian() {
|
||||
UDate timeA = Calendar::getNow();
|
||||
int32_t data[] = {
|
||||
GregorianCalendar::AD, 1868, 1868, UCAL_SEPTEMBER, 8,
|
||||
GregorianCalendar::AD, 1868, 1868, UCAL_SEPTEMBER, 9,
|
||||
@ -245,8 +246,23 @@ void IntlCalendarTest::TestGregorian() {
|
||||
|
||||
Calendar *cal;
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
cal = Calendar::createInstance("de_DE", status);
|
||||
cal = Calendar::createInstance(/*"de_DE", */ status);
|
||||
CHECK(status, UnicodeString("Creating de_CH calendar"));
|
||||
// Sanity check the calendar
|
||||
UDate timeB = Calendar::getNow();
|
||||
UDate timeCal = cal->getTime(status);
|
||||
|
||||
if(!(timeA <= timeCal) || !(timeCal <= timeB)) {
|
||||
errln((UnicodeString)"Error: Calendar time " + timeCal +
|
||||
" is not within sampled times [" + timeA + " to " + timeB + "]!");
|
||||
}
|
||||
// end sanity check
|
||||
|
||||
// Note, the following is a good way to test the sanity of the constructed calendars,
|
||||
// using Collation as a delay-loop:
|
||||
//
|
||||
// $ intltest format/IntlCalendarTest collate/G7CollationTest format/IntlCalendarTest
|
||||
|
||||
quasiGregorianTest(*cal,Locale("fr_FR"),data);
|
||||
delete cal;
|
||||
}
|
||||
@ -257,6 +273,8 @@ void IntlCalendarTest::TestGregorian() {
|
||||
*/
|
||||
void IntlCalendarTest::TestBuddhist() {
|
||||
// BE 2542 == 1999 CE
|
||||
UDate timeA = Calendar::getNow();
|
||||
|
||||
int32_t data[] = {
|
||||
0, // B. era
|
||||
2542, // B. year
|
||||
@ -282,6 +300,18 @@ void IntlCalendarTest::TestBuddhist() {
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
cal = Calendar::createInstance("th_TH_TRADITIONAL", status);
|
||||
CHECK(status, UnicodeString("Creating th_TH_TRADITIONAL calendar"));
|
||||
|
||||
// Sanity check the calendar
|
||||
UDate timeB = Calendar::getNow();
|
||||
UDate timeCal = cal->getTime(status);
|
||||
|
||||
if(!(timeA <= timeCal) || !(timeCal <= timeB)) {
|
||||
errln((UnicodeString)"Error: Calendar time " + timeCal +
|
||||
" is not within sampled times [" + timeA + " to " + timeB + "]!");
|
||||
}
|
||||
// end sanity check
|
||||
|
||||
|
||||
quasiGregorianTest(*cal,Locale("th_TH"),data);
|
||||
delete cal;
|
||||
}
|
||||
@ -291,6 +321,7 @@ void IntlCalendarTest::TestBuddhist() {
|
||||
* behaves like GregorianCalendar.
|
||||
*/
|
||||
void IntlCalendarTest::TestJapanese() {
|
||||
UDate timeA = Calendar::getNow();
|
||||
|
||||
/* Sorry.. japancal.h is private! */
|
||||
#define JapaneseCalendar_MEIJI 232
|
||||
@ -321,6 +352,15 @@ void IntlCalendarTest::TestJapanese() {
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
cal = Calendar::createInstance("ja_JP_TRADITIONAL", status);
|
||||
CHECK(status, UnicodeString("Creating ja_JP_TRADITIONAL calendar"));
|
||||
// Sanity check the calendar
|
||||
UDate timeB = Calendar::getNow();
|
||||
UDate timeCal = cal->getTime(status);
|
||||
|
||||
if(!(timeA <= timeCal) || !(timeCal <= timeB)) {
|
||||
errln((UnicodeString)"Error: Calendar time " + timeCal +
|
||||
" is not within sampled times [" + timeA + " to " + timeB + "]!");
|
||||
}
|
||||
// end sanity check
|
||||
quasiGregorianTest(*cal,Locale("ja_JP"),data);
|
||||
delete cal;
|
||||
}
|
||||
|
@ -152,6 +152,9 @@ void IntlTestSimpleDateFormatAPI::testAPI(/*char *par*/)
|
||||
errln("Couldn't obtain DateFormatSymbols. Quitting test!");
|
||||
return;
|
||||
}
|
||||
if(syms->getDynamicClassID() != DateFormatSymbols::getStaticClassID()) {
|
||||
errln("ERROR: format->getDateFormatSymbols()->getDynamicClassID() != DateFormatSymbols::getStaticClassID()");
|
||||
}
|
||||
DateFormatSymbols *newSyms = new DateFormatSymbols(*syms);
|
||||
def.adoptDateFormatSymbols(newSyms);
|
||||
pat_fr.setDateFormatSymbols(*newSyms);
|
||||
@ -171,6 +174,13 @@ void IntlTestSimpleDateFormatAPI::testAPI(/*char *par*/)
|
||||
errln("ERROR: setTwoDigitStartDate() failed");
|
||||
}
|
||||
|
||||
// ======= Test DateFormatSymbols constructor
|
||||
newSyms =new DateFormatSymbols("gregorian", status);
|
||||
if(U_FAILURE(status)) {
|
||||
errln("ERROR: new DateFormatSymbols() failed");
|
||||
}
|
||||
def.adoptDateFormatSymbols(newSyms);
|
||||
|
||||
// ======= Test applyPattern()
|
||||
|
||||
logln("Testing applyPattern()");
|
||||
|
@ -172,7 +172,8 @@ int32_t SimpleThread::start()
|
||||
return -1;
|
||||
}
|
||||
|
||||
imp->fHandle = _beginthread( SimpleThreadProc, 0 /*stack size*/ , (void *)this );
|
||||
// imp->fHandle = _beginthread( SimpleThreadProc, 0 /*stack size*/ , (void *)this );
|
||||
imp->fHandle = -1;
|
||||
if (imp->fHandle == -1) {
|
||||
// An error occured
|
||||
int err = errno;
|
||||
|
Loading…
Reference in New Issue
Block a user