]>
Commit | Line | Data |
---|---|---|
f3c0d7a5 A |
1 | // © 2016 and later: Unicode, Inc. and others. |
2 | // License & terms of use: http://www.unicode.org/copyright.html | |
b75a7d8f | 3 | /******************************************************************** |
2ca993e8 A |
4 | * COPYRIGHT: |
5 | * Copyright (c) 1997-2016, International Business Machines Corporation and | |
b75a7d8f A |
6 | * others. All Rights Reserved. |
7 | ********************************************************************/ | |
8 | ||
9 | #ifndef _DATEFORMATTEST_ | |
10 | #define _DATEFORMATTEST_ | |
2ca993e8 | 11 | |
b75a7d8f A |
12 | #include "unicode/utypes.h" |
13 | ||
14 | #if !UCONFIG_NO_FORMATTING | |
15 | ||
16 | #include "unicode/datefmt.h" | |
17 | #include "unicode/smpdtfmt.h" | |
18 | #include "caltztst.h" | |
19 | ||
2ca993e8 | 20 | /** |
729e4ab9 | 21 | * Performs many different tests for DateFormat and SimpleDateFormat |
b75a7d8f A |
22 | **/ |
23 | class DateFormatTest: public CalendarTimeZoneTest { | |
24 | // IntlTest override | |
25 | void runIndexedTest( int32_t index, UBool exec, const char* &name, char* par ); | |
26 | public: | |
51004dcb A |
27 | /** |
28 | * Verify that patterns have the correct values and could produce | |
29 | * the DateFormat instances that contain the correct localized patterns. | |
30 | */ | |
31 | void TestPatterns(); | |
b75a7d8f A |
32 | /** |
33 | * "Test written by Wally Wedel and emailed to me." | |
34 | * Test handling of timezone offsets | |
35 | **/ | |
36 | virtual void TestWallyWedel(void); | |
37 | /** | |
38 | * Test operator== | |
39 | */ | |
40 | virtual void TestEquals(void); | |
41 | /** | |
42 | * Test the parsing of 2-digit years. | |
43 | */ | |
44 | virtual void TestTwoDigitYearDSTParse(void); | |
2ca993e8 | 45 | |
b75a7d8f A |
46 | public: // package |
47 | // internal utility routine (genrates escape sequences for characters) | |
48 | static UnicodeString& escape(UnicodeString& s); | |
2ca993e8 | 49 | |
b75a7d8f A |
50 | public: |
51 | /** | |
52 | * Verify that returned field position indices are correct. | |
53 | */ | |
374ca955 | 54 | void TestFieldPosition(void); |
2ca993e8 | 55 | |
374ca955 A |
56 | void TestGeneral(); |
57 | ||
b75a7d8f A |
58 | public: // package |
59 | // internal utility function | |
60 | static void getFieldText(DateFormat* df, int32_t field, UDate date, UnicodeString& str); | |
2ca993e8 | 61 | |
b75a7d8f A |
62 | public: |
63 | /** | |
64 | * Verify that strings which contain incomplete specifications are parsed | |
65 | * correctly. In some instances, this means not being parsed at all, and | |
66 | * returning an appropriate error. | |
67 | */ | |
68 | virtual void TestPartialParse994(void); | |
2ca993e8 | 69 | |
b75a7d8f A |
70 | public: // package |
71 | // internal test subroutine, used by TestPartialParse994 | |
72 | virtual void tryPat994(SimpleDateFormat* format, const char* pat, const char* str, UDate expected); | |
2ca993e8 | 73 | |
b75a7d8f A |
74 | public: |
75 | /** | |
76 | * Verify the behavior of patterns in which digits for different fields run together | |
77 | * without intervening separators. | |
78 | */ | |
79 | virtual void TestRunTogetherPattern985(void); | |
80 | /** | |
81 | * Verify the behavior of patterns in which digits for different fields run together | |
82 | * without intervening separators. | |
83 | */ | |
84 | virtual void TestRunTogetherPattern917(void); | |
2ca993e8 | 85 | |
b75a7d8f A |
86 | public: // package |
87 | // internal test subroutine, used by TestRunTogetherPattern917 | |
88 | virtual void testIt917(SimpleDateFormat* fmt, UnicodeString& str, UDate expected); | |
2ca993e8 | 89 | |
b75a7d8f A |
90 | public: |
91 | /** | |
92 | * Verify the handling of Czech June and July, which have the unique attribute that | |
93 | * one is a proper prefix substring of the other. | |
94 | */ | |
95 | virtual void TestCzechMonths459(void); | |
96 | /** | |
97 | * Test the handling of 'D' in patterns. | |
98 | */ | |
99 | virtual void TestLetterDPattern212(void); | |
100 | /** | |
101 | * Test the day of year pattern. | |
102 | */ | |
103 | virtual void TestDayOfYearPattern195(void); | |
2ca993e8 | 104 | |
b75a7d8f A |
105 | public: // package |
106 | // interl test subroutine, used by TestDayOfYearPattern195 | |
107 | virtual void tryPattern(SimpleDateFormat& sdf, UDate d, const char* pattern, UDate expected); | |
2ca993e8 | 108 | |
b75a7d8f A |
109 | public: |
110 | /** | |
111 | * Test the handling of single quotes in patterns. | |
112 | */ | |
113 | virtual void TestQuotePattern161(void); | |
114 | /** | |
115 | * Verify the correct behavior when handling invalid input strings. | |
116 | */ | |
117 | virtual void TestBadInput135(void); | |
2ca993e8 | 118 | |
b75a7d8f A |
119 | public: |
120 | /** | |
121 | * Verify the correct behavior when parsing an array of inputs against an | |
122 | * array of patterns, with known results. The results are encoded after | |
123 | * the input strings in each row. | |
124 | */ | |
125 | virtual void TestBadInput135a(void); | |
126 | /** | |
127 | * Test the parsing of two-digit years. | |
128 | */ | |
129 | virtual void TestTwoDigitYear(void); | |
2ca993e8 | 130 | |
b75a7d8f A |
131 | public: // package |
132 | // internal test subroutine, used by TestTwoDigitYear | |
133 | virtual void parse2DigitYear(DateFormat& fmt, const char* str, UDate expected); | |
2ca993e8 | 134 | |
b75a7d8f A |
135 | public: |
136 | /** | |
137 | * Test the formatting of time zones. | |
138 | */ | |
139 | virtual void TestDateFormatZone061(void); | |
140 | /** | |
141 | * Further test the formatting of time zones. | |
142 | */ | |
143 | virtual void TestDateFormatZone146(void); | |
73c04bcf A |
144 | |
145 | void TestTimeZoneStringsAPI(void); | |
7393aa2f | 146 | |
7393aa2f | 147 | void TestGMTParsing(void); |
7393aa2f | 148 | |
b75a7d8f A |
149 | public: // package |
150 | /** | |
151 | * Test the formatting of dates in different locales. | |
152 | */ | |
153 | virtual void TestLocaleDateFormat(void); | |
154 | ||
b331163b A |
155 | virtual void TestFormattingLocaleTimeSeparator(void); |
156 | ||
b75a7d8f A |
157 | virtual void TestDateFormatCalendar(void); |
158 | ||
159 | virtual void TestSpaceParsing(void); | |
160 | ||
161 | void TestExactCountFormat(void); | |
162 | ||
163 | void TestWhiteSpaceParsing(void); | |
164 | ||
374ca955 A |
165 | void TestInvalidPattern(void); |
166 | ||
167 | void TestGreekMay(void); | |
168 | ||
73c04bcf A |
169 | void TestGenericTime(void); |
170 | ||
171 | void TestGenericTimeZoneOrder(void); | |
172 | ||
7393aa2f A |
173 | void Test6338(void); |
174 | ||
175 | void Test6726(void); | |
176 | ||
177 | void Test6880(void); | |
729e4ab9 A |
178 | |
179 | void TestISOEra(void); | |
180 | ||
181 | void TestFormalChineseDate(void); | |
7393aa2f | 182 | |
4388f060 A |
183 | void TestStandAloneGMTParse(void); |
184 | ||
185 | void TestParsePosition(void); | |
186 | ||
187 | void TestMonthPatterns(void); | |
188 | ||
189 | void TestContext(void); | |
190 | ||
51004dcb A |
191 | void TestNonGregoFmtParse(void); |
192 | ||
2ca993e8 A |
193 | void TestFormatsWithNumberSystems(void); |
194 | ||
73c04bcf A |
195 | public: |
196 | /** | |
197 | * Test host-specific formatting. | |
198 | */ | |
199 | void TestHost(void); | |
200 | ||
201 | public: | |
202 | /** | |
51004dcb | 203 | * Test patterns added in CLDR 1.4, CLDR 23 |
73c04bcf A |
204 | */ |
205 | void TestEras(void); | |
206 | ||
207 | void TestNarrowNames(void); | |
208 | ||
51004dcb A |
209 | void TestShortDays(void); |
210 | ||
73c04bcf A |
211 | void TestStandAloneDays(void); |
212 | ||
213 | void TestStandAloneMonths(void); | |
214 | ||
215 | void TestQuarters(void); | |
2ca993e8 | 216 | |
46f4442e A |
217 | void TestZTimeZoneParsing(void); |
218 | ||
219 | void TestRelativeClone(void); | |
2ca993e8 | 220 | |
46f4442e A |
221 | void TestHostClone(void); |
222 | ||
b331163b A |
223 | void TestHebrewClone(void); |
224 | ||
225 | void TestDateFormatSymbolsClone(void); | |
226 | ||
7393aa2f A |
227 | void TestTimeZoneDisplayName(void); |
228 | ||
229 | void TestRoundtripWithCalendar(void); | |
7393aa2f | 230 | |
46f4442e A |
231 | public: |
232 | /*** | |
233 | * Test Relative Dates | |
234 | */ | |
235 | void TestRelative(void); | |
46f4442e A |
236 | /* void TestRelativeError(void); |
237 | void TestRelativeOther(void); | |
238 | */ | |
239 | ||
51004dcb | 240 | void TestDotAndAtLeniency(); |
57a6839d A |
241 | |
242 | void TestDateFormatLeniency(); | |
243 | ||
244 | void TestParseMultiPatternMatch(); | |
245 | ||
246 | void TestParseLeniencyAPIs(); | |
247 | ||
b331163b A |
248 | // test override NumberFormat |
249 | void TestNumberFormatOverride(); | |
250 | void TestCreateInstanceForSkeleton(); | |
251 | void TestCreateInstanceForSkeletonDefault(); | |
252 | void TestCreateInstanceForSkeletonWithCalendar(); | |
253 | void TestDFSCreateForLocaleNonGregorianLocale(); | |
254 | void TestDFSCreateForLocaleWithCalendarInLocale(); | |
255 | void TestChangeCalendar(); | |
256 | ||
2ca993e8 A |
257 | void TestPatternFromSkeleton(); |
258 | ||
259 | void TestAmPmMidnightNoon(); | |
260 | void TestFlexibleDayPeriod(); | |
261 | void TestDayPeriodWithLocales(); | |
262 | void TestMinuteSecondFieldsInOddPlaces(); | |
263 | void TestDayPeriodParsing(); | |
0f5d89e8 | 264 | void TestParseRegression13744(); |
2ca993e8 | 265 | |
51004dcb A |
266 | private: |
267 | UBool showParse(DateFormat &format, const UnicodeString &formattedString); | |
268 | ||
7393aa2f A |
269 | public: |
270 | /** | |
271 | * Test parsing a number as a string | |
272 | */ | |
273 | void TestNumberAsStringParsing(void); | |
729e4ab9 A |
274 | |
275 | private: | |
2ca993e8 | 276 | void TestRelative(int daysdelta, |
46f4442e A |
277 | const Locale& loc, |
278 | const char *expectChars); | |
73c04bcf | 279 | |
b75a7d8f A |
280 | private: |
281 | void expectParse(const char** data, int32_t data_length, | |
282 | const Locale& locale); | |
374ca955 A |
283 | |
284 | void expect(const char** data, int32_t data_length, | |
285 | const Locale& loc); | |
73c04bcf A |
286 | |
287 | void expectFormat(const char **data, int32_t data_length, | |
288 | const Locale &locale); | |
2ca993e8 | 289 | |
b75a7d8f A |
290 | }; |
291 | ||
292 | #endif /* #if !UCONFIG_NO_FORMATTING */ | |
2ca993e8 | 293 | |
b75a7d8f A |
294 | #endif // _DATEFORMATTEST_ |
295 | //eof |