• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /***********************************************************************
2  * Copyright (c) 1997-2009, International Business Machines Corporation
3  * and others. All Rights Reserved.
4  ***********************************************************************/
5 
6 #ifndef __CalendarTest__
7 #define __CalendarTest__
8 
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);
36     /**
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);
54 
55     virtual void TestDebug(void);
56 
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);
66 
67 public:
68     /**
69      * Confirm that the offset between local time and GMT behaves as expected.
70      */
71     virtual void TestGMTvsLocal4064654(void);
72 
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);
78 
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
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,
99                             int32_t ms, UCalendarDateFields field);
100 
101     virtual void check520(Calendar* c,
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();
111 
112 public: // package
113     static UnicodeString& PREFIX;
114     static UnicodeString& POSTFIX;
115     static UnicodeString& FILENAME;
116 */
117 public:
118     /**
119      * Verify that the seconds of a Calendar can be zeroed out through the
120      * expected sequence of operations.
121      */
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);
129 
130 public: // package
131     // internal routine for checking date
132     static UnicodeString value(Calendar* calendar);
133 
134 public:
135     /**
136      * Verify that various fields on a known date are set correctly.
137      */
138     virtual void TestFields060(void);
139 
140 public: // package
141     static int32_t EXPECTED_FIELDS[];
142     static const int32_t EXPECTED_FIELDS_length;
143 
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);
150 
151 public: // package
152     static int32_t EPOCH_FIELDS[];
153 
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
165     virtual void doYEAR_WOYLoop(Calendar *cal,
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, */
169         int times, UCalendarDateFields field, UCalendarDateFields field2,
170         UErrorCode& errorCode);
171 
172     void TestYWOY(void);
173     void TestJD(void);
174 
175     void yearAddTest(Calendar& cal, UErrorCode& status);
176 
177 public: // package
178     // test subroutine use by TestDOWProgression
179     virtual void marchByDelta(Calendar* cal, int32_t delta);
180 
181  public:
182     // for other tests' use
183     static UnicodeString fieldName(UCalendarDateFields f);
184     static UnicodeString calToStr(const Calendar & cal);
185 
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
204      * @param status error code
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
213      * @param status error code
214      */
215     static UDate minDateOfCalendar(const Locale& locale, UBool &isGregorian, UErrorCode& status);
216 
217   // internal - for other test use
218  public:
219     void Test6703(void);
220     void Test3785(void);
221     void Test1624(void);
222 };
223 
224 #endif /* #if !UCONFIG_NO_FORMATTING */
225 
226 #endif // __CalendarTest__
227