ICU-7089 Add test for Calendar class time stamp recalculation in ICU4C
X-SVN-Rev: 29164
This commit is contained in:
parent
6400b375c6
commit
3261e6d703
@ -138,8 +138,8 @@ U_CFUNC void ucal_dump(UCalendar* cal) {
|
||||
|
||||
#endif
|
||||
|
||||
/* Max value for stamp allowable */
|
||||
#define STAMP_MAX INT32_MAX
|
||||
/* Max value for stamp allowable before recalculation */
|
||||
#define STAMP_MAX 10000
|
||||
|
||||
static const char * const gCalTypes[] = {
|
||||
"gregorian",
|
||||
|
@ -229,6 +229,13 @@ void CalendarTest::runIndexedTest( int32_t index, UBool exec, const char* &name,
|
||||
Test1624();
|
||||
}
|
||||
break;
|
||||
case 25:
|
||||
name = "TestTimeStamp";
|
||||
if(exec) {
|
||||
logln("TestTimeStamp---"); logln("");
|
||||
TestTimeStamp();
|
||||
}
|
||||
break;
|
||||
default: name = ""; break;
|
||||
}
|
||||
}
|
||||
@ -2158,6 +2165,41 @@ void CalendarTest::Test1624() {
|
||||
return;
|
||||
}
|
||||
|
||||
void CalendarTest::TestTimeStamp() {
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
UDate start, time;
|
||||
Calendar *cal;
|
||||
|
||||
// Create a new Gregorian Calendar.
|
||||
cal = Calendar::createInstance("en_US@calender=gregorian", status);
|
||||
if (U_FAILURE(status)) {
|
||||
dataerrln("Error creating Gregorian calendar.");
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 20000; i++) {
|
||||
// Set the Gregorian Calendar to a specific date for testing.
|
||||
cal->set(2009, UCAL_JULY, 3, 0, 49, 46);
|
||||
|
||||
time = cal->getTime(status);
|
||||
if (U_FAILURE(status)) {
|
||||
errln("Error calling getTime()");
|
||||
break;
|
||||
}
|
||||
|
||||
if (i == 0) {
|
||||
start = time;
|
||||
} else {
|
||||
if (start != time) {
|
||||
errln("start and time not equal.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
delete cal;
|
||||
}
|
||||
|
||||
#endif /* #if !UCONFIG_NO_FORMATTING */
|
||||
|
||||
//eof
|
||||
|
@ -1,5 +1,5 @@
|
||||
/***********************************************************************
|
||||
* Copyright (c) 1997-2009, International Business Machines Corporation
|
||||
* Copyright (c) 1997-2010, International Business Machines Corporation
|
||||
* and others. All Rights Reserved.
|
||||
***********************************************************************/
|
||||
|
||||
@ -219,6 +219,11 @@ public: // package
|
||||
void Test6703(void);
|
||||
void Test3785(void);
|
||||
void Test1624(void);
|
||||
|
||||
/**
|
||||
* Test the time stamp array recalculation during heavy Calendar usage
|
||||
*/
|
||||
void TestTimeStamp(void);
|
||||
};
|
||||
|
||||
#endif /* #if !UCONFIG_NO_FORMATTING */
|
||||
|
Loading…
Reference in New Issue
Block a user