1 /***********************************************************************
3 * Copyright (c) 1997-2004, International Business Machines Corporation
4 * and others. All Rights Reserved.
5 ***********************************************************************/
7 #ifndef __CalendarTest__
8 #define __CalendarTest__
10 #include "unicode/utypes.h"
12 #if !UCONFIG_NO_FORMATTING
14 #include "unicode/calendar.h"
15 #include "unicode/smpdtfmt.h"
18 class CalendarTest
: public CalendarTimeZoneTest
{
21 void runIndexedTest( int32_t index
, UBool exec
, const char* &name
, char* par
);
24 * This test confirms the correct behavior of add when incrementing
25 * through subsequent days.
27 virtual void TestRog(void);
29 * Test the handling of the day of the week, checking for correctness and
30 * for correct minimum and maximum values.
32 virtual void TestDOW943(void);
34 * test subroutine use by TestDOW943
36 void dowTest(UBool lenient
);
38 * Confirm that cloned Calendar objects do not inadvertently share substructures.
40 virtual void TestClonesUnique908(void);
42 * Confirm that the Gregorian cutoff value works as advertised.
44 virtual void TestGregorianChange768(void);
46 * Confirm the functioning of the field disambiguation algorithm.
48 virtual void TestDisambiguation765(void);
50 * Test various API methods for API completeness.
52 virtual void TestGenericAPI(void); // New to C++ -- needs to be back ported to Java
54 virtual void TestWOY(void);
58 * test subroutine used by TestDisambiguation765
60 virtual void verify765(const UnicodeString
& msg
, Calendar
* c
, int32_t year
, int32_t month
, int32_t day
);
62 * test subroutine used by TestDisambiguation765
64 virtual void verify765(const UnicodeString
& msg
/*, IllegalArgumentException e*/, UErrorCode status
);
68 * Confirm that the offset between local time and GMT behaves as expected.
70 virtual void TestGMTvsLocal4064654(void);
74 * test subroutine used by TestGMTvsLocal4064654
76 virtual void test4064654(int32_t yr
, int32_t mo
, int32_t dt
, int32_t hr
, int32_t mn
, int32_t sc
);
80 * The operations of adding and setting should not exhibit pathological
81 * dependence on the order of operations. This test checks for this.
83 virtual void TestAddSetOrder621(void);
85 * Confirm that adding to various fields works.
87 virtual void TestAdd520(void);
89 * Execute and test adding and rolling in GregorianCalendar extensively.
91 virtual void TestAddRollExtensive(void);
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
);
100 virtual void check520(Calendar
* c
,
101 int32_t y
, int32_t m
, int32_t d
);
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.
108 virtual void TestFieldSet4781(void);
109 /* virtual void TestSerialize337();
112 static UnicodeString& PREFIX;
113 static UnicodeString& POSTFIX;
114 static UnicodeString& FILENAME;
118 * Verify that the seconds of a Calendar can be zeroed out through the
119 * expected sequence of operations.
121 virtual void TestSecondsZero121(void);
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
127 virtual void TestAddSetGet0610(void);
130 // internal routine for checking date
131 static UnicodeString
value(Calendar
* calendar
);
135 * Verify that various fields on a known date are set correctly.
137 virtual void TestFields060(void);
140 static int32_t EXPECTED_FIELDS
[];
141 static const int32_t EXPECTED_FIELDS_length
;
145 * Verify that various fields on a known date are set correctly. In this
146 * case, the start of the epoch (January 1 1970).
148 virtual void TestEpochStartFields(void);
151 static int32_t EPOCH_FIELDS
[];
155 * Test that the days of the week progress properly when add is called repeatedly
156 * for increments of 24 days.
158 virtual void TestDOWProgression(void);
160 * Test newly added fields - DOW_LOCAL and YEAR_WOY
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
);
174 void yearAddTest(Calendar
& cal
, UErrorCode
& status
);
177 // test subroutine use by TestDOWProgression
178 virtual void marchByDelta(Calendar
* cal
, int32_t delta
);
181 // for other tests' use
182 static UnicodeString
fieldName(UCalendarDateFields f
);
183 static UnicodeString
calToStr(const Calendar
& cal
);
185 // List of non-installed locales with interesting calendars
188 * @return the count of 'other' locales to test
190 static int32_t testLocaleCount();
193 * @param i index of 'other' locale to return
196 static const char* testLocaleID(int32_t i
);
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
205 static UDate
minDateOfCalendar(const Calendar
& cal
, UBool
&isGregorian
, UErrorCode
& status
);
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
214 static UDate
minDateOfCalendar(const Locale
& locale
, UBool
&isGregorian
, UErrorCode
& status
);
216 // internal - for other test use
221 #endif /* #if !UCONFIG_NO_FORMATTING */
223 #endif // __CalendarTest__