1 /***********************************************************************
2 * Copyright (c) 1997-2016, International Business Machines Corporation
3 * and others. All Rights Reserved.
4 ***********************************************************************/
6 #ifndef __CalendarTest__
7 #define __CalendarTest__
9 #include "unicode/utypes.h"
11 #if !UCONFIG_NO_FORMATTING
13 #include "unicode/calendar.h"
14 #include "unicode/smpdtfmt.h"
17 class CalendarTest
: public CalendarTimeZoneTest
{
20 void runIndexedTest( int32_t index
, UBool exec
, const char* &name
, char* par
);
23 * This test confirms the correct behavior of add when incrementing
24 * through subsequent days.
26 virtual void TestRog(void);
28 * Test the handling of the day of the week, checking for correctness and
29 * for correct minimum and maximum values.
31 virtual void TestDOW943(void);
33 * test subroutine use by TestDOW943
35 void dowTest(UBool lenient
);
37 * Confirm that cloned Calendar objects do not inadvertently share substructures.
39 virtual void TestClonesUnique908(void);
41 * Confirm that the Gregorian cutoff value works as advertised.
43 virtual void TestGregorianChange768(void);
45 * Confirm the functioning of the field disambiguation algorithm.
47 virtual void TestDisambiguation765(void);
49 * Test various API methods for API completeness.
51 virtual void TestGenericAPI(void); // New to C++ -- needs to be back ported to Java
53 virtual void TestWOY(void);
55 virtual void TestDebug(void);
59 * test subroutine used by TestDisambiguation765
61 virtual void verify765(const UnicodeString
& msg
, Calendar
* c
, int32_t year
, int32_t month
, int32_t day
);
63 * test subroutine used by TestDisambiguation765
65 virtual void verify765(const UnicodeString
& msg
/*, IllegalArgumentException e*/, UErrorCode status
);
69 * Confirm that the offset between local time and GMT behaves as expected.
71 virtual void TestGMTvsLocal4064654(void);
75 * test subroutine used by TestGMTvsLocal4064654
77 virtual void test4064654(int32_t yr
, int32_t mo
, int32_t dt
, int32_t hr
, int32_t mn
, int32_t sc
);
81 * The operations of adding and setting should not exhibit pathological
82 * dependence on the order of operations. This test checks for this.
84 virtual void TestAddSetOrder621(void);
86 * Confirm that adding to various fields works.
88 virtual void TestAdd520(void);
90 * Execute and test adding and rolling in GregorianCalendar extensively.
92 virtual void TestAddRollExtensive(void);
95 // internal utility routine for checking date
96 virtual void check520(Calendar
* c
,
97 int32_t y
, int32_t m
, int32_t d
,
98 int32_t hr
, int32_t min
, int32_t sec
,
99 int32_t ms
, UCalendarDateFields field
);
101 virtual void check520(Calendar
* c
,
102 int32_t y
, int32_t m
, int32_t d
);
106 * Test that setting of fields works. In particular, make sure that all instances
107 * of GregorianCalendar don't share a static instance of the fields array.
109 virtual void TestFieldSet4781(void);
110 /* virtual void TestSerialize337();
113 static UnicodeString& PREFIX;
114 static UnicodeString& POSTFIX;
115 static UnicodeString& FILENAME;
119 * Verify that the seconds of a Calendar can be zeroed out through the
120 * expected sequence of operations.
122 virtual void TestSecondsZero121(void);
124 * Verify that a specific sequence of adding and setting works as expected;
125 * it should not vary depending on when and whether the get method is
128 virtual void TestAddSetGet0610(void);
131 // internal routine for checking date
132 static UnicodeString
value(Calendar
* calendar
);
136 * Verify that various fields on a known date are set correctly.
138 virtual void TestFields060(void);
141 static int32_t EXPECTED_FIELDS
[];
142 static const int32_t EXPECTED_FIELDS_length
;
146 * Verify that various fields on a known date are set correctly. In this
147 * case, the start of the epoch (January 1 1970).
149 virtual void TestEpochStartFields(void);
152 static int32_t EPOCH_FIELDS
[];
156 * Test that the days of the week progress properly when add is called repeatedly
157 * for increments of 24 days.
159 virtual void TestDOWProgression(void);
161 * Test newly added fields - DOW_LOCAL and YEAR_WOY
163 virtual void TestDOW_LOCALandYEAR_WOY(void);
164 // test subroutine used by TestDOW_LOCALandYEAR_WOY
165 virtual void doYEAR_WOYLoop(Calendar
*cal
,
166 SimpleDateFormat
*sdf
, int32_t times
, UErrorCode
& status
);
167 // test subroutine used by TestDOW_LOCALandYEAR_WOY
168 virtual void loop_addroll(Calendar
*cal
, /*SimpleDateFormat *sdf, */
169 int times
, UCalendarDateFields field
, UCalendarDateFields field2
,
170 UErrorCode
& errorCode
);
175 void yearAddTest(Calendar
& cal
, UErrorCode
& status
);
178 // test subroutine use by TestDOWProgression
179 virtual void marchByDelta(Calendar
* cal
, int32_t delta
);
182 // for other tests' use
183 static UnicodeString
fieldName(UCalendarDateFields f
);
184 static UnicodeString
calToStr(const Calendar
& cal
);
186 // List of non-installed locales with interesting calendars
189 * @return the count of 'other' locales to test
191 static int32_t testLocaleCount();
194 * @param i index of 'other' locale to return
197 static const char* testLocaleID(int32_t i
);
200 * Clone the specified calendar, and determine its earliest supported date
201 * by setting the extended year to the minimum value.
202 * @param cal Calendar (will be cloned)
203 * @param isGregorian output: returns 'TRUE' if the calendar's class is GregorianCalendar
204 * @param status error code
206 static UDate
minDateOfCalendar(const Calendar
& cal
, UBool
&isGregorian
, UErrorCode
& status
);
209 * Construct a calendar of the specified locale, and determine its earliest supported date
210 * by setting the extended year to the minimum value.
211 * @param locale locale of calendar to check
212 * @param isGregorian output: returns 'TRUE' if the calendar's class is GregorianCalendar
213 * @param status error code
215 static UDate
minDateOfCalendar(const Locale
& locale
, UBool
&isGregorian
, UErrorCode
& status
);
217 // internal - for other test use
222 void TestIslamicUmAlQura(void);
223 void TestIslamicTabularDates(void);
226 * Test the time stamp array recalculation during heavy Calendar usage
228 void TestTimeStamp(void);
230 * Test the ISO8601 calendar type
232 void TestISO8601(void);
235 * Test cases for [set|get][Repeated|Skipped]WallTimeOption
237 void TestAmbiguousWallTimeAPIs(void);
238 void TestRepeatedWallTime(void);
239 void TestSkippedWallTime(void);
241 void TestCloneLocale(void);
243 void TestHebrewMonthValidation(void);
246 * utility methods for TestIslamicUmAlQura
248 void setAndTestCalendar(Calendar
* cal
, int32_t initMonth
, int32_t initDay
, int32_t initYear
, UErrorCode
& status
);
249 void setAndTestWholeYear(Calendar
* cal
, int32_t startYear
, UErrorCode
& status
);
251 void TestWeekData(void);
253 void TestAddAcrossZoneTransition(void);
255 void TestChineseCalendarMapping(void);
258 #endif /* #if !UCONFIG_NO_FORMATTING */
260 #endif // __CalendarTest__