1 // Copyright (C) 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3 /***********************************************************************
4 * Copyright (c) 1997-2016, International Business Machines Corporation
5 * and others. All Rights Reserved.
6 ***********************************************************************/
8 #ifndef __CalendarTest__
9 #define __CalendarTest__
11 #include "unicode/utypes.h"
13 #if !UCONFIG_NO_FORMATTING
15 #include "unicode/calendar.h"
16 #include "unicode/smpdtfmt.h"
19 class CalendarTest: public CalendarTimeZoneTest {
22 void runIndexedTest( int32_t index, UBool exec, const char* &name, char* par );
25 * This test confirms the correct behavior of add when incrementing
26 * through subsequent days.
28 virtual void TestRog(void);
30 * Test the handling of the day of the week, checking for correctness and
31 * for correct minimum and maximum values.
33 virtual void TestDOW943(void);
35 * test subroutine use by TestDOW943
37 void dowTest(UBool lenient);
39 * Confirm that cloned Calendar objects do not inadvertently share substructures.
41 virtual void TestClonesUnique908(void);
43 * Confirm that the Gregorian cutoff value works as advertised.
45 virtual void TestGregorianChange768(void);
47 * Confirm the functioning of the field disambiguation algorithm.
49 virtual void TestDisambiguation765(void);
51 * Test various API methods for API completeness.
53 virtual void TestGenericAPI(void); // New to C++ -- needs to be back ported to Java
55 virtual void TestWOY(void);
57 virtual void TestDebug(void);
61 * test subroutine used by TestDisambiguation765
63 virtual void verify765(const UnicodeString& msg, Calendar* c, int32_t year, int32_t month, int32_t day);
65 * test subroutine used by TestDisambiguation765
67 virtual void verify765(const UnicodeString& msg/*, IllegalArgumentException e*/, UErrorCode status);
71 * Confirm that the offset between local time and GMT behaves as expected.
73 virtual void TestGMTvsLocal4064654(void);
77 * test subroutine used by TestGMTvsLocal4064654
79 virtual void test4064654(int32_t yr, int32_t mo, int32_t dt, int32_t hr, int32_t mn, int32_t sc);
83 * The operations of adding and setting should not exhibit pathological
84 * dependence on the order of operations. This test checks for this.
86 virtual void TestAddSetOrder621(void);
88 * Confirm that adding to various fields works.
90 virtual void TestAdd520(void);
92 * Execute and test adding and rolling in GregorianCalendar extensively.
94 virtual void TestAddRollExtensive(void);
97 // internal utility routine for checking date
98 virtual void check520(Calendar* c,
99 int32_t y, int32_t m, int32_t d,
100 int32_t hr, int32_t min, int32_t sec,
101 int32_t ms, UCalendarDateFields field);
103 virtual void check520(Calendar* c,
104 int32_t y, int32_t m, int32_t d);
108 * Test that setting of fields works. In particular, make sure that all instances
109 * of GregorianCalendar don't share a static instance of the fields array.
111 virtual void TestFieldSet4781(void);
112 /* virtual void TestSerialize337();
115 static UnicodeString& PREFIX;
116 static UnicodeString& POSTFIX;
117 static UnicodeString& FILENAME;
121 * Verify that the seconds of a Calendar can be zeroed out through the
122 * expected sequence of operations.
124 virtual void TestSecondsZero121(void);
126 * Verify that a specific sequence of adding and setting works as expected;
127 * it should not vary depending on when and whether the get method is
130 virtual void TestAddSetGet0610(void);
133 // internal routine for checking date
134 static UnicodeString value(Calendar* calendar);
138 * Verify that various fields on a known date are set correctly.
140 virtual void TestFields060(void);
143 static int32_t EXPECTED_FIELDS[];
144 static const int32_t EXPECTED_FIELDS_length;
148 * Verify that various fields on a known date are set correctly. In this
149 * case, the start of the epoch (January 1 1970).
151 virtual void TestEpochStartFields(void);
154 static int32_t EPOCH_FIELDS[];
158 * Test that the days of the week progress properly when add is called repeatedly
159 * for increments of 24 days.
161 virtual void TestDOWProgression(void);
163 * Test newly added fields - DOW_LOCAL and YEAR_WOY
165 virtual void TestDOW_LOCALandYEAR_WOY(void);
166 // test subroutine used by TestDOW_LOCALandYEAR_WOY
167 virtual void doYEAR_WOYLoop(Calendar *cal,
168 SimpleDateFormat *sdf, int32_t times, UErrorCode& status);
169 // test subroutine used by TestDOW_LOCALandYEAR_WOY
170 virtual void loop_addroll(Calendar *cal, /*SimpleDateFormat *sdf, */
171 int times, UCalendarDateFields field, UCalendarDateFields field2,
172 UErrorCode& errorCode);
177 void yearAddTest(Calendar& cal, UErrorCode& status);
180 // test subroutine use by TestDOWProgression
181 virtual void marchByDelta(Calendar* cal, int32_t delta);
184 // for other tests' use
185 static UnicodeString fieldName(UCalendarDateFields f);
186 static UnicodeString calToStr(const Calendar & cal);
188 // List of non-installed locales with interesting calendars
191 * @return the count of 'other' locales to test
193 static int32_t testLocaleCount();
196 * @param i index of 'other' locale to return
199 static const char* testLocaleID(int32_t i);
202 * Clone the specified calendar, and determine its earliest supported date
203 * by setting the extended year to the minimum value.
204 * @param cal Calendar (will be cloned)
205 * @param isGregorian output: returns 'TRUE' if the calendar's class is GregorianCalendar
206 * @param status error code
208 static UDate minDateOfCalendar(const Calendar& cal, UBool &isGregorian, UErrorCode& status);
211 * Construct a calendar of the specified locale, and determine its earliest supported date
212 * by setting the extended year to the minimum value.
213 * @param locale locale of calendar to check
214 * @param isGregorian output: returns 'TRUE' if the calendar's class is GregorianCalendar
215 * @param status error code
217 static UDate minDateOfCalendar(const Locale& locale, UBool &isGregorian, UErrorCode& status);
219 // internal - for other test use
224 void TestIslamicUmAlQura(void);
225 void TestIslamicTabularDates(void);
228 * Test the time stamp array recalculation during heavy Calendar usage
230 void TestTimeStamp(void);
232 * Test the ISO8601 calendar type
234 void TestISO8601(void);
237 * Test cases for [set|get][Repeated|Skipped]WallTimeOption
239 void TestAmbiguousWallTimeAPIs(void);
240 void TestRepeatedWallTime(void);
241 void TestSkippedWallTime(void);
243 void TestCloneLocale(void);
245 void TestHebrewMonthValidation(void);
248 * utility methods for TestIslamicUmAlQura
250 void setAndTestCalendar(Calendar* cal, int32_t initMonth, int32_t initDay, int32_t initYear, UErrorCode& status);
251 void setAndTestWholeYear(Calendar* cal, int32_t startYear, UErrorCode& status);
253 void TestWeekData(void);
255 void TestAddAcrossZoneTransition(void);
257 void TestChineseCalendarMapping(void);
260 #endif /* #if !UCONFIG_NO_FORMATTING */
262 #endif // __CalendarTest__