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