]> git.saurik.com Git - apple/icu.git/blame_incremental - icuSources/test/intltest/dtptngts.cpp
ICU-511.32.tar.gz
[apple/icu.git] / icuSources / test / intltest / dtptngts.cpp
... / ...
CommitLineData
1/********************************************************************
2 * COPYRIGHT:
3 * Copyright (c) 2008-2013, International Business Machines Corporation and
4 * others. All Rights Reserved.
5 ********************************************************************/
6
7#include "unicode/utypes.h"
8
9#if !UCONFIG_NO_FORMATTING
10
11#include <stdio.h>
12#include <stdlib.h>
13#include "dtptngts.h"
14
15#include "unicode/calendar.h"
16#include "unicode/smpdtfmt.h"
17#include "unicode/dtfmtsym.h"
18#include "unicode/dtptngen.h"
19#include "loctest.h"
20
21
22// This is an API test, not a unit test. It doesn't test very many cases, and doesn't
23// try to test the full functionality. It just calls each function in the class and
24// verifies that it works on a basic level.
25
26void IntlTestDateTimePatternGeneratorAPI::runIndexedTest( int32_t index, UBool exec, const char* &name, char* /*par*/ )
27{
28 if (exec) logln("TestSuite DateTimePatternGeneratorAPI");
29 switch (index) {
30 TESTCASE(0, testAPI);
31 TESTCASE(1, testOptions);
32 default: name = ""; break;
33 }
34}
35
36#define MAX_LOCALE 11
37
38/**
39 * Test various generic API methods of DateTimePatternGenerator for API coverage.
40 */
41void IntlTestDateTimePatternGeneratorAPI::testAPI(/*char *par*/)
42{
43 UnicodeString patternData[] = {
44 UnicodeString("yM"), // 00
45 UnicodeString("yMMM"), // 01
46 UnicodeString("yMd"), // 02
47 UnicodeString("yMMMd"), // 03
48 UnicodeString("Md"), // 04
49 UnicodeString("MMMd"), // 05
50 UnicodeString("MMMMd"), // 06
51 UnicodeString("yQQQ"), // 07
52 UnicodeString("hhmm"), // 08
53 UnicodeString("HHmm"), // 09
54 UnicodeString("jjmm"), // 10
55 UnicodeString("mmss"), // 11
56 UnicodeString("yyyyMMMM"), // 12
57 UnicodeString("MMMEd"), // 13
58 UnicodeString("Ed"), // 14
59 UnicodeString("jmmssSSS"), // 15
60 UnicodeString(),
61 };
62
63 const char* testLocale[MAX_LOCALE][4] = {
64 {"en", "US", "", ""}, // 0
65 {"en", "US", "", "calendar=japanese"}, // 1
66 {"de", "DE", "", ""}, // 2
67 {"fi", "", "", ""}, // 3
68 {"es", "", "", ""}, // 4
69 {"ja", "", "", ""}, // 5
70 {"ja", "", "", "calendar=japanese"}, // 6
71 {"zh", "Hans", "CN", ""}, // 7
72 {"zh", "TW", "", "calendar=roc"}, // 8
73 {"ru", "", "", ""}, // 9
74 {"zh", "", "", "calendar=chinese"}, // 10
75 };
76
77 // For Weds, Jan 13, 1999, 23:58:59
78 UnicodeString patternResults[] = {
79 // en_US // 0 en_US
80 UnicodeString("1/1999"), // 00: yM
81 UnicodeString("Jan 1999"), // 01: yMMM
82 UnicodeString("1/13/1999"), // 02: yMd
83 UnicodeString("Jan 13, 1999"), // 03: yMMMd
84 UnicodeString("1/13"), // 04: Md
85 UnicodeString("Jan 13"), // 05: MMMd
86 UnicodeString("January 13"), // 06: MMMMd
87 UnicodeString("Q1 1999"), // 07: yQQQ
88 UnicodeString("11:58 PM"), // 08: hhmm
89 UnicodeString("23:58"), // 09: HHmm
90 UnicodeString("11:58 PM"), // 10: jjmm
91 UnicodeString("58:59"), // 11: mmss
92 UnicodeString("January 1999"), // 12: yyyyMMMM
93 UnicodeString("Wed, Jan 13"), // 13: MMMEd -> EEE, MMM d
94 UnicodeString("13 Wed"), // 14: Ed -> d EEE
95 UnicodeString("11:58:59.123 PM"), // 15: jmmssSSS -> "h:mm:ss.SSS a"
96
97 // en_US@calendar=japanese // 1 en_US@calendar=japanese
98 UnicodeString("1/11 H"), // 0: yM
99 UnicodeString("Jan 11 Heisei"), // 1: yMMM
100 UnicodeString("1/13/11 H"), // 2: yMd
101 UnicodeString("Jan 13, 11 Heisei"), // 3: yMMMd
102 UnicodeString("1/13"), // 4: Md
103 UnicodeString("Jan 13"), // 5: MMMd
104 UnicodeString("January 13"), // 6: MMMMd
105 UnicodeString("Q1 11 Heisei"), // 7: yQQQ
106 UnicodeString("11:58 PM"), // 8: hhmm
107 UnicodeString("23:58"), // 9: HHmm
108 UnicodeString("11:58 PM"), // 10: jjmm
109 UnicodeString("58:59"), // 11: mmss
110 UnicodeString("January 11 Heisei"), // 12: yyyyMMMM
111 UnicodeString("Wed, Jan 13"), // 13: MMMEd -> EEE, MMM d"
112 UnicodeString("13 Wed"), // 14: Ed -> d EEE
113 UnicodeString("11:58:59.123 PM"), // 15: jmmssSSS -> "h:mm:ss.SSS a"
114
115 // de_DE // 2 de_DE
116 UnicodeString("1.1999"), // 00: yM
117 UnicodeString("Jan. 1999"), // 01: yMMM
118 UnicodeString("13.1.1999"), // 02: yMd
119 UnicodeString("13. Jan. 1999"), // 03: yMMMd
120 UnicodeString("13.1."), // 04: Md
121 UnicodeString("13. Jan."), // 05: MMMd
122 UnicodeString("13. Januar"), // 06: MMMMd
123 UnicodeString("Q1 1999"), // 07: yQQQ
124 UnicodeString("11:58 nachm."), // 08: hhmm
125 UnicodeString("23:58"), // 09: HHmm
126 UnicodeString("23:58"), // 10: jjmm
127 UnicodeString("58:59"), // 11: mmss
128 UnicodeString("Januar 1999"), // 12: yyyyMMMM
129 UnicodeString("Mi., 13. Jan."), // 13: MMMEd -> EEE, d. MMM
130 UnicodeString("Mi., 13."), // 14: Ed -> EEE d.
131 UnicodeString("23:58:59,123"), // 15: jmmssSSS -> "HH:mm:ss,SSS"
132
133 // fi // 3 fi
134 UnicodeString("1.1999"), // 00: yM (fixed expected result per ticket:6626:)
135 UnicodeString("tammi 1999"), // 01: yMMM
136 UnicodeString("13.1.1999"), // 02: yMd
137 UnicodeString("13. tammikuuta 1999"), // 03: yMMMd
138 UnicodeString("13.1."), // 04: Md
139 UnicodeString("13.1."), // 05: MMMd
140 UnicodeString("13. tammikuuta"), // 06: MMMMd
141 UnicodeString("1. nelj. 1999"), // 07: yQQQ
142 UnicodeString("11.58 ip."), // 08: hhmm
143 UnicodeString("23.58"), // 09: HHmm
144 UnicodeString("23.58"), // 10: jjmm
145 UnicodeString("58.59"), // 11: mmss
146 UnicodeString("tammikuu 1999"), // 12: yyyyMMMM
147 UnicodeString("ke 13. tammikuuta"), // 13: MMMEd -> EEE d. MMM
148 UnicodeString("ke 13."), // 14: Ed -> ccc d.
149 UnicodeString("23.58.59,123"), // 15: jmmssSSS -> "H.mm.ss,SSS"
150
151 // es // 4 es
152 UnicodeString("1/1999"), // 00: yM -> "M/y"
153 UnicodeString("ene 1999"), // 01: yMMM -> "MMM y"
154 UnicodeString("13/1/1999"), // 02: yMd -> "d/M/y"
155 UnicodeString("13 ene 1999"), // 03: yMMMd -> "d MMM y"
156 UnicodeString("13/1"), // 04: Md -> "d/M"
157 UnicodeString("13 ene"), // 05: MMMd -> "d MMM"
158 UnicodeString("13 de enero"), // 06: MMMMd -> "d 'de' MMMM"
159 UnicodeString("T1 1999"), // 07: yQQQ -> "QQQ y"
160 UnicodeString("11:58 p.m."), // 08: hhmm -> "hh:mm a"
161 UnicodeString("23:58"), // 09: HHmm -> "HH:mm"
162 UnicodeString("23:58"), // 10: jjmm -> "HH:mm"
163 UnicodeString("58:59"), // 11: mmss -> "mm:ss"
164 UnicodeString("enero de 1999"), // 12: yyyyMMMM -> "MMMM 'de' yyyy"
165 CharsToUnicodeString("mi\\u00E9 13 ene"), // 13: MMMEd -> "E d MMM"
166 CharsToUnicodeString("mi\\u00E9 13"), // 14: Ed -> "EEE d"
167 UnicodeString("23:58:59,123"), // 15: jmmssSSS -> "H:mm:ss,SSS"
168
169 // ja // 5 ja
170 UnicodeString("1999/1"), // 00: yM -> y/M
171 CharsToUnicodeString("1999\\u5E741\\u6708"), // 01: yMMM -> y\u5E74M\u6708
172 UnicodeString("1999/1/13"), // 02: yMd -> y/M/d
173 CharsToUnicodeString("1999\\u5E741\\u670813\\u65E5"), // 03: yMMMd -> y\u5E74M\u6708d\u65E5
174 UnicodeString("1/13"), // 04: Md -> M/d
175 CharsToUnicodeString("1\\u670813\\u65E5"), // 05: MMMd -> M\u6708d\u65E5
176 CharsToUnicodeString("1\\u670813\\u65E5"), // 06: MMMMd -> M\u6708d\u65E5
177 UnicodeString("1999/1Q"), // 07: yQQQ -> yQQQ
178 CharsToUnicodeString("\\u5348\\u5F8C11:58"), // 08: hhmm
179 UnicodeString("23:58"), // 09: HHmm -> HH:mm
180 UnicodeString("23:58"), // 10: jjmm
181 UnicodeString("58:59"), // 11: mmss -> mm:ss
182 CharsToUnicodeString("1999\\u5E741\\u6708"), // 12: yyyyMMMM -> y\u5E74M\u6708
183 CharsToUnicodeString("1\\u670813\\u65E5(\\u6C34)"), // 13: MMMEd -> M\u6708d\u65E5(EEE)
184 CharsToUnicodeString("13\\u65E5(\\u6C34)"), // 14: Ed -> d\u65E5(EEE)
185 UnicodeString("23:58:59.123"), // 15: jmmssSSS -> "H:mm:ss.SSS"
186
187 // ja@calendar=japanese // 6 ja@calendar=japanese
188 CharsToUnicodeString("H11/1"), // 00: yM -> GGGGGy/m
189 CharsToUnicodeString("\\u5E73\\u621011\\u5E741\\u6708"), // 01: yMMM -> Gy\u5E74M\u6708
190 CharsToUnicodeString("H11/1/13"), // 02: yMd -> GGGGGy/m/d
191 CharsToUnicodeString("\\u5E73\\u621011\\u5E741\\u670813\\u65E5"), // 03: yMMMd -> Gy\u5E74M\u6708d\u65E5
192 UnicodeString("1/13"), // 04: Md -> M/d
193 CharsToUnicodeString("1\\u670813\\u65E5"), // 05: MMMd -> M\u6708d\u65E5
194 CharsToUnicodeString("1\\u670813\\u65E5"), // 06: MMMMd -> M\u6708d\u65E5
195 CharsToUnicodeString("\\u5E73\\u621011/1Q"), // 07: yQQQ -> Gy/QQQ
196 CharsToUnicodeString("\\u5348\\u5F8C11:58"), // 08: hhmm ->
197 UnicodeString("23:58"), // 09: HHmm -> HH:mm (as for ja)
198 UnicodeString("23:58"), // 10: jjmm
199 UnicodeString("58:59"), // 11: mmss -> mm:ss (as for ja)
200 CharsToUnicodeString("\\u5E73\\u621011\\u5E741\\u6708"), // 12: yyyyMMMM -> Gyyyy\u5E74M\u6708
201 CharsToUnicodeString("1\\u670813\\u65E5(\\u6C34)"), // 13: MMMEd -> M\u6708d\u65E5(EEE)
202 CharsToUnicodeString("13\\u65E5(\\u6C34)"), // 14: Ed -> d\u65E5(EEE)
203 UnicodeString("23:58:59.123"), // 15: jmmssSSS -> "H:mm:ss.SSS"
204
205 // zh_Hans_CN // 7 zh_Hans_CN
206 UnicodeString("1999/1", -1, US_INV), // 00: yM
207 CharsToUnicodeString("1999\\u5E741\\u6708"), // 01: yMMM -> yyyy\u5E74MMM (fixed expected result per ticket:6626:)
208 CharsToUnicodeString("1999/1/13"), // 02: yMd
209 CharsToUnicodeString("1999\\u5E741\\u670813\\u65E5"), // 03: yMMMd -> yyyy\u5E74MMMd\u65E5 (fixed expected result per ticket:6626:)
210 UnicodeString("1/13"), // 04: Md
211 CharsToUnicodeString("1\\u670813\\u65E5"), // 05: MMMd -> M\u6708d\u65E5 (fixed expected result per ticket:6626:)
212 CharsToUnicodeString("1\\u670813\\u65E5"), // 06: MMMMd -> M\u6708d\u65E5
213 CharsToUnicodeString("1999\\u5E74\\u7B2C1\\u5B63\\u5EA6"), // 07: yQQQ
214 CharsToUnicodeString("\\u4E0B\\u534811:58"), // 08: hhmm
215 UnicodeString("23:58"), // 09: HHmm
216 CharsToUnicodeString("\\u4E0B\\u534811:58"), // 10: jjmm
217 UnicodeString("58:59"), // 11: mmss
218 CharsToUnicodeString("1999\\u5E741\\u6708"), // 12: yyyyMMMM -> yyyy\u5E74MMM
219 CharsToUnicodeString("1\\u670813\\u65E5 \\u5468\\u4E09"), // 13: MMMEd -> MMMd\u65E5EEE
220 CharsToUnicodeString("13\\u65E5\\u5468\\u4E09"), // 14: Ed -> d\u65E5EEE
221 CharsToUnicodeString("\\u4E0B\\u534811:58:59.123"), // 15: jmmssSSS -> "ah:mm:ss.SSS"
222
223 // zh_TW@calendar=roc // 8 zh_TW@calendar=roc
224 CharsToUnicodeString("\\u6C11\\u570B88/1"), // 00: yM -> Gy/M
225 CharsToUnicodeString("\\u6C11\\u570B88\\u5E741\\u6708"), // 01: yMMM -> Gy\u5E74M\u6708
226 CharsToUnicodeString("\\u6C11\\u570B88/1/13"), // 02: yMd -> Gy/M/d
227 CharsToUnicodeString("\\u6C11\\u570B88\\u5E741\\u670813\\u65E5"), // 03: yMMMd -> Gy\u5E74M\u6708d\u65E5
228 UnicodeString("1/13"), // 04: Md -> M/d
229 CharsToUnicodeString("1\\u670813\\u65E5"), // 05: MMMd ->M\u6708d\u65E5
230 CharsToUnicodeString("1\\u670813\\u65E5"), // 06: MMMMd ->M\u6708d\u65E5
231 CharsToUnicodeString("\\u6C11\\u570B88\\u5E741\\u5B63"), // 07: yQQQ -> Gy QQQ
232 CharsToUnicodeString("\\u4E0B\\u534811:58"), // 08: hhmm ->
233 UnicodeString("23:58"), // 09: HHmm ->
234 CharsToUnicodeString("\\u4E0B\\u534811:58"), // 10: jjmm
235 UnicodeString("58:59"), // 11: mmss ->
236 CharsToUnicodeString("\\u6C11\\u570B88\\u5E741\\u6708"), // 12: yyyyMMMM -> Gy\u5E74M\u670
237 CharsToUnicodeString("1\\u670813\\u65E5\\u9031\\u4E09"), // 13: MMMEd -> M\u6708d\u65E5EEE
238 CharsToUnicodeString("13\\u65E5\\uff08\\u9031\\u4E09\\uff09"), // 14: Ed -> d\u65E5\\uff08EEEi\\uff09
239 CharsToUnicodeString("\\u4E0B\\u534811:58:59.123"), // 15: jmmssSSS -> "ah:mm:ss.SSS"
240
241 // ru // 9 ru
242 UnicodeString("01.1999"), // 00: yM -> MM.y
243 CharsToUnicodeString("\\u042F\\u043D\\u0432. 1999"), // 01: yMMM -> LLL y
244 UnicodeString("13.01.1999"), // 02: yMd -> dd.MM.y
245 CharsToUnicodeString("13 \\u044F\\u043D\\u0432. 1999 \\u0433."), // 03: yMMMd -> d MMM y
246 UnicodeString("13.01"), // 04: Md -> dd.MM
247 CharsToUnicodeString("13 \\u044F\\u043D\\u0432."), // 05: MMMd -> d MMM
248 CharsToUnicodeString("13 \\u044F\\u043D\\u0432\\u0430\\u0440\\u044F"), // 06: MMMMd -> d MMMM
249 CharsToUnicodeString("1-\\u0439 \\u043A\\u0432. 1999 \\u0433."), // 07: yQQQ -> y QQQ
250 CharsToUnicodeString("11:58 \\u043F\\u043E\\u0441\\u043B\\u0435 \\u043F\\u043E\\u043B\\u0443\\u0434\\u043D\\u044F"), // 07: hhmm -> hh:mm a
251 UnicodeString("23:58"), // 09: HHmm -> HH:mm
252 UnicodeString("23:58"), // 10: jjmm -> HH:mm
253 UnicodeString("58:59"), // 11: mmss -> mm:ss
254 CharsToUnicodeString("\\u042F\\u043D\\u0432\\u0430\\u0440\\u044C 1999"), // 12: yyyyMMMM -> LLLL y
255 CharsToUnicodeString("\\u0421\\u0440, 13 \\u044F\\u043D\\u0432."), // 13: MMMEd -> ccc, d MMM
256 CharsToUnicodeString("\\u0421\\u0440, 13"), // 14: Ed -> EEE, d
257 UnicodeString("23:58:59,123"), // 15: jmmssSSS -> "H:mm:ss,SSS"
258
259 // zh@calendar=chinese // 10 zh@calendar=chinese
260 CharsToUnicodeString("\\u620A\\u5BC5\\u5E7411\\u6708"), // 00: yM
261 CharsToUnicodeString("\\u620A\\u5BC5\\u5E74\\u5341\\u4E00\\u6708"), // 01: yMMM
262 CharsToUnicodeString("\\u620A\\u5BC5\\u5E7411\\u670826\\u65E5"), // 02: yMd
263 CharsToUnicodeString("\\u620A\\u5BC5\\u5E74\\u5341\\u4E00\\u670826\\u65E5"), // 03: yMMMd
264 UnicodeString("11-26"), // 04: Md
265 CharsToUnicodeString("\\u5341\\u4E00\\u670826\\u65E5"), // 05: MMMd
266 CharsToUnicodeString("\\u5341\\u4E00\\u670826\\u65E5"), // 06: MMMMd
267 CharsToUnicodeString("\\u620A\\u5BC5\\u5E74\\u7b2c\\u56db\\u5B63\\u5EA6"), // 07: yQQQ
268 CharsToUnicodeString("\\u4E0B\\u534811:58"), // 08: hhmm
269 UnicodeString("23:58"), // 09: HHmm
270 CharsToUnicodeString("\\u4E0B\\u534811:58"), // 10: jjmm
271 UnicodeString("58:59"), // 11: mmss
272 CharsToUnicodeString("\\u620A\\u5BC5\\u5E74\\u5341\\u4E00\\u6708"), // 12: yyyyMMMM
273 CharsToUnicodeString("\\u5341\\u4E00\\u670826\\u65E5\\u5468\\u4E09"), // 13: MMMEd
274 CharsToUnicodeString("26\\u65E5\\u5468\\u4E09"), // 14: Ed -> d\u65E5EEE
275 CharsToUnicodeString("\\u4E0B\\u534811:58:59.123"), // 15: jmmssSS
276
277 UnicodeString(),
278 };
279
280 UnicodeString patternTests2[] = {
281 UnicodeString("yyyyMMMdd"),
282 UnicodeString("yyyyqqqq"),
283 UnicodeString("yMMMdd"),
284 UnicodeString("EyyyyMMMdd"),
285 UnicodeString("yyyyMMdd"),
286 UnicodeString("yyyyMMM"),
287 UnicodeString("yyyyMM"),
288 UnicodeString("yyMM"),
289 UnicodeString("yMMMMMd"),
290 UnicodeString("EEEEEMMMMMd"),
291 UnicodeString("MMMd"),
292 UnicodeString("MMMdhmm"),
293 UnicodeString("EMMMdhmms"),
294 UnicodeString("MMdhmm"),
295 UnicodeString("EEEEMMMdhmms"),
296 UnicodeString("yyyyMMMddhhmmss"),
297 UnicodeString("EyyyyMMMddhhmmss"),
298 UnicodeString("hmm"),
299 UnicodeString("hhmm"),
300 UnicodeString("hhmmVVVV"),
301 UnicodeString(""),
302 };
303 UnicodeString patternResults2[] = {
304 UnicodeString("Oct 14, 1999"),
305 UnicodeString("4th quarter 1999"),
306 UnicodeString("Oct 14, 1999"),
307 UnicodeString("Thu, Oct 14, 1999"),
308 UnicodeString("10/14/1999"),
309 UnicodeString("Oct 1999"),
310 UnicodeString("10/1999"),
311 UnicodeString("10/99"),
312 UnicodeString("O 14, 1999"),
313 UnicodeString("T, O 14"),
314 UnicodeString("Oct 14"),
315 UnicodeString("Oct 14, 6:58 AM"),
316 UnicodeString("Thu, Oct 14, 6:58:59 AM"),
317 UnicodeString("10/14, 6:58 AM"),
318 UnicodeString("Thursday, Oct 14, 6:58:59 AM"),
319 UnicodeString("Oct 14, 1999, 6:58:59 AM"),
320 UnicodeString("Thu, Oct 14, 1999, 6:58:59 AM"),
321 UnicodeString("6:58 AM"),
322 UnicodeString("6:58 AM"),
323 UnicodeString("6:58 AM GMT"),
324 UnicodeString(""),
325 };
326
327 // results for getSkeletons() and getPatternForSkeleton()
328 const UnicodeString testSkeletonsResults[] = {
329 UnicodeString("HH:mm"),
330 UnicodeString("MMMMd"),
331 UnicodeString("MMMMMdd"),
332 };
333
334 const UnicodeString testBaseSkeletonsResults[] = {
335 UnicodeString("Hm"),
336 UnicodeString("MMMMd"),
337 UnicodeString("MMMMMd"),
338 };
339
340 UnicodeString newDecimal(" "); // space
341 UnicodeString newAppendItemName("hrs.");
342 UnicodeString newAppendItemFormat("{1} {0}");
343 UnicodeString newDateTimeFormat("{1} {0}");
344 UErrorCode status = U_ZERO_ERROR;
345 UnicodeString conflictingPattern;
346 UDateTimePatternConflict conflictingStatus = UDATPG_NO_CONFLICT;
347 (void)conflictingStatus; // Suppress set but not used warning.
348
349 // ======= Test CreateInstance with default locale
350 logln("Testing DateTimePatternGenerator createInstance from default locale");
351
352 DateTimePatternGenerator *instFromDefaultLocale=DateTimePatternGenerator::createInstance(status);
353 if (U_FAILURE(status)) {
354 dataerrln("ERROR: Could not create DateTimePatternGenerator (default) - exitting");
355 return;
356 }
357 else {
358 delete instFromDefaultLocale;
359 }
360
361 // ======= Test CreateInstance with given locale
362 logln("Testing DateTimePatternGenerator createInstance from French locale");
363 status = U_ZERO_ERROR;
364 DateTimePatternGenerator *instFromLocale=DateTimePatternGenerator::createInstance(Locale::getFrench(), status);
365 if (U_FAILURE(status)) {
366 dataerrln("ERROR: Could not create DateTimePatternGenerator (Locale::getFrench()) - exitting");
367 return;
368 }
369
370 // ======= Test clone DateTimePatternGenerator
371 logln("Testing DateTimePatternGenerator::clone()");
372 status = U_ZERO_ERROR;
373
374
375 UnicodeString decimalSymbol = instFromLocale->getDecimal();
376 UnicodeString newDecimalSymbol = UnicodeString("*");
377 decimalSymbol = instFromLocale->getDecimal();
378 instFromLocale->setDecimal(newDecimalSymbol);
379 DateTimePatternGenerator *cloneDTPatternGen=instFromLocale->clone();
380 decimalSymbol = cloneDTPatternGen->getDecimal();
381 if (decimalSymbol != newDecimalSymbol) {
382 errln("ERROR: inconsistency is found in cloned object.");
383 }
384 if ( !(*cloneDTPatternGen == *instFromLocale) ) {
385 errln("ERROR: inconsistency is found in cloned object.");
386 }
387
388 if ( *cloneDTPatternGen != *instFromLocale ) {
389 errln("ERROR: inconsistency is found in cloned object.");
390 }
391
392 delete instFromLocale;
393 delete cloneDTPatternGen;
394
395 // ======= Test simple use cases
396 logln("Testing simple use cases");
397 status = U_ZERO_ERROR;
398 Locale deLocale=Locale::getGermany();
399 UDate sampleDate=LocaleTest::date(99, 9, 13, 23, 58, 59);
400 DateTimePatternGenerator *gen = DateTimePatternGenerator::createInstance(deLocale, status);
401 if (U_FAILURE(status)) {
402 dataerrln("ERROR: Could not create DateTimePatternGenerator (Locale::getGermany()) - exitting");
403 return;
404 }
405 UnicodeString findPattern = gen->getBestPattern(UnicodeString("MMMddHmm"), status);
406 SimpleDateFormat *format = new SimpleDateFormat(findPattern, deLocale, status);
407 if (U_FAILURE(status)) {
408 dataerrln("ERROR: Could not create SimpleDateFormat (Locale::getGermany())");
409 delete gen;
410 return;
411 }
412 TimeZone *zone = TimeZone::createTimeZone(UnicodeString("ECT"));
413 if (zone==NULL) {
414 dataerrln("ERROR: Could not create TimeZone ECT");
415 delete gen;
416 delete format;
417 return;
418 }
419 format->setTimeZone(*zone);
420 UnicodeString dateReturned, expectedResult;
421 dateReturned.remove();
422 dateReturned = format->format(sampleDate, dateReturned, status);
423 expectedResult=UnicodeString("14. Okt. 08:58", -1, US_INV);
424 if ( dateReturned != expectedResult ) {
425 errln("ERROR: Simple test in getBestPattern with Locale::getGermany()).");
426 }
427 // add new pattern
428 status = U_ZERO_ERROR;
429 conflictingStatus = gen->addPattern(UnicodeString("d'. von' MMMM", -1, US_INV), true, conflictingPattern, status);
430 if (U_FAILURE(status)) {
431 errln("ERROR: Could not addPattern - d\'. von\' MMMM");
432 }
433 status = U_ZERO_ERROR;
434 UnicodeString testPattern=gen->getBestPattern(UnicodeString("MMMMdd"), status);
435 testPattern=gen->getBestPattern(UnicodeString("MMMddHmm"), status);
436 format->applyPattern(gen->getBestPattern(UnicodeString("MMMMdHmm"), status));
437 dateReturned.remove();
438 dateReturned = format->format(sampleDate, dateReturned, status);
439 expectedResult=UnicodeString("14. von Oktober 08:58", -1, US_INV);
440 if ( dateReturned != expectedResult ) {
441 errln(UnicodeString("ERROR: Simple test addPattern failed!: d\'. von\' MMMM Got: ") + dateReturned + UnicodeString(" Expected: ") + expectedResult);
442 }
443 delete format;
444
445 // get a pattern and modify it
446 format = (SimpleDateFormat *)DateFormat::createDateTimeInstance(DateFormat::kFull, DateFormat::kFull,
447 deLocale);
448 format->setTimeZone(*zone);
449 UnicodeString pattern;
450 pattern = format->toPattern(pattern);
451 dateReturned.remove();
452 dateReturned = format->format(sampleDate, dateReturned, status);
453 expectedResult=CharsToUnicodeString("Donnerstag, 14. Oktober 1999 08:58:59 Mitteleurop\\u00E4ische Sommerzeit");
454 if ( dateReturned != expectedResult ) {
455 errln("ERROR: Simple test uses full date format.");
456 errln(UnicodeString(" Got: ") + dateReturned + UnicodeString(" Expected: ") + expectedResult);
457 }
458
459 // modify it to change the zone.
460 UnicodeString newPattern = gen->replaceFieldTypes(pattern, UnicodeString("vvvv"), status);
461 format->applyPattern(newPattern);
462 dateReturned.remove();
463 dateReturned = format->format(sampleDate, dateReturned, status);
464 expectedResult=CharsToUnicodeString("Donnerstag, 14. Oktober 1999 08:58:59 Mitteleurop\\u00E4ische Zeit");
465 if ( dateReturned != expectedResult ) {
466 errln("ERROR: Simple test modify the timezone!");
467 errln(UnicodeString(" Got: ")+ dateReturned + UnicodeString(" Expected: ") + expectedResult);
468 }
469
470 // setDeciaml(), getDeciaml()
471 gen->setDecimal(newDecimal);
472 if (newDecimal != gen->getDecimal()) {
473 errln("ERROR: unexpected result from setDecimal() and getDecimal()!.\n");
474 }
475
476 // setAppenItemName() , getAppendItemName()
477 gen->setAppendItemName(UDATPG_HOUR_FIELD, newAppendItemName);
478 if (newAppendItemName != gen->getAppendItemName(UDATPG_HOUR_FIELD)) {
479 errln("ERROR: unexpected result from setAppendItemName() and getAppendItemName()!.\n");
480 }
481
482 // setAppenItemFormat() , getAppendItemFormat()
483 gen->setAppendItemFormat(UDATPG_HOUR_FIELD, newAppendItemFormat);
484 if (newAppendItemFormat != gen->getAppendItemFormat(UDATPG_HOUR_FIELD)) {
485 errln("ERROR: unexpected result from setAppendItemFormat() and getAppendItemFormat()!.\n");
486 }
487
488 // setDateTimeFormat() , getDateTimeFormat()
489 gen->setDateTimeFormat(newDateTimeFormat);
490 if (newDateTimeFormat != gen->getDateTimeFormat()) {
491 errln("ERROR: unexpected result from setDateTimeFormat() and getDateTimeFormat()!.\n");
492 }
493
494 // ======== Test getSkeleton and getBaseSkeleton
495 status = U_ZERO_ERROR;
496 pattern = UnicodeString("dd-MMM");
497 UnicodeString expectedSkeleton = UnicodeString("MMMdd");
498 UnicodeString expectedBaseSkeleton = UnicodeString("MMMd");
499 UnicodeString retSkeleton = gen->getSkeleton(pattern, status);
500 if(U_FAILURE(status) || retSkeleton != expectedSkeleton ) {
501 errln("ERROR: Unexpected result from getSkeleton().\n");
502 errln(UnicodeString(" Got: ") + retSkeleton + UnicodeString(" Expected: ") + expectedSkeleton );
503 }
504 retSkeleton = gen->getBaseSkeleton(pattern, status);
505 if(U_FAILURE(status) || retSkeleton != expectedBaseSkeleton) {
506 errln("ERROR: Unexpected result from getBaseSkeleton().\n");
507 errln(UnicodeString(" Got: ") + retSkeleton + UnicodeString(" Expected:")+ expectedBaseSkeleton);
508 }
509
510 pattern = UnicodeString("dd/MMMM/yy");
511 expectedSkeleton = UnicodeString("yyMMMMdd");
512 expectedBaseSkeleton = UnicodeString("yMMMMd");
513 retSkeleton = gen->getSkeleton(pattern, status);
514 if(U_FAILURE(status) || retSkeleton != expectedSkeleton ) {
515 errln("ERROR: Unexpected result from getSkeleton().\n");
516 errln(UnicodeString(" Got: ") + retSkeleton + UnicodeString(" Expected: ") + expectedSkeleton );
517 }
518 retSkeleton = gen->getBaseSkeleton(pattern, status);
519 if(U_FAILURE(status) || retSkeleton != expectedBaseSkeleton) {
520 errln("ERROR: Unexpected result from getBaseSkeleton().\n");
521 errln(UnicodeString(" Got: ") + retSkeleton + UnicodeString(" Expected:")+ expectedBaseSkeleton);
522 }
523 delete format;
524 delete zone;
525 delete gen;
526
527 {
528 // Trac# 6104
529 status = U_ZERO_ERROR;
530 pattern = UnicodeString("YYYYMMM");
531 UnicodeString expR = CharsToUnicodeString("1999\\u5E741\\u6708"); // fixed expected result per ticket:6626:
532 Locale loc("ja");
533 UDate testDate1= LocaleTest::date(99, 0, 13, 23, 58, 59);
534 DateTimePatternGenerator *patGen=DateTimePatternGenerator::createInstance(loc, status);
535 if(U_FAILURE(status)) {
536 dataerrln("ERROR: Could not create DateTimePatternGenerator");
537 return;
538 }
539 UnicodeString bPattern = patGen->getBestPattern(pattern, status);
540 UnicodeString rDate;
541 SimpleDateFormat sdf(bPattern, loc, status);
542 rDate.remove();
543 rDate = sdf.format(testDate1, rDate);
544
545 logln(UnicodeString(" ja locale with skeleton: YYYYMMM Best Pattern:") + bPattern);
546 logln(UnicodeString(" Formatted date:") + rDate);
547
548 if ( expR!= rDate ) {
549 errln(UnicodeString("\nERROR: Test Japanese month hack Got: ") + rDate +
550 UnicodeString(" Expected: ") + expR );
551 }
552
553 delete patGen;
554 }
555 { // Trac# 6104
556 Locale loc("zh");
557 UnicodeString expR = CharsToUnicodeString("1999\\u5E741\\u6708"); // fixed expected result per ticket:6626:
558 UDate testDate1= LocaleTest::date(99, 0, 13, 23, 58, 59);
559 DateTimePatternGenerator *patGen=DateTimePatternGenerator::createInstance(loc, status);
560 if(U_FAILURE(status)) {
561 dataerrln("ERROR: Could not create DateTimePatternGenerator");
562 return;
563 }
564 UnicodeString bPattern = patGen->getBestPattern(pattern, status);
565 UnicodeString rDate;
566 SimpleDateFormat sdf(bPattern, loc, status);
567 rDate.remove();
568 rDate = sdf.format(testDate1, rDate);
569
570 logln(UnicodeString(" zh locale with skeleton: YYYYMMM Best Pattern:") + bPattern);
571 logln(UnicodeString(" Formatted date:") + rDate);
572 if ( expR!= rDate ) {
573 errln(UnicodeString("\nERROR: Test Chinese month hack Got: ") + rDate +
574 UnicodeString(" Expected: ") + expR );
575 }
576 delete patGen;
577 }
578
579 {
580 // Trac# 6172 duplicate time pattern
581 status = U_ZERO_ERROR;
582 pattern = UnicodeString("hmv");
583 UnicodeString expR = UnicodeString("h:mm a v"); // avail formats has hm -> "h:mm a" (fixed expected result per ticket:6626:)
584 Locale loc("en");
585 DateTimePatternGenerator *patGen=DateTimePatternGenerator::createInstance(loc, status);
586 if(U_FAILURE(status)) {
587 dataerrln("ERROR: Could not create DateTimePatternGenerator");
588 return;
589 }
590 UnicodeString bPattern = patGen->getBestPattern(pattern, status);
591 logln(UnicodeString(" en locale with skeleton: hmv Best Pattern:") + bPattern);
592
593 if ( expR!= bPattern ) {
594 errln(UnicodeString("\nERROR: Test EN time format Got: ") + bPattern +
595 UnicodeString(" Expected: ") + expR );
596 }
597
598 delete patGen;
599 }
600
601
602 // ======= Test various skeletons.
603 logln("Testing DateTimePatternGenerator with various skeleton");
604
605 status = U_ZERO_ERROR;
606 int32_t localeIndex=0;
607 int32_t resultIndex=0;
608 UnicodeString resultDate;
609 UDate testDate= LocaleTest::date(99, 0, 13, 23, 58, 59) + 123.0;
610 while (localeIndex < MAX_LOCALE )
611 {
612 int32_t dataIndex=0;
613 UnicodeString bestPattern;
614
615 Locale loc(testLocale[localeIndex][0], testLocale[localeIndex][1], testLocale[localeIndex][2], testLocale[localeIndex][3]);
616 logln("\n\n Locale: %s_%s_%s@%s", testLocale[localeIndex][0], testLocale[localeIndex][1], testLocale[localeIndex][2], testLocale[localeIndex][3]);
617 DateTimePatternGenerator *patGen=DateTimePatternGenerator::createInstance(loc, status);
618 if(U_FAILURE(status)) {
619 dataerrln("ERROR: Could not create DateTimePatternGenerator with locale index:%d . - exitting\n", localeIndex);
620 return;
621 }
622 while (patternData[dataIndex].length() > 0) {
623 log(patternData[dataIndex]);
624 bestPattern = patGen->getBestPattern(patternData[dataIndex++], status);
625 logln(UnicodeString(" -> ") + bestPattern);
626
627 SimpleDateFormat sdf(bestPattern, loc, status);
628 resultDate.remove();
629 resultDate = sdf.format(testDate, resultDate);
630 if ( resultDate != patternResults[resultIndex] ) {
631 errln(UnicodeString("\nERROR: Test various skeletons[") + (dataIndex-1) + UnicodeString("], localeIndex ") + localeIndex +
632 UnicodeString(". Got: \"") + resultDate + UnicodeString("\" Expected: \"") + patternResults[resultIndex] + "\"" );
633 }
634
635 resultIndex++;
636 }
637 delete patGen;
638 localeIndex++;
639 }
640
641 // ======= More tests ticket#6110
642 logln("Testing DateTimePatternGenerator with various skeleton");
643
644 status = U_ZERO_ERROR;
645 localeIndex=0;
646 resultIndex=0;
647 testDate= LocaleTest::date(99, 9, 13, 23, 58, 59);
648 {
649 int32_t dataIndex=0;
650 UnicodeString bestPattern;
651 logln("\n\n Test various skeletons for English locale...");
652 DateTimePatternGenerator *patGen=DateTimePatternGenerator::createInstance(Locale::getEnglish(), status);
653 if(U_FAILURE(status)) {
654 dataerrln("ERROR: Could not create DateTimePatternGenerator with locale English . - exitting\n");
655 return;
656 }
657 TimeZone *enZone = TimeZone::createTimeZone(UnicodeString("ECT/GMT"));
658 if (enZone==NULL) {
659 dataerrln("ERROR: Could not create TimeZone ECT");
660 delete patGen;
661 return;
662 }
663 SimpleDateFormat *enFormat = (SimpleDateFormat *)DateFormat::createDateTimeInstance(DateFormat::kFull,
664 DateFormat::kFull, Locale::getEnglish());
665 enFormat->setTimeZone(*enZone);
666 while (patternTests2[dataIndex].length() > 0) {
667 logln(patternTests2[dataIndex]);
668 bestPattern = patGen->getBestPattern(patternTests2[dataIndex], status);
669 logln(UnicodeString(" -> ") + bestPattern);
670 enFormat->applyPattern(bestPattern);
671 resultDate.remove();
672 resultDate = enFormat->format(testDate, resultDate);
673 if ( resultDate != patternResults2[resultIndex] ) {
674 errln(UnicodeString("\nERROR: Test various skeletons[") + dataIndex
675 + UnicodeString("]. Got: ") + resultDate + UnicodeString(" Expected: ") +
676 patternResults2[resultIndex] );
677 }
678 dataIndex++;
679 resultIndex++;
680 }
681 delete patGen;
682 delete enZone;
683 delete enFormat;
684 }
685
686
687
688 // ======= Test random skeleton
689 DateTimePatternGenerator *randDTGen= DateTimePatternGenerator::createInstance(status);
690 if (U_FAILURE(status)) {
691 dataerrln("ERROR: Could not create DateTimePatternGenerator (Locale::getFrench()) - exitting");
692 return;
693 }
694 UChar newChar;
695 int32_t i;
696 for (i=0; i<10; ++i) {
697 UnicodeString randomSkeleton;
698 int32_t len = rand() % 20;
699 for (int32_t j=0; j<len; ++j ) {
700 while ((newChar = (UChar)(rand()%0x7f))>=(UChar)0x20) {
701 randomSkeleton += newChar;
702 }
703 }
704 UnicodeString bestPattern = randDTGen->getBestPattern(randomSkeleton, status);
705 }
706 delete randDTGen;
707
708 // UnicodeString randomString=Unicode
709 // ======= Test getStaticClassID()
710
711 logln("Testing getStaticClassID()");
712 status = U_ZERO_ERROR;
713 DateTimePatternGenerator *test= DateTimePatternGenerator::createInstance(status);
714
715 if(test->getDynamicClassID() != DateTimePatternGenerator::getStaticClassID()) {
716 errln("ERROR: getDynamicClassID() didn't return the expected value");
717 }
718 delete test;
719
720 // ====== Test createEmptyInstance()
721
722 logln("Testing createEmptyInstance()");
723 status = U_ZERO_ERROR;
724
725 test = DateTimePatternGenerator::createEmptyInstance(status);
726 if(U_FAILURE(status)) {
727 errln("ERROR: Fail to create an empty instance ! - exitting.\n");
728 delete test;
729 return;
730 }
731
732 conflictingStatus = test->addPattern(UnicodeString("MMMMd"), true, conflictingPattern, status);
733 status = U_ZERO_ERROR;
734 testPattern=test->getBestPattern(UnicodeString("MMMMdd"), status);
735 conflictingStatus = test->addPattern(UnicodeString("HH:mm"), true, conflictingPattern, status);
736 conflictingStatus = test->addPattern(UnicodeString("MMMMMdd"), true, conflictingPattern, status); //duplicate pattern
737 StringEnumeration *output=NULL;
738 output = test->getRedundants(status);
739 expectedResult=UnicodeString("MMMMd");
740 if (output != NULL) {
741 output->reset(status);
742 const UnicodeString *dupPattern=output->snext(status);
743 if ( (dupPattern==NULL) || (*dupPattern != expectedResult) ) {
744 errln("ERROR: Fail in getRedundants !\n");
745 }
746 }
747
748 // ======== Test getSkeletons and getBaseSkeletons
749 StringEnumeration* ptrSkeletonEnum = test->getSkeletons(status);
750 if(U_FAILURE(status)) {
751 errln("ERROR: Fail to get skeletons !\n");
752 }
753 UnicodeString returnPattern, *ptrSkeleton;
754 ptrSkeletonEnum->reset(status);
755 int32_t count=ptrSkeletonEnum->count(status);
756 for (i=0; i<count; ++i) {
757 ptrSkeleton = (UnicodeString *)ptrSkeletonEnum->snext(status);
758 returnPattern = test->getPatternForSkeleton(*ptrSkeleton);
759 if ( returnPattern != testSkeletonsResults[i] ) {
760 errln(UnicodeString("ERROR: Unexpected result from getSkeletons and getPatternForSkeleton\nGot: ") + returnPattern
761 + UnicodeString("\nExpected: ") + testSkeletonsResults[i]
762 + UnicodeString("\n"));
763 }
764 }
765 StringEnumeration* ptrBaseSkeletonEnum = test->getBaseSkeletons(status);
766 if(U_FAILURE(status)) {
767 errln("ERROR: Fail to get base skeletons !\n");
768 }
769 count=ptrBaseSkeletonEnum->count(status);
770 for (i=0; i<count; ++i) {
771 ptrSkeleton = (UnicodeString *)ptrBaseSkeletonEnum->snext(status);
772 if ( *ptrSkeleton != testBaseSkeletonsResults[i] ) {
773 errln("ERROR: Unexpected result from getBaseSkeletons() !\n");
774 }
775 }
776
777 // ========= DateTimePatternGenerator sample code in Userguide
778 // set up the generator
779 Locale locale = Locale::getFrench();
780 status = U_ZERO_ERROR;
781 DateTimePatternGenerator *generator = DateTimePatternGenerator::createInstance( locale, status);
782
783 // get a pattern for an abbreviated month and day
784 pattern = generator->getBestPattern(UnicodeString("MMMd"), status);
785 SimpleDateFormat formatter(pattern, locale, status);
786
787 zone = TimeZone::createTimeZone(UnicodeString("GMT"));
788 formatter.setTimeZone(*zone);
789 // use it to format (or parse)
790 UnicodeString formatted;
791 formatted = formatter.format(Calendar::getNow(), formatted, status);
792 // for French, the result is "13 sept."
793 formatted.remove();
794 // cannot use the result from getNow() because the value change evreyday.
795 testDate= LocaleTest::date(99, 0, 13, 23, 58, 59);
796 formatted = formatter.format(testDate, formatted, status);
797 expectedResult=UnicodeString("14 janv.");
798 if ( formatted != expectedResult ) {
799 errln("ERROR: Userguide sample code result!");
800 errln(UnicodeString(" Got: ")+ formatted + UnicodeString(" Expected: ") + expectedResult);
801 }
802
803 delete zone;
804 delete output;
805 delete ptrSkeletonEnum;
806 delete ptrBaseSkeletonEnum;
807 delete test;
808 delete generator;
809}
810
811/**
812 * Test handling of options
813 *
814 * For reference, as of ICU 4.3.3,
815 * root/gregorian has
816 * Hm{"H:mm"}
817 * Hms{"H:mm:ss"}
818 * hm{"h:mm a"}
819 * hms{"h:mm:ss a"}
820 * en/gregorian has
821 * Hm{"H:mm"}
822 * Hms{"H:mm:ss"}
823 * hm{"h:mm a"}
824 * be/gregorian has
825 * HHmmss{"HH.mm.ss"}
826 * Hm{"HH.mm"}
827 * hm{"h.mm a"}
828 * hms{"h.mm.ss a"}
829 */
830typedef struct DTPtnGenOptionsData {
831 const char *locale;
832 const char *skel;
833 const char *expectedPattern;
834 UDateTimePatternMatchOptions options;
835} DTPtnGenOptionsData;
836void IntlTestDateTimePatternGeneratorAPI::testOptions(/*char *par*/)
837{
838 DTPtnGenOptionsData testData[] = {
839 // locale skel expectedPattern options
840 { "en", "Hmm", "HH:mm", UDATPG_MATCH_NO_OPTIONS },
841 { "en", "HHmm", "HH:mm", UDATPG_MATCH_NO_OPTIONS },
842 { "en", "hhmm", "h:mm a", UDATPG_MATCH_NO_OPTIONS },
843 { "en", "Hmm", "HH:mm", UDATPG_MATCH_HOUR_FIELD_LENGTH },
844 { "en", "HHmm", "HH:mm", UDATPG_MATCH_HOUR_FIELD_LENGTH },
845 { "en", "hhmm", "hh:mm a", UDATPG_MATCH_HOUR_FIELD_LENGTH },
846 { "be", "Hmm", "HH.mm", UDATPG_MATCH_NO_OPTIONS },
847 { "be", "HHmm", "HH.mm", UDATPG_MATCH_NO_OPTIONS },
848 { "be", "hhmm", "h.mm a", UDATPG_MATCH_NO_OPTIONS },
849 { "be", "Hmm", "H.mm", UDATPG_MATCH_HOUR_FIELD_LENGTH },
850 { "be", "HHmm", "HH.mm", UDATPG_MATCH_HOUR_FIELD_LENGTH },
851 { "be", "hhmm", "hh.mm a", UDATPG_MATCH_HOUR_FIELD_LENGTH },
852 //
853 { "en", "yyyy", "yyyy", UDATPG_MATCH_NO_OPTIONS },
854 { "en", "YYYY", "YYYY", UDATPG_MATCH_NO_OPTIONS },
855 { "en", "U", "y", UDATPG_MATCH_NO_OPTIONS },
856 { "en@calendar=japanese", "yyyy", "y G", UDATPG_MATCH_NO_OPTIONS },
857 { "en@calendar=japanese", "YYYY", "Y G", UDATPG_MATCH_NO_OPTIONS },
858 { "en@calendar=japanese", "U", "y G", UDATPG_MATCH_NO_OPTIONS },
859 { "en@calendar=chinese", "yyyy", "U", UDATPG_MATCH_NO_OPTIONS },
860 { "en@calendar=chinese", "YYYY", "Y", UDATPG_MATCH_NO_OPTIONS },
861 { "en@calendar=chinese", "U", "U", UDATPG_MATCH_NO_OPTIONS },
862 };
863
864 int count = sizeof(testData) / sizeof(testData[0]);
865 const DTPtnGenOptionsData * testDataPtr = testData;
866
867 for (; count-- > 0; ++testDataPtr) {
868 UErrorCode status = U_ZERO_ERROR;
869
870 Locale locale(testDataPtr->locale);
871 UnicodeString skel(testDataPtr->skel);
872 UnicodeString expectedPattern(testDataPtr->expectedPattern);
873 UDateTimePatternMatchOptions options = testDataPtr->options;
874
875 DateTimePatternGenerator * dtpgen = DateTimePatternGenerator::createInstance(locale, status);
876 if (U_FAILURE(status)) {
877 dataerrln("Unable to create DateTimePatternGenerator instance for locale(%s): %s", locale.getName(), u_errorName(status));
878 delete dtpgen;
879 continue;
880 }
881 UnicodeString pattern = dtpgen->getBestPattern(skel, options, status);
882 if (pattern.compare(expectedPattern) != 0) {
883 errln( UnicodeString("ERROR in getBestPattern, locale ") + UnicodeString(testDataPtr->locale) +
884 UnicodeString(", skeleton ") + skel +
885 ((options)?UnicodeString(", options!=0"):UnicodeString(", options==0")) +
886 UnicodeString(", expected pattern ") + expectedPattern +
887 UnicodeString(", got ") + pattern );
888 }
889 delete dtpgen;
890 }
891}
892
893#endif /* #if !UCONFIG_NO_FORMATTING */