From 29cd7b1fc9b6dd97737f314de89adec3c62f5d49 Mon Sep 17 00:00:00 2001 From: Jugu Dannie Sundar Date: Tue, 5 Sep 2017 22:22:09 +0000 Subject: [PATCH] ICU-11632 icu4c changes for integer overflow in calendar support X-SVN-Rev: 40369 --- icu4c/source/i18n/calendar.cpp | 181 +++++----- icu4c/source/i18n/unicode/calendar.h | 20 +- icu4c/source/test/intltest/calregts.cpp | 431 +++++++++++++----------- icu4c/source/test/intltest/calregts.h | 13 +- 4 files changed, 343 insertions(+), 302 deletions(-) diff --git a/icu4c/source/i18n/calendar.cpp b/icu4c/source/i18n/calendar.cpp index 2c14b113a16..10fc1ed2774 100644 --- a/icu4c/source/i18n/calendar.cpp +++ b/icu4c/source/i18n/calendar.cpp @@ -8,12 +8,12 @@ * * File CALENDAR.CPP * -* Modification History: +* Modification History: * * Date Name Description * 02/03/97 clhuang Creation. -* 04/22/97 aliu Cleaned up, fixed memory leak, made -* setWeekCountData() more robust. +* 04/22/97 aliu Cleaned up, fixed memory leak, made +* setWeekCountData() more robust. * Moved platform code to TPlatformUtilities. * 05/01/97 aliu Made equals(), before(), after() arguments const. * 05/20/97 aliu Changed logic of when to compute fields and time @@ -26,7 +26,7 @@ ******************************************************************************* */ -#include "utypeinfo.h" // for 'typeid' to work +#include "utypeinfo.h" // for 'typeid' to work #include "unicode/utypes.h" @@ -93,9 +93,9 @@ U_CDECL_END #if defined( U_DEBUG_CALSVC ) || defined (U_DEBUG_CAL) -/** - * fldName was removed as a duplicate implementation. - * use udbg_ services instead, +/** + * fldName was removed as a duplicate implementation. + * use udbg_ services instead, * which depend on include files and library from ../tools/toolutil, the following circular link: * CPPFLAGS+=-I$(top_srcdir)/tools/toolutil * LIBS+=$(LIBICUTOOLUTIL) @@ -123,7 +123,7 @@ void ucal_dump(const Calendar &cal) { void Calendar::dump() const { int i; fprintf(stderr, "@calendar=%s, timeset=%c, fieldset=%c, allfields=%c, virtualset=%c, t=%.2f", - getType(), fIsTimeSet?'y':'n', fAreFieldsSet?'y':'n', fAreAllFieldsSet?'y':'n', + getType(), fIsTimeSet?'y':'n', fAreFieldsSet?'y':'n', fAreAllFieldsSet?'y':'n', fAreFieldsVirtuallySet?'y':'n', fTime); @@ -135,9 +135,9 @@ void Calendar::dump() const { fprintf(stderr, " %25s: %-11ld", f, fFields[i]); if(fStamp[i] == kUnset) { fprintf(stderr, " (unset) "); - } else if(fStamp[i] == kInternallySet) { + } else if(fStamp[i] == kInternallySet) { fprintf(stderr, " (internally set) "); - //} else if(fStamp[i] == kInternalDefault) { + //} else if(fStamp[i] == kInternalDefault) { // fprintf(stderr, " (internal default) "); } else { fprintf(stderr, " %%%d ", fStamp[i]); @@ -213,7 +213,7 @@ const SharedCalendar *LocaleCacheKey::createObject( const void * /*unusedCreationContext*/, UErrorCode &status) const { Calendar *calendar = Calendar::makeInstance(fLoc, status); if (U_FAILURE(status)) { - return NULL; + return NULL; } SharedCalendar *shared = new SharedCalendar(calendar); if (shared == NULL) { @@ -234,7 +234,7 @@ static ECalType getCalendarType(const char *s) { return CALTYPE_UNKNOWN; } -static UBool isStandardSupportedKeyword(const char *keyword, UErrorCode& status) { +static UBool isStandardSupportedKeyword(const char *keyword, UErrorCode& status) { if(U_FAILURE(status)) { return FALSE; } @@ -291,7 +291,7 @@ static ECalType getCalendarTypeForLocale(const char *locid) { if (U_FAILURE(status)) { return CALTYPE_GREGORIAN; } - + // Read preferred calendar values from supplementalData calendarPreference UResourceBundle *rb = ures_openDirect(NULL, "supplementalData", &status); ures_getByKey(rb, "calendarPreferenceData", rb, &status); @@ -394,7 +394,7 @@ static Calendar *createStandardCalendar(ECalType calType, const Locale &loc, UEr // ------------------------------------- /** -* a Calendar Factory which creates the "basic" calendar types, that is, those +* a Calendar Factory which creates the "basic" calendar types, that is, those * shipped with ICU. */ class BasicCalendarFactory : public LocaleKeyFactory { @@ -408,7 +408,7 @@ public: virtual ~BasicCalendarFactory(); protected: - //virtual UBool isSupportedID( const UnicodeString& id, UErrorCode& status) const { + //virtual UBool isSupportedID( const UnicodeString& id, UErrorCode& status) const { // if(U_FAILURE(status)) { // return FALSE; // } @@ -466,7 +466,7 @@ protected: BasicCalendarFactory::~BasicCalendarFactory() {} -/** +/** * A factory which looks up the DefaultCalendar resource to determine which class of calendar to use */ @@ -510,7 +510,7 @@ public: virtual UObject* cloneInstance(UObject* instance) const { UnicodeString *s = dynamic_cast(instance); if(s != NULL) { - return s->clone(); + return s->clone(); } else { #ifdef U_DEBUG_CALSVC_F UErrorCode status2 = U_ZERO_ERROR; @@ -573,7 +573,7 @@ initCalendarService(UErrorCode &status) fprintf(stderr, "Registering classes..\n"); #endif - // Register all basic instances. + // Register all basic instances. gService->registerFactory(new BasicCalendarFactory(),status); #ifdef U_DEBUG_CALSVC @@ -589,7 +589,7 @@ initCalendarService(UErrorCode &status) } } -static ICULocaleService* +static ICULocaleService* getCalendarService(UErrorCode &status) { umtx_initOnce(gServiceInitOnce, &initCalendarService, status); @@ -743,7 +743,7 @@ fSkippedWallTime(UCAL_WALLTIME_LAST) return; } - clear(); + clear(); fZone = zone; setWeekData(aLocale, NULL, success); } @@ -850,7 +850,7 @@ Calendar::createInstance(const Locale& aLocale, UErrorCode& success) return createInstance(TimeZone::createDefault(), aLocale, success); } -// ------------------------------------- Adopting +// ------------------------------------- Adopting // Note: this is the bottleneck that actually calls the service routines. @@ -903,7 +903,7 @@ Calendar::makeInstance(const Locale& aLocale, UErrorCode& success) { c = (Calendar*)getCalendarService(success)->get(l, LocaleKey::KIND_ANY, &actualLoc2, success); if(U_FAILURE(success) || !c) { - if(U_SUCCESS(success)) { + if(U_SUCCESS(success)) { success = U_INTERNAL_PROGRAM_ERROR; // Propagate some err } return NULL; @@ -911,7 +911,7 @@ Calendar::makeInstance(const Locale& aLocale, UErrorCode& success) { str = dynamic_cast(c); if(str != NULL) { - // recursed! Second lookup returned a UnicodeString. + // recursed! Second lookup returned a UnicodeString. // Perhaps DefaultCalendar{} was set to another locale. #ifdef U_DEBUG_CALSVC char tmp[200]; @@ -985,7 +985,7 @@ Calendar::createInstance(const TimeZone& zone, const Locale& aLocale, UErrorCode if(U_SUCCESS(success) && c) { c->setTimeZone(zone); } - return c; + return c; } // ------------------------------------- @@ -1017,7 +1017,7 @@ Calendar::operator==(const Calendar& that) const U_SUCCESS(status); } -UBool +UBool Calendar::isEquivalentTo(const Calendar& other) const { return typeid(*this) == typeid(other) && @@ -1099,13 +1099,13 @@ Calendar::getNow() * Gets this Calendar's current time as a long. * @return the current time as UTC milliseconds from the epoch. */ -double +double Calendar::getTimeInMillis(UErrorCode& status) const { - if(U_FAILURE(status)) + if(U_FAILURE(status)) return 0.0; - if ( ! fIsTimeSet) + if ( ! fIsTimeSet) ((Calendar*)this)->updateTime(status); /* Test for buffer overflows */ @@ -1124,9 +1124,9 @@ Calendar::getTimeInMillis(UErrorCode& status) const * when in lenient mode the out of range values are pinned to their respective min/max. * @param date the new time in UTC milliseconds from the epoch. */ -void +void Calendar::setTimeInMillis( double millis, UErrorCode& status ) { - if(U_FAILURE(status)) + if(U_FAILURE(status)) return; if (millis > MAX_MILLIS) { @@ -1154,7 +1154,7 @@ Calendar::setTimeInMillis( double millis, UErrorCode& status ) { fStamp[i] = kUnset; fIsSet[i] = FALSE; } - + } @@ -1479,7 +1479,7 @@ void Calendar::computeFields(UErrorCode &ec) double localMillis = internalGetTime(); int32_t rawOffset, dstOffset; getTimeZone().getOffset(localMillis, FALSE, rawOffset, dstOffset, ec); - localMillis += (rawOffset + dstOffset); + localMillis += (rawOffset + dstOffset); // Mark fields as set. Do this before calling handleComputeFields(). uint32_t mask = //fInternalSetMask; @@ -1488,7 +1488,7 @@ void Calendar::computeFields(UErrorCode &ec) (1 << UCAL_MONTH) | (1 << UCAL_DAY_OF_MONTH) | // = UCAL_DATE (1 << UCAL_DAY_OF_YEAR) | - (1 << UCAL_EXTENDED_YEAR); + (1 << UCAL_EXTENDED_YEAR); for (int32_t i=0; iset(field, fieldValue); if (work->get(field, status) != fieldValue) { break; - } + } else { result = fieldValue; fieldValue--; @@ -2800,7 +2800,7 @@ void Calendar::validateField(UCalendarDateFields field, UErrorCode &status) { case UCAL_DAY_OF_WEEK_IN_MONTH: if (internalGet(field) == 0) { #if defined (U_DEBUG_CAL) - fprintf(stderr, "%s:%d: ILLEGAL ARG because DOW in month cannot be 0\n", + fprintf(stderr, "%s:%d: ILLEGAL ARG because DOW in month cannot be 0\n", __FILE__, __LINE__); #endif status = U_ILLEGAL_ARGUMENT_ERROR; // "DAY_OF_WEEK_IN_MONTH cannot be zero" @@ -2826,7 +2826,7 @@ void Calendar::validateField(UCalendarDateFields field, int32_t min, int32_t max int32_t value = fFields[field]; if (value < min || value > max) { #if defined (U_DEBUG_CAL) - fprintf(stderr, "%s:%d: ILLEGAL ARG because of field %s out of range %d..%d at %d\n", + fprintf(stderr, "%s:%d: ILLEGAL ARG because of field %s out of range %d..%d at %d\n", __FILE__, __LINE__,fldName(field),min,max,value); #endif status = U_ILLEGAL_ARGUMENT_ERROR; @@ -2892,7 +2892,7 @@ linesInGroup: } const UFieldResolutionTable Calendar::kDatePrecedence[] = -{ +{ { { UCAL_DAY_OF_MONTH, kResolveSTOP }, { UCAL_WEEK_OF_YEAR, UCAL_DAY_OF_WEEK, kResolveSTOP }, @@ -2913,12 +2913,12 @@ const UFieldResolutionTable Calendar::kDatePrecedence[] = { kResolveRemap | UCAL_DAY_OF_WEEK_IN_MONTH, UCAL_DAY_OF_WEEK, kResolveSTOP }, { kResolveRemap | UCAL_DAY_OF_WEEK_IN_MONTH, UCAL_DOW_LOCAL, kResolveSTOP }, { kResolveSTOP } - }, + }, {{kResolveSTOP}} }; -const UFieldResolutionTable Calendar::kDOWPrecedence[] = +const UFieldResolutionTable Calendar::kDOWPrecedence[] = { { { UCAL_DAY_OF_WEEK,kResolveSTOP, kResolveSTOP }, @@ -2929,7 +2929,7 @@ const UFieldResolutionTable Calendar::kDOWPrecedence[] = }; // precedence for calculating a year -const UFieldResolutionTable Calendar::kYearPrecedence[] = +const UFieldResolutionTable Calendar::kYearPrecedence[] = { { { UCAL_YEAR, kResolveSTOP }, @@ -2966,7 +2966,7 @@ void Calendar::computeTime(UErrorCode& status) { // } #endif - int32_t millisInDay; + double millisInDay; // We only use MILLISECONDS_IN_DAY if it has been set by the user. // This makes it possible for the caller to set the calendar to a @@ -3086,10 +3086,10 @@ UBool Calendar::getImmediatePreviousZoneTransition(UDate base, UDate *transition * reflects local zone wall time. * @stable ICU 2.0 */ -int32_t Calendar::computeMillisInDay() { +double Calendar::computeMillisInDay() { // Do the time portion of the conversion. - int32_t millisInDay = 0; + double millisInDay = 0; // Find the best set of fields specifying the time of day. There // are only two possibilities here; the HOUR_OF_DAY or the @@ -3131,7 +3131,7 @@ int32_t Calendar::computeMillisInDay() { * or range. * @stable ICU 2.0 */ -int32_t Calendar::computeZoneOffset(double millis, int32_t millisInDay, UErrorCode &ec) { +int32_t Calendar::computeZoneOffset(double millis, double millisInDay, UErrorCode &ec) { int32_t rawOffset, dstOffset; UDate wall = millis + millisInDay; BasicTimeZone* btz = getBasicTimeZone(); @@ -3178,7 +3178,7 @@ int32_t Calendar::computeZoneOffset(double millis, int32_t millisInDay, UErrorCo return rawOffset + dstOffset; } -int32_t Calendar::computeJulianDay() +int32_t Calendar::computeJulianDay() { // We want to see if any of the date fields is newer than the // JULIAN_DAY. If not, then we use JULIAN_DAY. If so, then we do @@ -3220,9 +3220,9 @@ int32_t Calendar::handleComputeJulianDay(UCalendarDateFields bestField) { internalSet(UCAL_EXTENDED_YEAR, year); } -#if defined (U_DEBUG_CAL) +#if defined (U_DEBUG_CAL) fprintf(stderr, "%s:%d: bestField= %s - y=%d\n", __FILE__, __LINE__, fldName(bestField), year); -#endif +#endif // Get the Julian day of the day BEFORE the start of this year. // If useMonth is true, get the day before the start of the month. @@ -3304,9 +3304,9 @@ int32_t Calendar::handleComputeJulianDay(UCalendarDateFields bestField) { date += ((monthLength - date) / 7 + dim + 1) * 7; } } else { -#if defined (U_DEBUG_CAL) +#if defined (U_DEBUG_CAL) fprintf(stderr, "%s:%d - bf= %s\n", __FILE__, __LINE__, fldName(bestField)); -#endif +#endif if(bestField == UCAL_WEEK_OF_YEAR) { // ------------------------------------- WOY ------------- if(!isSet(UCAL_YEAR_WOY) || // YWOY not set at all or @@ -3317,30 +3317,30 @@ int32_t Calendar::handleComputeJulianDay(UCalendarDateFields bestField) { int32_t woy = internalGet(bestField); int32_t nextJulianDay = handleComputeMonthStart(year+1, 0, FALSE); // jd of day before jan 1 - int32_t nextFirst = julianDayToDayOfWeek(nextJulianDay + 1) - firstDayOfWeek; + int32_t nextFirst = julianDayToDayOfWeek(nextJulianDay + 1) - firstDayOfWeek; if (nextFirst < 0) { // 0..6 ldow of Jan 1 nextFirst += 7; } if(woy==1) { // FIRST WEEK --------------------------------- -#if defined (U_DEBUG_CAL) - fprintf(stderr, "%s:%d - woy=%d, yp=%d, nj(%d)=%d, nf=%d", __FILE__, __LINE__, - internalGet(bestField), resolveFields(kYearPrecedence), year+1, +#if defined (U_DEBUG_CAL) + fprintf(stderr, "%s:%d - woy=%d, yp=%d, nj(%d)=%d, nf=%d", __FILE__, __LINE__, + internalGet(bestField), resolveFields(kYearPrecedence), year+1, nextJulianDay, nextFirst); fprintf(stderr, " next: %d DFW, min=%d \n", (7-nextFirst), getMinimalDaysInFirstWeek() ); -#endif +#endif // nextFirst is now the localized DOW of Jan 1 of y-woy+1 if((nextFirst > 0) && // Jan 1 starts on FDOW (7-nextFirst) >= getMinimalDaysInFirstWeek()) // or enough days in the week { // Jan 1 of (yearWoy+1) is in yearWoy+1 - recalculate JD to next year -#if defined (U_DEBUG_CAL) - fprintf(stderr, "%s:%d - was going to move JD from %d to %d [d%d]\n", __FILE__, __LINE__, +#if defined (U_DEBUG_CAL) + fprintf(stderr, "%s:%d - was going to move JD from %d to %d [d%d]\n", __FILE__, __LINE__, julianDay, nextJulianDay, (nextJulianDay-julianDay)); -#endif +#endif julianDay = nextJulianDay; // recalculate 'first' [0-based local dow of jan 1] @@ -3351,7 +3351,7 @@ int32_t Calendar::handleComputeJulianDay(UCalendarDateFields bestField) { // recalculate date. date = 1 - first + dowLocal; } - } else if(woy>=getLeastMaximum(bestField)) { + } else if(woy>=getLeastMaximum(bestField)) { // could be in the last week- find out if this JD would overstep int32_t testDate = date; if ((7 - first) < getMinimalDaysInFirstWeek()) { @@ -3361,7 +3361,7 @@ int32_t Calendar::handleComputeJulianDay(UCalendarDateFields bestField) { // Now adjust for the week number. testDate += 7 * (woy - 1); -#if defined (U_DEBUG_CAL) +#if defined (U_DEBUG_CAL) fprintf(stderr, "%s:%d - y=%d, y-1=%d doy%d, njd%d (C.F. %d)\n", __FILE__, __LINE__, year, year-1, testDate, julianDay+testDate, nextJulianDay); #endif @@ -3375,7 +3375,7 @@ int32_t Calendar::handleComputeJulianDay(UCalendarDateFields bestField) { } date = 1 - first + dowLocal; -#if defined (U_DEBUG_CAL) +#if defined (U_DEBUG_CAL) fprintf(stderr, "%s:%d - date now %d, jd%d, ywoy%d\n", __FILE__, __LINE__, date, julianDay, year-1); #endif @@ -3400,13 +3400,13 @@ int32_t Calendar::handleComputeJulianDay(UCalendarDateFields bestField) { } int32_t -Calendar::getDefaultMonthInYear(int32_t /*eyear*/) +Calendar::getDefaultMonthInYear(int32_t /*eyear*/) { return 0; } int32_t -Calendar::getDefaultDayInMonth(int32_t /*eyear*/, int32_t /*month*/) +Calendar::getDefaultDayInMonth(int32_t /*eyear*/, int32_t /*month*/) { return 1; } @@ -3436,13 +3436,13 @@ int32_t Calendar::getLocalDOW() int32_t Calendar::handleGetExtendedYearFromWeekFields(int32_t yearWoy, int32_t woy) { - // We have UCAL_YEAR_WOY and UCAL_WEEK_OF_YEAR - from those, determine + // We have UCAL_YEAR_WOY and UCAL_WEEK_OF_YEAR - from those, determine // what year we fall in, so that other code can set it properly. // (code borrowed from computeWeekFields and handleComputeJulianDay) //return yearWoy; // First, we need a reliable DOW. - UCalendarDateFields bestField = resolveFields(kDatePrecedence); // !! Note: if subclasses have a different table, they should override handleGetExtendedYearFromWeekFields + UCalendarDateFields bestField = resolveFields(kDatePrecedence); // !! Note: if subclasses have a different table, they should override handleGetExtendedYearFromWeekFields // Now, a local DOW int32_t dowLocal = getLocalDOW(); // 0..6 @@ -3475,9 +3475,9 @@ int32_t Calendar::handleGetExtendedYearFromWeekFields(int32_t yearWoy, int32_t w int32_t minDays = getMinimalDaysInFirstWeek(); UBool jan1InPrevYear = FALSE; // January 1st in the year of WOY is the 1st week? (i.e. first week is < minimal ) - //UBool nextJan1InPrevYear = FALSE; // January 1st of Year of WOY + 1 is in the first week? + //UBool nextJan1InPrevYear = FALSE; // January 1st of Year of WOY + 1 is in the first week? - if((7 - first) < minDays) { + if((7 - first) < minDays) { jan1InPrevYear = TRUE; } @@ -3500,8 +3500,8 @@ int32_t Calendar::handleGetExtendedYearFromWeekFields(int32_t yearWoy, int32_t w return yearWoy; // in this year } } - } else if(woy >= getLeastMaximum(bestField)) { - // we _might_ be in the last week.. + } else if(woy >= getLeastMaximum(bestField)) { + // we _might_ be in the last week.. int32_t jd = // Calculate JD of our target day: jan1Start + // JD of Jan 1 (7-first) + // days in the first week (Jan 1.. ) @@ -3538,7 +3538,7 @@ int32_t Calendar::handleGetExtendedYearFromWeekFields(int32_t yearWoy, int32_t w } //(internalGet(UCAL_DATE) <= (7-first)) /* && in minDow */ ) { - //within 1st week and in this month.. + //within 1st week and in this month.. //return yearWoy+1; return yearWoy; @@ -3671,7 +3671,7 @@ void Calendar::prepareGetActual(UCalendarDateFields field, UBool isMinimum, UErr dow += 7; } } -#if defined (U_DEBUG_CAL) +#if defined (U_DEBUG_CAL) fprintf(stderr, "prepareGetActualHelper(WOM/WOY) - dow=%d\n", dow); #endif set(UCAL_DAY_OF_WEEK, dow); @@ -3687,7 +3687,7 @@ void Calendar::prepareGetActual(UCalendarDateFields field, UBool isMinimum, UErr int32_t Calendar::getActualHelper(UCalendarDateFields field, int32_t startValue, int32_t endValue, UErrorCode &status) const { -#if defined (U_DEBUG_CAL) +#if defined (U_DEBUG_CAL) fprintf(stderr, "getActualHelper(%d,%d .. %d, %s)\n", field, startValue, endValue, u_errorName(status)); #endif if (startValue == endValue) { @@ -3723,7 +3723,7 @@ int32_t Calendar::getActualHelper(UCalendarDateFields field, int32_t startValue, int32_t result = startValue; if ((work->get(field, status) != startValue && field != UCAL_WEEK_OF_MONTH && delta > 0 ) || U_FAILURE(status)) { -#if defined (U_DEBUG_CAL) +#if defined (U_DEBUG_CAL) fprintf(stderr, "getActualHelper(fld %d) - got %d (not %d) - %s\n", field, work->get(field,status), startValue, u_errorName(status)); #endif } else { @@ -3740,7 +3740,7 @@ int32_t Calendar::getActualHelper(UCalendarDateFields field, int32_t startValue, } while (startValue != endValue); } delete work; -#if defined (U_DEBUG_CAL) +#if defined (U_DEBUG_CAL) fprintf(stderr, "getActualHelper(%d) = %d\n", field, result); #endif return result; @@ -3767,18 +3767,18 @@ Calendar::setWeekData(const Locale& desiredLocale, const char *type, UErrorCode& // Since week and weekend data is territory based instead of language based, // we may need to tweak the locale that we are using to try to get the appropriate // values, using the following logic: - // 1). If the locale has a language but no territory, use the territory as defined by + // 1). If the locale has a language but no territory, use the territory as defined by // the likely subtags. // 2). If the locale has a script designation then we ignore it, // then remove it ( i.e. "en_Latn_US" becomes "en_US" ) - + char minLocaleID[ULOC_FULLNAME_CAPACITY] = { 0 }; UErrorCode myStatus = U_ZERO_ERROR; uloc_minimizeSubtags(desiredLocale.getName(),minLocaleID,ULOC_FULLNAME_CAPACITY,&myStatus); Locale min = Locale::createFromName(minLocaleID); Locale useLocale; - if ( uprv_strlen(desiredLocale.getCountry()) == 0 || + if ( uprv_strlen(desiredLocale.getCountry()) == 0 || (uprv_strlen(desiredLocale.getScript()) > 0 && uprv_strlen(min.getScript()) == 0) ) { char maxLocaleID[ULOC_FULLNAME_CAPACITY] = { 0 }; myStatus = U_ZERO_ERROR; @@ -3788,8 +3788,8 @@ Calendar::setWeekData(const Locale& desiredLocale, const char *type, UErrorCode& } else { useLocale = Locale(desiredLocale); } - - /* The code here is somewhat of a hack, since week data and weekend data aren't really tied to + + /* The code here is somewhat of a hack, since week data and weekend data aren't really tied to a specific calendar, they aren't truly locale data. But this is the only place where valid and actual locale can be set, so we take a shot at it here by loading a representative resource from the calendar data. The code used to use the dateTimeElements resource to get first day @@ -3865,8 +3865,8 @@ Calendar::setWeekData(const Locale& desiredLocale, const char *type, UErrorCode& * and areFieldsSet. Callers should check isTimeSet and only * call this method if isTimeSet is false. */ -void -Calendar::updateTime(UErrorCode& status) +void +Calendar::updateTime(UErrorCode& status) { computeTime(status); if(U_FAILURE(status)) @@ -3875,14 +3875,14 @@ Calendar::updateTime(UErrorCode& status) // If we are lenient, we need to recompute the fields to normalize // the values. Also, if we haven't set all the fields yet (i.e., // in a newly-created object), we need to fill in the fields. [LIU] - if (isLenient() || ! fAreAllFieldsSet) + if (isLenient() || ! fAreAllFieldsSet) fAreFieldsSet = FALSE; fIsTimeSet = TRUE; fAreFieldsVirtuallySet = FALSE; } -Locale +Locale Calendar::getLocale(ULocDataLocaleType type, UErrorCode& status) const { U_LOCALE_BASED(locBased, *this); return locBased.getLocale(type, status); @@ -3945,4 +3945,3 @@ U_NAMESPACE_END //eof - diff --git a/icu4c/source/i18n/unicode/calendar.h b/icu4c/source/i18n/unicode/calendar.h index 6ebf539d97d..48021534b42 100644 --- a/icu4c/source/i18n/unicode/calendar.h +++ b/icu4c/source/i18n/unicode/calendar.h @@ -30,7 +30,7 @@ #include "unicode/utypes.h" /** - * \file + * \file * \brief C++ API: Calendar object */ #if !UCONFIG_NO_FORMATTING @@ -137,7 +137,7 @@ class BasicTimeZone; * Calendar resolves the time using the UTC offset before the transition by default. * In this example, 1:30 AM is interpreted as 1:30 AM standard time (non-exist), * so the final result will be 2:30 AM daylight time. - * + * *

On the date switching back to standard time, wall clock time is moved back one * hour at 2:00 AM. So wall clock time from 1:00 AM to 1:59 AM occur twice. In this * case, the ICU Calendar resolves the time using the UTC offset after the transition @@ -235,7 +235,7 @@ public: DST_OFFSET, // Example: 0 or U_MILLIS_PER_HOUR YEAR_WOY, // 'Y' Example: 1..big number - Year of Week of Year DOW_LOCAL, // 'e' Example: 1..7 - Day of Week / Localized - + EXTENDED_YEAR, JULIAN_DAY, MILLISECONDS_IN_DAY, @@ -914,7 +914,7 @@ public: * option for this. When the argument is neither UCAL_WALLTIME_FIRST * nor UCAL_WALLTIME_LAST, this method has no effect and will keep * the current setting. - * + * * @param option the behavior for handling repeating wall time, either * UCAL_WALLTIME_FIRST or UCAL_WALLTIME_LAST. * @see #getRepeatedWallTimeOption @@ -925,7 +925,7 @@ public: /** * Gets the behavior for handling wall time repeating multiple times * at negative time zone offset transitions. - * + * * @return the behavior for handling repeating wall time, either * UCAL_WALLTIME_FIRST or UCAL_WALLTIME_LAST. * @see #setRepeatedWallTimeOption @@ -946,12 +946,12 @@ public: *

* Note:This option is effective only when this calendar is lenient. * When the calendar is strict, such non-existing wall time will cause an error. - * + * * @param option the behavior for handling skipped wall time at positive time zone * offset transitions, one of UCAL_WALLTIME_FIRST, UCAL_WALLTIME_LAST and * UCAL_WALLTIME_NEXT_VALID. * @see #getSkippedWallTimeOption - * + * * @stable ICU 49 */ void setSkippedWallTimeOption(UCalendarWallTimeOption option); @@ -959,7 +959,7 @@ public: /** * Gets the behavior for handling skipped wall time at positive time zone offset * transitions. - * + * * @return the behavior for handling skipped wall time, one of * UCAL_WALLTIME_FIRST, UCAL_WALLTIME_LAST * and UCAL_WALLTIME_NEXT_VALID. @@ -1741,7 +1741,7 @@ protected: * reflects local zone wall time. * @internal */ - int32_t computeMillisInDay(); + double computeMillisInDay(); /** * This method can assume EXTENDED_YEAR has been set. @@ -1752,7 +1752,7 @@ protected: * when this function fails. * @internal */ - int32_t computeZoneOffset(double millis, int32_t millisInDay, UErrorCode &ec); + int32_t computeZoneOffset(double millis, double millisInDay, UErrorCode &ec); /** diff --git a/icu4c/source/test/intltest/calregts.cpp b/icu4c/source/test/intltest/calregts.cpp index a3c4afafa4f..8896b61c509 100644 --- a/icu4c/source/test/intltest/calregts.cpp +++ b/icu4c/source/test/intltest/calregts.cpp @@ -1,11 +1,11 @@ // © 2016 and later: Unicode, Inc. and others. // License & terms of use: http://www.unicode.org/copyright.html /******************************************************************** - * COPYRIGHT: + * COPYRIGHT: * Copyright (c) 1997-2016, International Business Machines Corporation * and others. All Rights Reserved. ********************************************************************/ - + #include "unicode/utypes.h" #if !UCONFIG_NO_FORMATTING @@ -33,7 +33,7 @@ const UDate CalendarRegressionTest::LATEST_SUPPORTED_MILLIS = 4503599627370 #define CASE(id,test) case id: name = #test; if (exec) { logln(#test "---"); logln((UnicodeString)""); test(); } break -void +void CalendarRegressionTest::runIndexedTest( int32_t index, UBool exec, const char* &name, char* /*par*/ ) { // if (exec) logln((UnicodeString)"TestSuite NumberFormatRegressionTest"); @@ -68,7 +68,7 @@ CalendarRegressionTest::runIndexedTest( int32_t index, UBool exec, const char* & CASE(27,test4145158); CASE(28,test4145983); CASE(29,test4147269); - + CASE(30,Test4149677); CASE(31,Test4162587); CASE(32,Test4165343); @@ -90,33 +90,34 @@ CalendarRegressionTest::runIndexedTest( int32_t index, UBool exec, const char* & CASE(48,TestT8596); CASE(49,Test9019); CASE(50,TestT9452); + CASE(51,TestT11632); default: name = ""; break; } } const char* CalendarRegressionTest::FIELD_NAME [] = { - "ERA", - "YEAR", - "MONTH", - "WEEK_OF_YEAR", - "WEEK_OF_MONTH", - "DAY_OF_MONTH", - "DAY_OF_YEAR", - "DAY_OF_WEEK", - "DAY_OF_WEEK_IN_MONTH", - "AM_PM", - "HOUR", - "HOUR_OF_DAY", - "MINUTE", - "SECOND", - "MILLISECOND", - "ZONE_OFFSET", + "ERA", + "YEAR", + "MONTH", + "WEEK_OF_YEAR", + "WEEK_OF_MONTH", + "DAY_OF_MONTH", + "DAY_OF_YEAR", + "DAY_OF_WEEK", + "DAY_OF_WEEK_IN_MONTH", + "AM_PM", + "HOUR", + "HOUR_OF_DAY", + "MINUTE", + "SECOND", + "MILLISECOND", + "ZONE_OFFSET", "DST_OFFSET", "YEAR_WOY", "DOW_LOCAL" }; -UBool +UBool CalendarRegressionTest::failure(UErrorCode status, const char* msg) { if(U_FAILURE(status)) { @@ -130,7 +131,7 @@ CalendarRegressionTest::failure(UErrorCode status, const char* msg) /* * bug 4100311 */ -void +void CalendarRegressionTest::test4100311() { UErrorCode status = U_ZERO_ERROR; @@ -223,14 +224,14 @@ CalendarRegressionTest::Test9019() failure(status, "->add(UCAL_MONTH,8)"); printdate(cal1.getAlias(), "cal1 (lenient) after adding 8 months:") ; printdate(cal2.getAlias(), "cal2 (expected date):") ; - + if(!cal1->equals(*cal2,status)) { errln("Error: cal1 != cal2.\n"); } failure(status, "equals"); } -void +void CalendarRegressionTest::printdate(GregorianCalendar *cal, const char *string) { UErrorCode status = U_ZERO_ERROR; @@ -247,8 +248,8 @@ CalendarRegressionTest::printdate(GregorianCalendar *cal, const char *string) /** * @bug 4031502 */ -void -CalendarRegressionTest::test4031502() +void +CalendarRegressionTest::test4031502() { // This bug actually occurs on Windows NT as well, and doesn't // require the host zone to be set; it can be set in Java. @@ -290,7 +291,7 @@ CalendarRegressionTest::test4031502() } delete cal; } - if (bad) + if (bad) errln("TimeZone problems with GC"); // delete [] ids; // TODO: bad APIs delete ids; @@ -299,7 +300,7 @@ CalendarRegressionTest::test4031502() /** * @bug 4035301 */ -void CalendarRegressionTest::test4035301() +void CalendarRegressionTest::test4035301() { UErrorCode status = U_ZERO_ERROR; GregorianCalendar *c = new GregorianCalendar(98, 8, 7,status); @@ -318,7 +319,7 @@ void CalendarRegressionTest::test4035301() /** * @bug 4040996 */ -void CalendarRegressionTest::test4040996() +void CalendarRegressionTest::test4040996() { int32_t count = 0; StringEnumeration* ids = TimeZone::createEnumeration(-8 * 60 * 60 * 1000); @@ -326,7 +327,7 @@ void CalendarRegressionTest::test4040996() dataerrln("Unable to create TimeZone enumeration."); return; } - UErrorCode status = U_ZERO_ERROR; + UErrorCode status = U_ZERO_ERROR; count = ids->count(status); (void)count; // Suppress set but not used warning. SimpleTimeZone *pdt = new SimpleTimeZone(-8 * 60 * 60 * 1000, *ids->snext(status)); @@ -342,7 +343,7 @@ void CalendarRegressionTest::test4040996() calendar->set(UCAL_SECOND, 30); logln(UnicodeString("MONTH: ") + calendar->get(UCAL_MONTH, status)); - logln(UnicodeString("DAY_OF_MONTH: ") + + logln(UnicodeString("DAY_OF_MONTH: ") + calendar->get(UCAL_DATE, status)); logln(UnicodeString("MINUTE: ") + calendar->get(UCAL_MINUTE, status)); logln(UnicodeString("SECOND: ") + calendar->get(UCAL_SECOND, status)); @@ -352,7 +353,7 @@ void CalendarRegressionTest::test4040996() //instead of the date it was set to. //This happens when adding MILLISECOND or MINUTE also logln(UnicodeString("MONTH: ") + calendar->get(UCAL_MONTH, status)); - logln(UnicodeString("DAY_OF_MONTH: ") + + logln(UnicodeString("DAY_OF_MONTH: ") + calendar->get(UCAL_DATE, status)); logln(UnicodeString("MINUTE: ") + calendar->get(UCAL_MINUTE, status)); logln(UnicodeString("SECOND: ") + calendar->get(UCAL_SECOND, status)); @@ -369,7 +370,7 @@ void CalendarRegressionTest::test4040996() /** * @bug 4051765 */ -void CalendarRegressionTest::test4051765() +void CalendarRegressionTest::test4051765() { UErrorCode status = U_ZERO_ERROR; Calendar *cal = Calendar::createInstance(status); @@ -400,12 +401,12 @@ void CalendarRegressionTest::test4059524() { logln("ERA: " + Calendar::get(Calendar::ERA)); logln("YEAR: " + Calendar::get(Calendar::YEAR)); logln("MONTH: " + Calendar::get(Calendar::MONTH)); - logln("WEEK_OF_YEAR: " + + logln("WEEK_OF_YEAR: " + Calendar::get(Calendar::WEEK_OF_YEAR)); - logln("WEEK_OF_MONTH: " + + logln("WEEK_OF_MONTH: " + Calendar::get(Calendar::WEEK_OF_MONTH)); logln("DATE: " + Calendar::get(Calendar::DATE)); - logln("DAY_OF_MONTH: " + + logln("DAY_OF_MONTH: " + Calendar::get(Calendar::DAY_OF_MONTH)); logln("DAY_OF_YEAR: " + Calendar::get(Calendar::DAY_OF_YEAR)); logln("DAY_OF_WEEK: " + Calendar::get(Calendar::DAY_OF_WEEK)); @@ -421,18 +422,18 @@ void CalendarRegressionTest::test4059524() { + (Calendar::get(Calendar::ZONE_OFFSET)/(60*60*1000))); logln("DST_OFFSET: " + (Calendar::get(Calendar::DST_OFFSET)/(60*60*1000))); - calendar = new GregorianCalendar(1997,3,10); - Calendar::getTime(); + calendar = new GregorianCalendar(1997,3,10); + Calendar::getTime(); logln("April 10, 1997"); logln("ERA: " + Calendar::get(Calendar::ERA)); logln("YEAR: " + Calendar::get(Calendar::YEAR)); logln("MONTH: " + Calendar::get(Calendar::MONTH)); - logln("WEEK_OF_YEAR: " + + logln("WEEK_OF_YEAR: " + Calendar::get(Calendar::WEEK_OF_YEAR)); - logln("WEEK_OF_MONTH: " + + logln("WEEK_OF_MONTH: " + Calendar::get(Calendar::WEEK_OF_MONTH)); logln("DATE: " + Calendar::get(Calendar::DATE)); - logln("DAY_OF_MONTH: " + + logln("DAY_OF_MONTH: " + Calendar::get(Calendar::DAY_OF_MONTH)); logln("DAY_OF_YEAR: " + Calendar::get(Calendar::DAY_OF_YEAR)); logln("DAY_OF_WEEK: " + Calendar::get(Calendar::DAY_OF_WEEK)); @@ -461,7 +462,7 @@ void CalendarRegressionTest::test4059654() { delete gc; return; } - + gc->set(1997, 3, 1, 15, 16, 17); // April 1, 1997 gc->set(UCAL_HOUR, 0); @@ -482,11 +483,11 @@ void CalendarRegressionTest::test4059654() { /** * @bug 4061476 */ -void CalendarRegressionTest::test4061476() +void CalendarRegressionTest::test4061476() { UErrorCode status = U_ZERO_ERROR; SimpleDateFormat *fmt = new SimpleDateFormat(UnicodeString("ddMMMyy"), Locale::getUK(),status); - Calendar *cal = Calendar::createInstance(TimeZone::createTimeZone("GMT"), + Calendar *cal = Calendar::createInstance(TimeZone::createTimeZone("GMT"), Locale::getUK(),status); if(U_FAILURE(status)) { dataerrln("Error creating Calendar: %s", u_errorName(status)); @@ -515,7 +516,7 @@ void CalendarRegressionTest::test4061476() /** * @bug 4070502 */ -void CalendarRegressionTest::test4070502() +void CalendarRegressionTest::test4070502() { UErrorCode status = U_ZERO_ERROR; Calendar *cal = new GregorianCalendar(status); @@ -540,12 +541,12 @@ void CalendarRegressionTest::test4070502() *

* @param date The date to start from */ -UDate -CalendarRegressionTest::getAssociatedDate(UDate d, UErrorCode& status) +UDate +CalendarRegressionTest::getAssociatedDate(UDate d, UErrorCode& status) { GregorianCalendar *cal = new GregorianCalendar(status); cal->setTime(d,status); - //cal.add(field, amount); //<-- PROBLEM SEEN WITH field = DATE,MONTH + //cal.add(field, amount); //<-- PROBLEM SEEN WITH field = DATE,MONTH // cal.getTime(); // <--- REMOVE THIS TO SEE BUG for (;;) { int32_t wd = cal->get(UCAL_DAY_OF_WEEK, status); @@ -556,7 +557,7 @@ CalendarRegressionTest::getAssociatedDate(UDate d, UErrorCode& status) else break; } - + UDate dd = cal->getTime(status); delete cal; return dd; @@ -565,13 +566,13 @@ CalendarRegressionTest::getAssociatedDate(UDate d, UErrorCode& status) /** * @bug 4071197 */ -void CalendarRegressionTest::test4071197() +void CalendarRegressionTest::test4071197() { dowTest(FALSE); dowTest(TRUE); } -void CalendarRegressionTest::dowTest(UBool lenient) +void CalendarRegressionTest::dowTest(UBool lenient) { UErrorCode status = U_ZERO_ERROR; GregorianCalendar *cal = new GregorianCalendar(status); @@ -590,9 +591,9 @@ void CalendarRegressionTest::dowTest(UBool lenient) //logln(cal.getTime().toString()); if (min != UCAL_SUNDAY || max != UCAL_SATURDAY) errln("FAIL: Min/max bad"); - if (dow < min || dow > max) + if (dow < min || dow > max) errln("FAIL: Day of week %d out of range [%d,%d]\n", dow, min, max); - if (dow != UCAL_SUNDAY) + if (dow != UCAL_SUNDAY) errln(UnicodeString("FAIL: Day of week should be SUNDAY Got ") + dow); if(U_FAILURE(status)) { @@ -621,14 +622,14 @@ void CalendarRegressionTest::dowTest(UBool lenient) errln("Error getting actual minimum: %s", u_errorName(status)); return; } - + delete cal; } /** * @bug 4071385 */ -void CalendarRegressionTest::test4071385() +void CalendarRegressionTest::test4071385() { UErrorCode status = U_ZERO_ERROR; Calendar *cal = Calendar::createInstance(status); @@ -649,7 +650,7 @@ void CalendarRegressionTest::test4071385() /** * @bug 4073929 */ -void CalendarRegressionTest::test4073929() +void CalendarRegressionTest::test4073929() { UErrorCode status = U_ZERO_ERROR; GregorianCalendar *foo1 = new GregorianCalendar(1997, 8, 27,status); @@ -700,7 +701,7 @@ void CalendarRegressionTest::test4073929() /** * @bug 4083167 */ -void CalendarRegressionTest::test4083167() +void CalendarRegressionTest::test4083167() { UErrorCode status = U_ZERO_ERROR; TimeZone *saveZone = TimeZone::createDefault(); @@ -720,7 +721,7 @@ void CalendarRegressionTest::test4083167() int32_t sec = cal->get(UCAL_SECOND, status); int32_t msec = cal->get(UCAL_MILLISECOND, status); double firstMillisInDay = hr * 3600000 + min * 60000 + sec * 1000 + msec; - + //logln("Current time: " + firstDate.toString()); for (int32_t validity=0; validity<30; validity++) { @@ -731,7 +732,7 @@ void CalendarRegressionTest::test4083167() sec = cal->get(UCAL_SECOND, status); msec = cal->get(UCAL_MILLISECOND, status); double millisInDay = hr * 3600000.0 + min * 60000.0 + sec * 1000.0 + msec; - if (firstMillisInDay != millisInDay) + if (firstMillisInDay != millisInDay) errln(UnicodeString("Day has shifted ") + lastDate); } //} @@ -747,18 +748,18 @@ void CalendarRegressionTest::test4083167() /** * @bug 4086724 */ -void CalendarRegressionTest::test4086724() +void CalendarRegressionTest::test4086724() { UErrorCode status = U_ZERO_ERROR; SimpleDateFormat *date; TimeZone *saveZone = TimeZone::createDefault(); Locale saveLocale = Locale::getDefault(); //try { - Locale::setDefault(Locale::getUK(),status); + Locale::setDefault(Locale::getUK(),status); TimeZone *newZone = TimeZone::createTimeZone("GMT"); TimeZone::setDefault(*newZone); - date = new SimpleDateFormat(UnicodeString("dd MMM yyy (zzzz) 'is in week' ww"),status); - Calendar *cal = Calendar::createInstance(status); + date = new SimpleDateFormat(UnicodeString("dd MMM yyy (zzzz) 'is in week' ww"),status); + Calendar *cal = Calendar::createInstance(status); if(U_FAILURE(status)) { dataerrln("Error creating Calendar: %s", u_errorName(status)); delete cal; @@ -766,20 +767,20 @@ void CalendarRegressionTest::test4086724() delete date; return; } - cal->set(1997,UCAL_SEPTEMBER,30); - UDate now = cal->getTime(status); + cal->set(1997,UCAL_SEPTEMBER,30); + UDate now = cal->getTime(status); UnicodeString temp; FieldPosition pos(FieldPosition::DONT_CARE); - logln(date->format(now, temp, pos)); - cal->set(1997,UCAL_JANUARY,1); - now=cal->getTime(status); - logln(date->format(now,temp, pos)); - cal->set(1997,UCAL_JANUARY,8); - now=cal->getTime(status); - logln(date->format(now,temp, pos)); - cal->set(1996,UCAL_DECEMBER,31); - now=cal->getTime(status); - logln(date->format(now,temp, pos)); + logln(date->format(now, temp, pos)); + cal->set(1997,UCAL_JANUARY,1); + now=cal->getTime(status); + logln(date->format(now,temp, pos)); + cal->set(1997,UCAL_JANUARY,8); + now=cal->getTime(status); + logln(date->format(now,temp, pos)); + cal->set(1996,UCAL_DECEMBER,31); + now=cal->getTime(status); + logln(date->format(now,temp, pos)); //} //finally { Locale::setDefault(saveLocale,status); @@ -798,35 +799,35 @@ delete saveZone; */ void CalendarRegressionTest::test4092362() { UErrorCode status = U_ZERO_ERROR; - GregorianCalendar *cal1 = new GregorianCalendar(1997, 10, 11, 10, 20, 40,status); + GregorianCalendar *cal1 = new GregorianCalendar(1997, 10, 11, 10, 20, 40,status); if (U_FAILURE(status)) { dataerrln("Fail new GregorianCalendar: %s", u_errorName(status)); delete cal1; return; } - /*cal1.set( Calendar::YEAR, 1997 ); - cal1.set( Calendar::MONTH, 10 ); - cal1.set( Calendar::DATE, 11 ); - cal1.set( Calendar::HOUR, 10 ); - cal1.set( Calendar::MINUTE, 20 ); + /*cal1.set( Calendar::YEAR, 1997 ); + cal1.set( Calendar::MONTH, 10 ); + cal1.set( Calendar::DATE, 11 ); + cal1.set( Calendar::HOUR, 10 ); + cal1.set( Calendar::MINUTE, 20 ); cal1.set( Calendar::SECOND, 40 ); */ - logln( UnicodeString(" Cal1 = ") + cal1->getTime(status) ); - logln( UnicodeString(" Cal1 time in ms = ") + cal1->get(UCAL_MILLISECOND,status) ); + logln( UnicodeString(" Cal1 = ") + cal1->getTime(status) ); + logln( UnicodeString(" Cal1 time in ms = ") + cal1->get(UCAL_MILLISECOND,status) ); for (int32_t k = 0; k < 100 ; k++) ; - GregorianCalendar *cal2 = new GregorianCalendar(1997, 10, 11, 10, 20, 40,status); - /*cal2.set( Calendar::YEAR, 1997 ); - cal2.set( Calendar::MONTH, 10 ); - cal2.set( Calendar::DATE, 11 ); - cal2.set( Calendar::HOUR, 10 ); - cal2.set( Calendar::MINUTE, 20 ); + GregorianCalendar *cal2 = new GregorianCalendar(1997, 10, 11, 10, 20, 40,status); + /*cal2.set( Calendar::YEAR, 1997 ); + cal2.set( Calendar::MONTH, 10 ); + cal2.set( Calendar::DATE, 11 ); + cal2.set( Calendar::HOUR, 10 ); + cal2.set( Calendar::MINUTE, 20 ); cal2.set( Calendar::SECOND, 40 ); */ - logln( UnicodeString(" Cal2 = ") + cal2->getTime(status) ); - logln( UnicodeString(" Cal2 time in ms = ") + cal2->get(UCAL_MILLISECOND,status) ); - if( *cal1 != *cal2 ) + logln( UnicodeString(" Cal2 = ") + cal2->getTime(status) ); + logln( UnicodeString(" Cal2 time in ms = ") + cal2->get(UCAL_MILLISECOND,status) ); + if( *cal1 != *cal2 ) errln("Fail: Milliseconds randomized"); delete cal1; @@ -836,7 +837,7 @@ void CalendarRegressionTest::test4092362() { /** * @bug 4095407 */ -void CalendarRegressionTest::test4095407() +void CalendarRegressionTest::test4095407() { UErrorCode status = U_ZERO_ERROR; GregorianCalendar *a = new GregorianCalendar(1997,UCAL_NOVEMBER, 13,status); @@ -855,13 +856,13 @@ void CalendarRegressionTest::test4095407() /** * @bug 4096231 */ -void CalendarRegressionTest::test4096231() +void CalendarRegressionTest::test4096231() { UErrorCode status = U_ZERO_ERROR; TimeZone *GMT = TimeZone::createTimeZone("GMT"); TimeZone *PST = TimeZone::createTimeZone("PST"); int32_t sec = 0, min = 0, hr = 0, day = 1, month = 10, year = 1997; - + Calendar *cal1 = new GregorianCalendar(*PST,status); if (U_FAILURE(status)) { dataerrln("Failure new GregorianCalendar: %s", u_errorName(status)); @@ -872,7 +873,7 @@ void CalendarRegressionTest::test4096231() } cal1->setTime(880698639000.0,status); // Issue 1: Changing the timezone doesn't change the - // represented time. The old API, pre 1.2.2a requires + // represented time. The old API, pre 1.2.2a requires // setTime to be called in order to update the time fields after the time // zone has been set. int32_t h1,h2; @@ -925,13 +926,13 @@ void CalendarRegressionTest::test4096231() /** * @bug 4096539 */ -void CalendarRegressionTest::test4096539() +void CalendarRegressionTest::test4096539() { UErrorCode status = U_ZERO_ERROR; int32_t y [] = {31,28,31,30,31,30,31,31,30,31,30,31}; for (int32_t x=0;x<12;x++) { - GregorianCalendar *gc = new + GregorianCalendar *gc = new GregorianCalendar(1997,x,y[x], status); if (U_FAILURE(status)) { dataerrln("Fail new GregorianCalendar: %s", u_errorName(status)); @@ -952,13 +953,13 @@ void CalendarRegressionTest::test4096539() errln(UnicodeString("Fail: Want ") + m + " Got " + m2); delete gc; } - + } /** * @bug 4100311 */ -void CalendarRegressionTest::test41003112() +void CalendarRegressionTest::test41003112() { UErrorCode status = U_ZERO_ERROR; GregorianCalendar *cal = (GregorianCalendar*)Calendar::createInstance(status); @@ -979,51 +980,51 @@ void CalendarRegressionTest::test41003112() /** * @bug 4103271 */ -void CalendarRegressionTest::test4103271() +void CalendarRegressionTest::test4103271() { UErrorCode status = U_ZERO_ERROR; - SimpleDateFormat sdf(status); - int32_t numYears=40, startYear=1997, numDays=15; - UnicodeString output, testDesc, str, str2; - GregorianCalendar *testCal = (GregorianCalendar*)Calendar::createInstance(status); + SimpleDateFormat sdf(status); + int32_t numYears=40, startYear=1997, numDays=15; + UnicodeString output, testDesc, str, str2; + GregorianCalendar *testCal = (GregorianCalendar*)Calendar::createInstance(status); if(U_FAILURE(status)) { dataerrln("Error creating calendar: %s", u_errorName(status)); delete testCal; return; } testCal->clear(); - sdf.adoptCalendar(testCal); - sdf.applyPattern("EEE dd MMM yyyy 'WOY'ww'-'YYYY 'DOY'DDD"); + sdf.adoptCalendar(testCal); + sdf.applyPattern("EEE dd MMM yyyy 'WOY'ww'-'YYYY 'DOY'DDD"); UBool fail = FALSE; - for (int32_t firstDay=1; firstDay<=2; firstDay++) { - for (int32_t minDays=1; minDays<=7; minDays++) { - testCal->setMinimalDaysInFirstWeek((uint8_t)minDays); - testCal->setFirstDayOfWeek((UCalendarDaysOfWeek)firstDay); - testDesc = (UnicodeString("Test") + firstDay + minDays); + for (int32_t firstDay=1; firstDay<=2; firstDay++) { + for (int32_t minDays=1; minDays<=7; minDays++) { + testCal->setMinimalDaysInFirstWeek((uint8_t)minDays); + testCal->setFirstDayOfWeek((UCalendarDaysOfWeek)firstDay); + testDesc = (UnicodeString("Test") + firstDay + minDays); logln(testDesc + " => 1st day of week=" + firstDay + ", minimum days in first week=" + - minDays); - for (int32_t j=startYear; j<=startYear+numYears; j++) { - testCal->set(j,11,25); - for(int32_t i=0; iadd(UCAL_DATE,1,status); - UnicodeString calWOY; + minDays); + for (int32_t j=startYear; j<=startYear+numYears; j++) { + testCal->set(j,11,25); + for(int32_t i=0; iadd(UCAL_DATE,1,status); + UnicodeString calWOY; int32_t actWOY = testCal->get(UCAL_WEEK_OF_YEAR,status); if (actWOY < 1 || actWOY > 53) { - UDate d = testCal->getTime(status); + UDate d = testCal->getTime(status); //calWOY = String.valueOf(actWOY); UnicodeString temp; FieldPosition pos(FieldPosition::DONT_CARE); - output = testDesc + " - " + sdf.format(d,temp,pos) + "\t"; - output = output + "\t" + actWOY; - logln(output); + output = testDesc + " - " + sdf.format(d,temp,pos) + "\t"; + output = output + "\t" + actWOY; + logln(output); fail = TRUE; } - } - } - } - } + } + } + } + } int32_t DATA [] = { 3, 52, 52, 52, 52, 52, 52, 52, @@ -1049,7 +1050,7 @@ void CalendarRegressionTest::test4103271() fail = TRUE; } logln(""); - + // Now compute the time from the fields, and make sure we // get the same answer back. This is a round-trip test. UDate save = testCal->getTime(status); @@ -1084,7 +1085,7 @@ void CalendarRegressionTest::test4103271() makeDate(1998, UCAL_DECEMBER, 31), makeDate(1999, UCAL_JANUARY, 1) }; - + testCal->setMinimalDaysInFirstWeek(3); testCal->setFirstDayOfWeek(UCAL_SUNDAY); int32_t i = 0; @@ -1183,9 +1184,9 @@ void CalendarRegressionTest::test4103271() UDate after = ADDROLL_date[i+1]; testCal->setTime(before,status); - if (ADDROLL_bool[i/2]) + if (ADDROLL_bool[i/2]) testCal->add(UCAL_WEEK_OF_YEAR, amount,status); - else + else testCal->roll(UCAL_WEEK_OF_YEAR, amount,status); UDate got = testCal->getTime(status); str.remove(); @@ -1206,9 +1207,9 @@ void CalendarRegressionTest::test4103271() else logln(" ok"); testCal->setTime(after,status); - if (ADDROLL_bool[i/2]) + if (ADDROLL_bool[i/2]) testCal->add(UCAL_WEEK_OF_YEAR, -amount,status); - else + else testCal->roll(UCAL_WEEK_OF_YEAR, -amount,status); got = testCal->getTime(status); str.remove(); @@ -1222,14 +1223,14 @@ void CalendarRegressionTest::test4103271() } else logln(" ok"); } - if (fail) + if (fail) errln("Fail: Week of year misbehaving"); -} +} /** * @bug 4106136 */ -void CalendarRegressionTest::test4106136() +void CalendarRegressionTest::test4106136() { UErrorCode status = U_ZERO_ERROR; Locale saveLocale = Locale::getDefault(); @@ -1260,10 +1261,10 @@ void CalendarRegressionTest::test4106136() /** * @bug 4108764 */ -void CalendarRegressionTest::test4108764() +void CalendarRegressionTest::test4108764() { UErrorCode status = U_ZERO_ERROR; - Calendar *cal = Calendar::createInstance(status); + Calendar *cal = Calendar::createInstance(status); if(U_FAILURE(status)) { dataerrln("Error creating calendar %s", u_errorName(status)); delete cal; @@ -1277,29 +1278,29 @@ void CalendarRegressionTest::test4108764() cal->setTime(d11,status); - cal->clear( UCAL_MINUTE ); - logln(UnicodeString("") + cal->getTime(status)); + cal->clear( UCAL_MINUTE ); + logln(UnicodeString("") + cal->getTime(status)); if (cal->getTime(status) != d01) errln("Fail: clear(MINUTE) broken"); - cal->set( UCAL_SECOND, 0 ); - logln(UnicodeString("") + cal->getTime(status)); + cal->set( UCAL_SECOND, 0 ); + logln(UnicodeString("") + cal->getTime(status)); if (cal->getTime(status) != d00) errln("Fail: set(SECOND, 0) broken"); cal->setTime(d11,status); - cal->set( UCAL_SECOND, 0 ); - logln(UnicodeString("") + cal->getTime(status)); + cal->set( UCAL_SECOND, 0 ); + logln(UnicodeString("") + cal->getTime(status)); if (cal->getTime(status) != d10) errln("Fail: set(SECOND, 0) broken #2"); - cal->clear( UCAL_MINUTE ); - logln(UnicodeString("") + cal->getTime(status)); + cal->clear( UCAL_MINUTE ); + logln(UnicodeString("") + cal->getTime(status)); if (cal->getTime(status) != d00) errln("Fail: clear(MINUTE) broken #2"); cal->clear(); - logln(UnicodeString("") + cal->getTime(status)); + logln(UnicodeString("") + cal->getTime(status)); if (cal->getTime(status) != epoch) errln(UnicodeString("Fail: clear() broken Want ") + epoch); @@ -1309,7 +1310,7 @@ void CalendarRegressionTest::test4108764() /** * @bug 4114578 */ -void CalendarRegressionTest::test4114578() +void CalendarRegressionTest::test4114578() { UErrorCode status = U_ZERO_ERROR; double ONE_HOUR = 60*60*1000; @@ -1324,7 +1325,7 @@ void CalendarRegressionTest::test4114578() UDate cease = makeDate(1998, UCAL_OCTOBER, 25, 0, 0) + 2*ONE_HOUR; UBool fail = FALSE; - + const int32_t ADD = 1; const int32_t ROLL = 2; @@ -1344,7 +1345,7 @@ void CalendarRegressionTest::test4114578() UDate date = DATA[i]; int32_t amt = (int32_t) DATA[i+2]; double expectedChange = DATA[i+3]; - + log(UnicodeString("") + date); cal->setTime(date,status); @@ -1378,7 +1379,7 @@ void CalendarRegressionTest::test4114578() * @bug 4118384 * Make sure maximum for HOUR field is 11, not 12. */ -void CalendarRegressionTest::test4118384() +void CalendarRegressionTest::test4118384() { UErrorCode status = U_ZERO_ERROR; Calendar *cal = Calendar::createInstance(status); @@ -1436,7 +1437,7 @@ void CalendarRegressionTest::test4118384() * @bug 4125881 * Check isLeapYear for BC years. */ -void CalendarRegressionTest::test4125881() +void CalendarRegressionTest::test4125881() { UErrorCode status = U_ZERO_ERROR; GregorianCalendar *cal = (GregorianCalendar*) Calendar::createInstance(status); @@ -1505,7 +1506,7 @@ void CalendarRegressionTest::test4125892() { * @bug 4141665 * GregorianCalendar::equals() ignores cutover date */ -void CalendarRegressionTest::test4141665() +void CalendarRegressionTest::test4141665() { UErrorCode status = U_ZERO_ERROR; GregorianCalendar *cal = new GregorianCalendar(status); @@ -1534,7 +1535,7 @@ void CalendarRegressionTest::test4141665() * Bug states that ArrayIndexOutOfBoundsException is thrown by GregorianCalendar::roll() * when IllegalArgumentException should be. */ -void CalendarRegressionTest::test4142933() +void CalendarRegressionTest::test4142933() { UErrorCode status = U_ZERO_ERROR; GregorianCalendar *calendar = new GregorianCalendar(status); @@ -1555,7 +1556,7 @@ void CalendarRegressionTest::test4142933() //catch (Exception e) { //errln("Test failed. Unexpected exception is thrown: " + e); //e.printStackTrace(); - //} + //} delete calendar; } @@ -1568,7 +1569,7 @@ void CalendarRegressionTest::test4142933() * report to therefore only check the behavior of a calendar with a zero raw * offset zone. */ -void CalendarRegressionTest::test4145158() +void CalendarRegressionTest::test4145158() { UErrorCode status = U_ZERO_ERROR; GregorianCalendar *calendar = new GregorianCalendar(status); @@ -1587,7 +1588,7 @@ void CalendarRegressionTest::test4145158() calendar->setTime(makeDate(INT32_MAX),status); int32_t year2 = calendar->get(UCAL_YEAR,status); int32_t era2 = calendar->get(UCAL_ERA,status); - + if (year1 == year2 && era1 == era2) { errln("Fail: Long.MIN_VALUE or Long.MAX_VALUE wrapping around"); } @@ -1601,13 +1602,13 @@ void CalendarRegressionTest::test4145158() */ // {sfb} this is not directly applicable in C++, since all // possible doubles are not representable by our Calendar. -// In Java, all longs are representable. +// In Java, all longs are representable. // We can determine limits programmatically // Using DBL_MAX is a bit of a hack, since for large doubles // Calendar gets squirrely and doesn't behave in any sort // of linear fashion (ie years jump around, up/down, etc) for a // small change in millis. -void CalendarRegressionTest::test4145983() +void CalendarRegressionTest::test4145983() { UErrorCode status = U_ZERO_ERROR; GregorianCalendar *calendar = new GregorianCalendar(status); @@ -1638,7 +1639,7 @@ void CalendarRegressionTest::test4145983() * report test was written. In reality the bug is restricted to the DAY_OF_YEAR * field. - liu 6/29/98 */ -void CalendarRegressionTest::test4147269() +void CalendarRegressionTest::test4147269() { UErrorCode status = U_ZERO_ERROR; GregorianCalendar *calendar = new GregorianCalendar(status); @@ -1656,7 +1657,7 @@ void CalendarRegressionTest::test4147269() // use getActualMaximum(), since that's too costly. int32_t max = calendar->getMaximum((UCalendarDateFields)field); int32_t value = max+1; - calendar->set((UCalendarDateFields)field, value); + calendar->set((UCalendarDateFields)field, value); //try { calendar->getTime(status); // Force time computation // We expect an exception to be thrown. If we fall through @@ -1666,7 +1667,7 @@ void CalendarRegressionTest::test4147269() ", date before: " + date + ", date after: " + calendar->getTime(status) + ", value: " + value + " (max = " + max +")"); - //} catch (IllegalArgumentException e) {} + //} catch (IllegalArgumentException e) {} } delete calendar; @@ -1678,15 +1679,15 @@ void CalendarRegressionTest::test4147269() * doesn't behave as a pure Julian calendar. * CANNOT REPRODUCE THIS BUG */ -void -CalendarRegressionTest::Test4149677() +void +CalendarRegressionTest::Test4149677() { UErrorCode status = U_ZERO_ERROR; - TimeZone *zones [] = { + TimeZone *zones [] = { TimeZone::createTimeZone("GMT"), TimeZone::createTimeZone("PST"), - TimeZone::createTimeZone("EAT") + TimeZone::createTimeZone("EAT") }; if(U_FAILURE(status)) { errln("Couldn't create zones"); @@ -1719,7 +1720,7 @@ CalendarRegressionTest::Test4149677() if(U_FAILURE(status)) errln("setGregorianChange failed"); // to obtain a pure Julian calendar - + UBool is100Leap = calendar->isLeapYear(100); if (!is100Leap) { UnicodeString temp; @@ -1729,7 +1730,7 @@ CalendarRegressionTest::Test4149677() } delete calendar; } - + // no need for cleanup- zones were adopted } @@ -1738,22 +1739,22 @@ CalendarRegressionTest::Test4149677() * Calendar and Date HOUR broken. If HOUR is out-of-range, Calendar * and Date classes will misbehave. */ -void -CalendarRegressionTest::Test4162587() +void +CalendarRegressionTest::Test4162587() { UErrorCode status = U_ZERO_ERROR; TimeZone *savedef = TimeZone::createDefault(); TimeZone *tz = TimeZone::createTimeZone("PST"); //TimeZone::adoptDefault(tz); TimeZone::setDefault(*tz); - + GregorianCalendar *cal = new GregorianCalendar(tz, status); if(U_FAILURE(status)) { dataerrln("Couldn't create calendar.: %s", u_errorName(status)); return; } UDate d0, dPlus, dMinus; - + for(int32_t i=0; i<5; ++i) { if (i>0) logln("---"); @@ -1795,8 +1796,8 @@ CalendarRegressionTest::Test4162587() * @bug 4165343 * Adding 12 months behaves differently from adding 1 year */ -void -CalendarRegressionTest::Test4165343() +void +CalendarRegressionTest::Test4165343() { UErrorCode status = U_ZERO_ERROR; GregorianCalendar *calendar = new GregorianCalendar(1996, UCAL_FEBRUARY, 29, status); @@ -1808,7 +1809,7 @@ CalendarRegressionTest::Test4165343() if(U_FAILURE(status)) errln("Couldn't getTime (1)"); logln(UnicodeString("init date: ") + start); - calendar->add(UCAL_MONTH, 12, status); + calendar->add(UCAL_MONTH, 12, status); if(U_FAILURE(status)) errln("Couldn't add(MONTH, 12)"); UDate date1 = calendar->getTime(status); @@ -1837,8 +1838,8 @@ CalendarRegressionTest::Test4165343() * @bug 4166109 * GregorianCalendar.getActualMaximum() does not account for first day of week. */ -void -CalendarRegressionTest::Test4166109() +void +CalendarRegressionTest::Test4166109() { /* Test month: * @@ -1862,7 +1863,7 @@ CalendarRegressionTest::Test4166109() calendar->set(1998, UCAL_MARCH, 1); calendar->setMinimalDaysInFirstWeek(1); logln(UnicodeString("Date: ") + calendar->getTime(status)); // 888817448000 - + int32_t firstInMonth = calendar->get(UCAL_DATE, status); if(U_FAILURE(status)) errln("get(D_O_M) failed"); @@ -1892,8 +1893,8 @@ CalendarRegressionTest::Test4166109() * @bug 4167060 * Calendar.getActualMaximum(YEAR) works wrong. */ -void -CalendarRegressionTest::Test4167060() +void +CalendarRegressionTest::Test4167060() { UErrorCode status = U_ZERO_ERROR; UCalendarDateFields field = UCAL_YEAR; @@ -1924,7 +1925,7 @@ CalendarRegressionTest::Test4167060() GregorianCalendar *calendar = calendars[j]; if (k == 1) { calendar->setGregorianChange(EARLIEST_SUPPORTED_MILLIS, status); - } + } else if (k == 2) { calendar->setGregorianChange(LATEST_SUPPORTED_MILLIS, status); } @@ -1963,7 +1964,7 @@ CalendarRegressionTest::Test4167060() " => " + format->format(dateAfter, temp)); if (valid && newYear != years[i]) { errln(UnicodeString(" FAIL: ") + newYear + " should be valid; date, month and time shouldn't change"); - } + } // {sfb} this next line is a hack, but it should work since if a // double has an exponent, adding 1 should not yield the same double else if (!valid && /*newYear == years[i]*/ dateAfter + 1.0 == dateAfter) { @@ -2206,9 +2207,9 @@ void CalendarRegressionTest::TestJ81() { } status = U_ZERO_ERROR; int32_t amount = DATA[i].amount * (sign==MINUS?-1:1); - UDate date = cutover + + UDate date = cutover + (sign==PLUS ? DATA[i].before : DATA[i].after); - UDate expected = cutover + + UDate expected = cutover + (sign==PLUS ? DATA[i].after : DATA[i].before); cal.setTime(date, status); if (U_FAILURE(status)) { @@ -2232,18 +2233,18 @@ void CalendarRegressionTest::TestJ81() { continue; } if (result == expected) { - logln((UnicodeString)"Ok: {" + + logln((UnicodeString)"Ok: {" + fmt.format(date, temp.remove()) + "}(" + date/ONE_DAY + - (action==ADD?") add ":") roll ") + + (action==ADD?") add ":") roll ") + amount + " " + FIELD_NAME[DATA[i].field] + " -> {" + fmt.format(result, temp2.remove()) + - "}(" + result/ONE_DAY + ")"); + "}(" + result/ONE_DAY + ")"); } else { - errln((UnicodeString)"FAIL: {" + + errln((UnicodeString)"FAIL: {" + fmt.format(date, temp.remove()) + "}(" + date/ONE_DAY + - (action==ADD?") add ":") roll ") + + (action==ADD?") add ":") roll ") + amount + " " + FIELD_NAME[DATA[i].field] + " -> {" + fmt.format(result, temp2.remove()) + "}(" + result/ONE_DAY + "), expect {" + @@ -2254,7 +2255,7 @@ void CalendarRegressionTest::TestJ81() { } } } - + /** * Test fieldDifference(). */ @@ -2306,11 +2307,11 @@ void CalendarRegressionTest::TestJ438(void) { if (failure(ec, "fieldDifference")) break; - { + { Calendar *cal2 = cal.clone(); UErrorCode ec2 = U_ZERO_ERROR; - cal2->setTime(date1, ec2); + cal2->setTime(date1, ec2); int32_t dy2 = cal2->fieldDifference(date2, Calendar::YEAR, ec2); int32_t dm2 = cal2->fieldDifference(date2, Calendar::MONTH, ec2); @@ -2574,13 +2575,13 @@ void CalendarRegressionTest::TestWeekShift() { // In pass one, change the first day of week so that the weeks // shift in August 2001. In pass two, change the minimal days // in the first week so that the weeks shift in August 2001. - // August 2001 + // August 2001 // Su Mo Tu We Th Fr Sa // 1 2 3 4 // 5 6 7 8 9 10 11 // 12 13 14 15 16 17 18 // 19 20 21 22 23 24 25 - // 26 27 28 29 30 31 + // 26 27 28 29 30 31 for (int32_t pass=0; pass<2; ++pass) { if (pass==0) { cal.setFirstDayOfWeek(UCAL_WEDNESDAY); @@ -2659,7 +2660,7 @@ void CalendarRegressionTest::TestTimeZoneTransitionAdd() { errln("FAIL: StringEnumeration::unext"); break; } - + TimeZone *t = TimeZone::createTimeZone(id); if (t == NULL) { errln("FAIL: TimeZone::createTimeZone"); @@ -2713,7 +2714,7 @@ CalendarRegressionTest::makeDate(int32_t y, int32_t m, int32_t d, cal->clear(); cal->set(UCAL_YEAR, y); - + if(m != 0) cal->set(UCAL_MONTH, m); if(d != 0) cal->set(UCAL_DATE, d); if(hr != 0) cal->set(UCAL_HOUR, hr); @@ -2944,6 +2945,46 @@ void CalendarRegressionTest::TestT9452(void) { logln(UnicodeString("-1 day: ") + dstr); assertEquals("Subtract 1 day", UnicodeString("2011-12-29T00:00:00-10:00"), dstr); } + + /** + * @bug ticket 11632 + */ + void CalendarRegressionTest::TestT11632(void) { + UErrorCode status = U_ZERO_ERROR; + GregorianCalendar cal(TimeZone::createTimeZone("Pacific/Apia"), status); + if(U_FAILURE(status)) { + dataerrln("Error creating Calendar: %s", u_errorName(status)); + return; + } + failure(status, "Calendar::createInstance(status)"); + cal.clear(); + failure(status, "clear calendar"); + cal.set(UCAL_HOUR, 597); + failure(status, "set hour value in calendar"); + SimpleDateFormat sdf(UnicodeString("y-MM-dd'T'HH:mm:ss"), status); + failure(status, "initializing SimpleDateFormat"); + sdf.setCalendar(cal); + UnicodeString dstr; + UDate d = cal.getTime(status); + if (!failure(status, "getTime for date")) { + sdf.format(d, dstr); + std::string utf8; + dstr.toUTF8String(utf8); + assertEquals("correct datetime displayed for hour value", UnicodeString("1970-01-25T21:00:00"), dstr); + cal.clear(); + failure(status, "clear calendar"); + cal.set(UCAL_HOUR, 300); + failure(status, "set hour value in calendar"); + sdf.setCalendar(cal); + d = cal.getTime(status); + if (!failure(status, "getTime for initial date")) { + dstr.remove(); + sdf.format(d, dstr); + dstr.toUTF8String(utf8); + assertEquals("correct datetime displayed for hour value", UnicodeString("1970-01-13T12:00:00"), dstr); + } + } + } } #endif /* #if !UCONFIG_NO_FORMATTING */ diff --git a/icu4c/source/test/intltest/calregts.h b/icu4c/source/test/intltest/calregts.h index e4c89dc225d..e576b972631 100644 --- a/icu4c/source/test/intltest/calregts.h +++ b/icu4c/source/test/intltest/calregts.h @@ -1,14 +1,14 @@ // © 2016 and later: Unicode, Inc. and others. // License & terms of use: http://www.unicode.org/copyright.html /******************************************************************** - * COPYRIGHT: + * COPYRIGHT: * Copyright (c) 1997-2012, International Business Machines Corporation and * others. All Rights Reserved. ********************************************************************/ #ifndef _CALENDARREGRESSIONTEST_ #define _CALENDARREGRESSIONTEST_ - + #include "unicode/utypes.h" #if !UCONFIG_NO_FORMATTING @@ -17,11 +17,11 @@ #include "unicode/gregocal.h" #include "intltest.h" -/** +/** * Performs regression test for Calendar **/ -class CalendarRegressionTest: public IntlTest { - +class CalendarRegressionTest: public IntlTest { + // IntlTest override void runIndexedTest( int32_t index, UBool exec, const char* &name, char* par ); public: @@ -77,6 +77,7 @@ public: void TestT8596(void); void Test9019(void); void TestT9452(void); + void TestT11632(void); void printdate(GregorianCalendar *cal, const char *string); void dowTest(UBool lenient) ; @@ -94,6 +95,6 @@ protected: }; #endif /* #if !UCONFIG_NO_FORMATTING */ - + #endif // _CALENDARREGRESSIONTEST_ //eof