]> git.saurik.com Git - apple/icu.git/blob - icuSources/test/intltest/caltest.h
ICU-6.2.8.tar.gz
[apple/icu.git] / icuSources / test / intltest / caltest.h
1 /***********************************************************************
2 * COPYRIGHT:
3 * Copyright (c) 1997-2004, International Business Machines Corporation
4 * and others. All Rights Reserved.
5 ***********************************************************************/
6
7 #ifndef __CalendarTest__
8 #define __CalendarTest__
9
10 #include "unicode/utypes.h"
11
12 #if !UCONFIG_NO_FORMATTING
13
14 #include "unicode/calendar.h"
15 #include "unicode/smpdtfmt.h"
16 #include "caltztst.h"
17
18 class CalendarTest: public CalendarTimeZoneTest {
19 public:
20 // IntlTest override
21 void runIndexedTest( int32_t index, UBool exec, const char* &name, char* par );
22 public:
23 /**
24 * This test confirms the correct behavior of add when incrementing
25 * through subsequent days.
26 */
27 virtual void TestRog(void);
28 /**
29 * Test the handling of the day of the week, checking for correctness and
30 * for correct minimum and maximum values.
31 */
32 virtual void TestDOW943(void);
33 /**
34 * test subroutine use by TestDOW943
35 */
36 void dowTest(UBool lenient);
37 /**
38 * Confirm that cloned Calendar objects do not inadvertently share substructures.
39 */
40 virtual void TestClonesUnique908(void);
41 /**
42 * Confirm that the Gregorian cutoff value works as advertised.
43 */
44 virtual void TestGregorianChange768(void);
45 /**
46 * Confirm the functioning of the field disambiguation algorithm.
47 */
48 virtual void TestDisambiguation765(void);
49 /**
50 * Test various API methods for API completeness.
51 */
52 virtual void TestGenericAPI(void); // New to C++ -- needs to be back ported to Java
53
54 virtual void TestWOY(void);
55
56 public: // package
57 /**
58 * test subroutine used by TestDisambiguation765
59 */
60 virtual void verify765(const UnicodeString& msg, Calendar* c, int32_t year, int32_t month, int32_t day);
61 /**
62 * test subroutine used by TestDisambiguation765
63 */
64 virtual void verify765(const UnicodeString& msg/*, IllegalArgumentException e*/, UErrorCode status);
65
66 public:
67 /**
68 * Confirm that the offset between local time and GMT behaves as expected.
69 */
70 virtual void TestGMTvsLocal4064654(void);
71
72 public: // package
73 /**
74 * test subroutine used by TestGMTvsLocal4064654
75 */
76 virtual void test4064654(int32_t yr, int32_t mo, int32_t dt, int32_t hr, int32_t mn, int32_t sc);
77
78 public:
79 /**
80 * The operations of adding and setting should not exhibit pathological
81 * dependence on the order of operations. This test checks for this.
82 */
83 virtual void TestAddSetOrder621(void);
84 /**
85 * Confirm that adding to various fields works.
86 */
87 virtual void TestAdd520(void);
88 /**
89 * Execute and test adding and rolling in GregorianCalendar extensively.
90 */
91 virtual void TestAddRollExtensive(void);
92
93 public: // package
94 // internal utility routine for checking date
95 virtual void check520(Calendar* c,
96 int32_t y, int32_t m, int32_t d,
97 int32_t hr, int32_t min, int32_t sec,
98 int32_t ms, UCalendarDateFields field);
99
100 virtual void check520(Calendar* c,
101 int32_t y, int32_t m, int32_t d);
102
103 public:
104 /**
105 * Test that setting of fields works. In particular, make sure that all instances
106 * of GregorianCalendar don't share a static instance of the fields array.
107 */
108 virtual void TestFieldSet4781(void);
109 /* virtual void TestSerialize337();
110
111 public: // package
112 static UnicodeString& PREFIX;
113 static UnicodeString& POSTFIX;
114 static UnicodeString& FILENAME;
115 */
116 public:
117 /**
118 * Verify that the seconds of a Calendar can be zeroed out through the
119 * expected sequence of operations.
120 */
121 virtual void TestSecondsZero121(void);
122 /**
123 * Verify that a specific sequence of adding and setting works as expected;
124 * it should not vary depending on when and whether the get method is
125 * called.
126 */
127 virtual void TestAddSetGet0610(void);
128
129 public: // package
130 // internal routine for checking date
131 static UnicodeString value(Calendar* calendar);
132
133 public:
134 /**
135 * Verify that various fields on a known date are set correctly.
136 */
137 virtual void TestFields060(void);
138
139 public: // package
140 static int32_t EXPECTED_FIELDS[];
141 static const int32_t EXPECTED_FIELDS_length;
142
143 public:
144 /**
145 * Verify that various fields on a known date are set correctly. In this
146 * case, the start of the epoch (January 1 1970).
147 */
148 virtual void TestEpochStartFields(void);
149
150 public: // package
151 static int32_t EPOCH_FIELDS[];
152
153 public:
154 /**
155 * Test that the days of the week progress properly when add is called repeatedly
156 * for increments of 24 days.
157 */
158 virtual void TestDOWProgression(void);
159 /**
160 * Test newly added fields - DOW_LOCAL and YEAR_WOY
161 */
162 virtual void TestDOW_LOCALandYEAR_WOY(void);
163 // test subroutine used by TestDOW_LOCALandYEAR_WOY
164 virtual void doYEAR_WOYLoop(Calendar *cal,
165 SimpleDateFormat *sdf, int32_t times, UErrorCode& status);
166 // test subroutine used by TestDOW_LOCALandYEAR_WOY
167 virtual void loop_addroll(Calendar *cal, /*SimpleDateFormat *sdf, */
168 int times, UCalendarDateFields field, UCalendarDateFields field2,
169 UErrorCode& errorCode);
170
171 void TestYWOY(void);
172 void TestJD(void);
173
174 void yearAddTest(Calendar& cal, UErrorCode& status);
175
176 public: // package
177 // test subroutine use by TestDOWProgression
178 virtual void marchByDelta(Calendar* cal, int32_t delta);
179
180 public:
181 // for other tests' use
182 static UnicodeString fieldName(UCalendarDateFields f);
183 static UnicodeString calToStr(const Calendar & cal);
184
185 // List of non-installed locales with interesting calendars
186
187 /**
188 * @return the count of 'other' locales to test
189 */
190 static int32_t testLocaleCount();
191
192 /**
193 * @param i index of 'other' locale to return
194 * @return locale ID
195 */
196 static const char* testLocaleID(int32_t i);
197
198 /**
199 * Clone the specified calendar, and determine its earliest supported date
200 * by setting the extended year to the minimum value.
201 * @param cal Calendar (will be cloned)
202 * @param isGregorian output: returns 'TRUE' if the calendar's class is GregorianCalendar
203 * @param status error code
204 */
205 static UDate minDateOfCalendar(const Calendar& cal, UBool &isGregorian, UErrorCode& status);
206
207 /**
208 * Construct a calendar of the specified locale, and determine its earliest supported date
209 * by setting the extended year to the minimum value.
210 * @param locale locale of calendar to check
211 * @param isGregorian output: returns 'TRUE' if the calendar's class is GregorianCalendar
212 * @param status error code
213 */
214 static UDate minDateOfCalendar(const Locale& locale, UBool &isGregorian, UErrorCode& status);
215
216 // internal - for other test use
217 public:
218
219 };
220
221 #endif /* #if !UCONFIG_NO_FORMATTING */
222
223 #endif // __CalendarTest__