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