]>
Commit | Line | Data |
---|---|---|
374ca955 | 1 | /*********************************************************************** |
2ca993e8 | 2 | * Copyright (c) 1997-2016, International Business Machines Corporation |
374ca955 A |
3 | * and others. All Rights Reserved. |
4 | ***********************************************************************/ | |
b75a7d8f A |
5 | |
6 | #ifndef __CalendarTest__ | |
7 | #define __CalendarTest__ | |
2ca993e8 | 8 | |
b75a7d8f A |
9 | #include "unicode/utypes.h" |
10 | ||
11 | #if !UCONFIG_NO_FORMATTING | |
12 | ||
13 | #include "unicode/calendar.h" | |
14 | #include "unicode/smpdtfmt.h" | |
15 | #include "caltztst.h" | |
16 | ||
17 | class CalendarTest: public CalendarTimeZoneTest { | |
18 | public: | |
19 | // IntlTest override | |
20 | void runIndexedTest( int32_t index, UBool exec, const char* &name, char* par ); | |
21 | public: | |
22 | /** | |
23 | * This test confirms the correct behavior of add when incrementing | |
24 | * through subsequent days. | |
25 | */ | |
26 | virtual void TestRog(void); | |
27 | /** | |
28 | * Test the handling of the day of the week, checking for correctness and | |
29 | * for correct minimum and maximum values. | |
30 | */ | |
31 | virtual void TestDOW943(void); | |
32 | /** | |
33 | * test subroutine use by TestDOW943 | |
34 | */ | |
35 | void dowTest(UBool lenient); | |
2ca993e8 | 36 | /** |
b75a7d8f A |
37 | * Confirm that cloned Calendar objects do not inadvertently share substructures. |
38 | */ | |
39 | virtual void TestClonesUnique908(void); | |
40 | /** | |
41 | * Confirm that the Gregorian cutoff value works as advertised. | |
42 | */ | |
43 | virtual void TestGregorianChange768(void); | |
44 | /** | |
45 | * Confirm the functioning of the field disambiguation algorithm. | |
46 | */ | |
47 | virtual void TestDisambiguation765(void); | |
48 | /** | |
49 | * Test various API methods for API completeness. | |
50 | */ | |
51 | virtual void TestGenericAPI(void); // New to C++ -- needs to be back ported to Java | |
52 | ||
53 | virtual void TestWOY(void); | |
2ca993e8 | 54 | |
46f4442e | 55 | virtual void TestDebug(void); |
2ca993e8 | 56 | |
b75a7d8f A |
57 | public: // package |
58 | /** | |
59 | * test subroutine used by TestDisambiguation765 | |
60 | */ | |
61 | virtual void verify765(const UnicodeString& msg, Calendar* c, int32_t year, int32_t month, int32_t day); | |
62 | /** | |
63 | * test subroutine used by TestDisambiguation765 | |
64 | */ | |
65 | virtual void verify765(const UnicodeString& msg/*, IllegalArgumentException e*/, UErrorCode status); | |
2ca993e8 | 66 | |
b75a7d8f A |
67 | public: |
68 | /** | |
69 | * Confirm that the offset between local time and GMT behaves as expected. | |
70 | */ | |
71 | virtual void TestGMTvsLocal4064654(void); | |
2ca993e8 | 72 | |
b75a7d8f A |
73 | public: // package |
74 | /** | |
75 | * test subroutine used by TestGMTvsLocal4064654 | |
76 | */ | |
77 | virtual void test4064654(int32_t yr, int32_t mo, int32_t dt, int32_t hr, int32_t mn, int32_t sc); | |
2ca993e8 | 78 | |
b75a7d8f A |
79 | public: |
80 | /** | |
81 | * The operations of adding and setting should not exhibit pathological | |
82 | * dependence on the order of operations. This test checks for this. | |
83 | */ | |
84 | virtual void TestAddSetOrder621(void); | |
85 | /** | |
86 | * Confirm that adding to various fields works. | |
87 | */ | |
88 | virtual void TestAdd520(void); | |
89 | /** | |
90 | * Execute and test adding and rolling in GregorianCalendar extensively. | |
91 | */ | |
92 | virtual void TestAddRollExtensive(void); | |
93 | ||
94 | public: // package | |
95 | // internal utility routine for checking date | |
2ca993e8 A |
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, | |
b75a7d8f | 99 | int32_t ms, UCalendarDateFields field); |
2ca993e8 A |
100 | |
101 | virtual void check520(Calendar* c, | |
b75a7d8f A |
102 | int32_t y, int32_t m, int32_t d); |
103 | ||
104 | public: | |
105 | /** | |
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. | |
108 | */ | |
109 | virtual void TestFieldSet4781(void); | |
110 | /* virtual void TestSerialize337(); | |
2ca993e8 | 111 | |
b75a7d8f A |
112 | public: // package |
113 | static UnicodeString& PREFIX; | |
114 | static UnicodeString& POSTFIX; | |
115 | static UnicodeString& FILENAME; | |
2ca993e8 | 116 | */ |
b75a7d8f A |
117 | public: |
118 | /** | |
119 | * Verify that the seconds of a Calendar can be zeroed out through the | |
120 | * expected sequence of operations. | |
2ca993e8 | 121 | */ |
b75a7d8f A |
122 | virtual void TestSecondsZero121(void); |
123 | /** | |
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 | |
126 | * called. | |
127 | */ | |
128 | virtual void TestAddSetGet0610(void); | |
2ca993e8 | 129 | |
b75a7d8f A |
130 | public: // package |
131 | // internal routine for checking date | |
132 | static UnicodeString value(Calendar* calendar); | |
2ca993e8 | 133 | |
b75a7d8f A |
134 | public: |
135 | /** | |
136 | * Verify that various fields on a known date are set correctly. | |
137 | */ | |
138 | virtual void TestFields060(void); | |
2ca993e8 | 139 | |
b75a7d8f A |
140 | public: // package |
141 | static int32_t EXPECTED_FIELDS[]; | |
142 | static const int32_t EXPECTED_FIELDS_length; | |
2ca993e8 | 143 | |
b75a7d8f A |
144 | public: |
145 | /** | |
146 | * Verify that various fields on a known date are set correctly. In this | |
147 | * case, the start of the epoch (January 1 1970). | |
148 | */ | |
149 | virtual void TestEpochStartFields(void); | |
2ca993e8 | 150 | |
b75a7d8f A |
151 | public: // package |
152 | static int32_t EPOCH_FIELDS[]; | |
2ca993e8 | 153 | |
b75a7d8f A |
154 | public: |
155 | /** | |
156 | * Test that the days of the week progress properly when add is called repeatedly | |
157 | * for increments of 24 days. | |
158 | */ | |
159 | virtual void TestDOWProgression(void); | |
160 | /** | |
161 | * Test newly added fields - DOW_LOCAL and YEAR_WOY | |
162 | */ | |
163 | virtual void TestDOW_LOCALandYEAR_WOY(void); | |
164 | // test subroutine used by TestDOW_LOCALandYEAR_WOY | |
2ca993e8 | 165 | virtual void doYEAR_WOYLoop(Calendar *cal, |
b75a7d8f A |
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, */ | |
2ca993e8 | 169 | int times, UCalendarDateFields field, UCalendarDateFields field2, |
b75a7d8f A |
170 | UErrorCode& errorCode); |
171 | ||
374ca955 A |
172 | void TestYWOY(void); |
173 | void TestJD(void); | |
174 | ||
b75a7d8f | 175 | void yearAddTest(Calendar& cal, UErrorCode& status); |
2ca993e8 | 176 | |
b75a7d8f A |
177 | public: // package |
178 | // test subroutine use by TestDOWProgression | |
179 | virtual void marchByDelta(Calendar* cal, int32_t delta); | |
374ca955 A |
180 | |
181 | public: | |
182 | // for other tests' use | |
183 | static UnicodeString fieldName(UCalendarDateFields f); | |
184 | static UnicodeString calToStr(const Calendar & cal); | |
2ca993e8 | 185 | |
374ca955 A |
186 | // List of non-installed locales with interesting calendars |
187 | ||
188 | /** | |
189 | * @return the count of 'other' locales to test | |
190 | */ | |
191 | static int32_t testLocaleCount(); | |
192 | ||
193 | /** | |
194 | * @param i index of 'other' locale to return | |
195 | * @return locale ID | |
196 | */ | |
197 | static const char* testLocaleID(int32_t i); | |
198 | ||
199 | /** | |
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 | |
2ca993e8 | 204 | * @param status error code |
374ca955 A |
205 | */ |
206 | static UDate minDateOfCalendar(const Calendar& cal, UBool &isGregorian, UErrorCode& status); | |
207 | ||
208 | /** | |
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 | |
2ca993e8 | 213 | * @param status error code |
374ca955 A |
214 | */ |
215 | static UDate minDateOfCalendar(const Locale& locale, UBool &isGregorian, UErrorCode& status); | |
216 | ||
217 | // internal - for other test use | |
218 | public: | |
729e4ab9 A |
219 | void Test6703(void); |
220 | void Test3785(void); | |
221 | void Test1624(void); | |
57a6839d A |
222 | void TestIslamicUmAlQura(void); |
223 | void TestIslamicTabularDates(void); | |
4388f060 A |
224 | |
225 | /** | |
226 | * Test the time stamp array recalculation during heavy Calendar usage | |
227 | */ | |
228 | void TestTimeStamp(void); | |
229 | /** | |
230 | * Test the ISO8601 calendar type | |
231 | */ | |
232 | void TestISO8601(void); | |
233 | ||
234 | /** | |
235 | * Test cases for [set|get][Repeated|Skipped]WallTimeOption | |
236 | */ | |
237 | void TestAmbiguousWallTimeAPIs(void); | |
238 | void TestRepeatedWallTime(void); | |
239 | void TestSkippedWallTime(void); | |
240 | ||
241 | void TestCloneLocale(void); | |
e4f10fab | 242 | |
57a6839d A |
243 | void TestHebrewMonthValidation(void); |
244 | ||
245 | /* | |
246 | * utility methods for TestIslamicUmAlQura | |
247 | */ | |
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); | |
250 | ||
251 | void TestWeekData(void); | |
252 | ||
e4f10fab | 253 | void TestAddAcrossZoneTransition(void); |
2ca993e8 A |
254 | |
255 | void TestChineseCalendarMapping(void); | |
b75a7d8f A |
256 | }; |
257 | ||
258 | #endif /* #if !UCONFIG_NO_FORMATTING */ | |
2ca993e8 | 259 | |
b75a7d8f | 260 | #endif // __CalendarTest__ |