]>
Commit | Line | Data |
---|---|---|
f3c0d7a5 A |
1 | // © 2016 and later: Unicode, Inc. and others. |
2 | // License & terms of use: http://www.unicode.org/copyright.html | |
4388f060 | 3 | /******************************************************************** |
2ca993e8 | 4 | * Copyright (c) 2011-2016, International Business Machines Corporation |
4388f060 A |
5 | * and others. All Rights Reserved. |
6 | ********************************************************************/ | |
7 | /* C API TEST FOR DATE INTERVAL FORMAT */ | |
8 | ||
9 | #include "unicode/utypes.h" | |
10 | ||
11 | #if !UCONFIG_NO_FORMATTING | |
12 | ||
13 | #include "unicode/udateintervalformat.h" | |
14 | #include "unicode/udat.h" | |
15 | #include "unicode/ucal.h" | |
16 | #include "unicode/ustring.h" | |
3d1f044b | 17 | #include "unicode/udisplaycontext.h" |
4388f060 A |
18 | #include "cintltst.h" |
19 | #include "cmemory.h" | |
3d1f044b | 20 | #include "cformtst.h" |
4388f060 A |
21 | |
22 | static void TestDateIntervalFormat(void); | |
b331163b | 23 | static void TestFPos_SkelWithSeconds(void); |
3d1f044b | 24 | static void TestFormatToResult(void); |
0f5d89e8 | 25 | static void TestOpen(void); |
4388f060 | 26 | |
4388f060 A |
27 | void addDateIntervalFormatTest(TestNode** root); |
28 | ||
29 | #define TESTCASE(x) addTest(root, &x, "tsformat/cdateintervalformattest/" #x) | |
30 | ||
31 | void addDateIntervalFormatTest(TestNode** root) | |
32 | { | |
33 | TESTCASE(TestDateIntervalFormat); | |
b331163b | 34 | TESTCASE(TestFPos_SkelWithSeconds); |
3d1f044b | 35 | TESTCASE(TestFormatToResult); |
0f5d89e8 | 36 | TESTCASE(TestOpen); |
4388f060 A |
37 | } |
38 | ||
39 | static const char tzUSPacific[] = "US/Pacific"; | |
40 | static const char tzAsiaTokyo[] = "Asia/Tokyo"; | |
3d1f044b A |
41 | #define Date201103021030 1299090600000.0 /* 2011-Mar-02 Wed 1030 in US/Pacific, 2011-Mar-03 0330 in Asia/Tokyo */ |
42 | #define Date201009270800 1285599629000.0 /* 2010-Sep-27 Mon 0800 in US/Pacific */ | |
43 | #define Date201712300900 1514653200000.0 /* 2017-Dec-30 Sat 0900 in US/Pacific */ | |
340931cb | 44 | #define Date200101012200 1546322400000.0 /* 2001-Jan-01 2200 in US/Pacific */ |
4388f060 A |
45 | #define _MINUTE (60.0*1000.0) |
46 | #define _HOUR (60.0*60.0*1000.0) | |
47 | #define _DAY (24.0*60.0*60.0*1000.0) | |
3d1f044b A |
48 | #define MIN_NONE UDTITVFMT_MINIMIZE_NONE |
49 | #define MIN_MONTHS UDTITVFMT_MINIMIZE_ADJACENT_MONTHS | |
50 | #define MIN_DAYS UDTITVFMT_MINIMIZE_ADJACENT_DAYS | |
51 | #define C_NONE UDISPCTX_CAPITALIZATION_NONE | |
52 | #define C_MID UDISPCTX_CAPITALIZATION_FOR_MIDDLE_OF_SENTENCE | |
53 | #define C_BEGIN UDISPCTX_CAPITALIZATION_FOR_BEGINNING_OF_SENTENCE | |
54 | #define C_MENU UDISPCTX_CAPITALIZATION_FOR_UI_LIST_OR_MENU | |
55 | #define C_ALONE UDISPCTX_CAPITALIZATION_FOR_STANDALONE | |
4388f060 A |
56 | |
57 | typedef struct { | |
58 | const char * locale; | |
59 | const char * skeleton; | |
60 | const char * tzid; | |
2ca993e8 | 61 | UDateIntervalFormatAttributeValue minimizeType; |
3d1f044b | 62 | UDisplayContext context; |
4388f060 A |
63 | const UDate from; |
64 | const UDate to; | |
65 | const char * resultExpected; | |
66 | } DateIntervalFormatTestItem; | |
67 | ||
68 | /* Just a small set of tests for now, the real functionality is tested in the C++ tests */ | |
69 | static const DateIntervalFormatTestItem testItems[] = { | |
3d1f044b A |
70 | { "en", "MMMdHHmm", tzUSPacific, MIN_NONE, C_NONE, Date201103021030, Date201103021030 + 7.0*_HOUR, "Mar 2, 10:30\\u2009\\u2013\\u200917:30" }, |
71 | { "en", "MMMdHHmm", tzAsiaTokyo, MIN_NONE, C_NONE, Date201103021030, Date201103021030 + 7.0*_HOUR, "Mar 3, 03:30\\u2009\\u2013\\u200910:30" }, | |
72 | { "en", "yMMMEd", tzUSPacific, MIN_NONE, C_NONE, Date201009270800, Date201009270800 + 12.0*_HOUR, "Mon, Sep 27, 2010" }, | |
73 | { "en", "yMMMEd", tzUSPacific, MIN_NONE, C_NONE, Date201009270800, Date201009270800 + 31.0*_DAY, "Mon, Sep 27\\u2009\\u2013\\u2009Thu, Oct 28, 2010" }, | |
74 | { "en", "yMMMEd", tzUSPacific, MIN_NONE, C_NONE, Date201009270800, Date201009270800 + 410.0*_DAY, "Mon, Sep 27, 2010\\u2009\\u2013\\u2009Fri, Nov 11, 2011" }, | |
75 | { "de", "Hm", tzUSPacific, MIN_NONE, C_NONE, Date201009270800, Date201009270800 + 12.0*_HOUR, "08:00\\u201320:00 Uhr" }, | |
76 | { "de", "Hm", tzUSPacific, MIN_NONE, C_NONE, Date201009270800, Date201009270800 + 31.0*_DAY, "27.9.2010, 08:00\\u2009\\u2013\\u200928.10.2010, 08:00" }, | |
77 | { "ja", "MMMd", tzUSPacific, MIN_NONE, C_NONE, Date201009270800, Date201009270800 + 1.0*_DAY, "9\\u670827\\u65E5\\uFF5E28\\u65E5" }, | |
78 | { "en", "jm", tzUSPacific, MIN_NONE, C_NONE, Date201103021030, Date201103021030 + 1.0*_HOUR, "10:30 AM\\u2009\\u2013\\u200911:30 AM" }, | |
79 | { "en", "jm", tzUSPacific, MIN_NONE, C_NONE, Date201103021030, Date201103021030 + 12.0*_HOUR, "10:30 AM\\u2009\\u2013\\u200910:30 PM" }, | |
80 | { "it", "yMMMMd", tzUSPacific, MIN_NONE, C_NONE, Date201103021030, Date201103021030 + 15.0*_DAY, "2\\u201317 marzo 2011" }, | |
81 | { "en_SA", "MMMd", tzUSPacific, MIN_NONE, C_NONE, Date201009270800, Date201009270800 + 6.0*_DAY, "18\\u2009\\u2013\\u200924 Shaw." }, | |
82 | { "en@calendar=islamic-umalqura", "MMMd", tzUSPacific, MIN_NONE, C_NONE, Date201009270800, Date201009270800 + 6.0*_DAY, "Shaw. 18\\u2009\\u2013\\u200924" }, | |
83 | { "fr", "E", tzUSPacific, MIN_NONE, C_NONE, Date201103021030, Date201103021030 + 3.0*_DAY, "mer.\\u2009\\u2013\\u2009sam." }, | |
84 | { "fr", "E", tzUSPacific, MIN_NONE, C_BEGIN, Date201103021030, Date201103021030 + 3.0*_DAY, "Mer.\\u2009\\u2013\\u2009sam." }, | |
85 | { "fr", "E", tzUSPacific, MIN_NONE, C_MENU, Date201103021030, Date201103021030 + 3.0*_DAY, "mer.\\u2009\\u2013\\u2009sam." }, | |
86 | { "fr", "E", tzUSPacific, MIN_NONE, C_ALONE, Date201103021030, Date201103021030 + 3.0*_DAY, "Mer.\\u2009\\u2013\\u2009sam." }, | |
87 | { "fr", "yMMMM", tzUSPacific, MIN_NONE, C_NONE, Date201103021030, Date201103021030 + 3.0*_DAY, "mars 2011" }, | |
88 | { "fr", "yMMMM", tzUSPacific, MIN_NONE, C_BEGIN, Date201103021030, Date201103021030 + 3.0*_DAY, "Mars 2011" }, | |
89 | { "fr", "yMMMM", tzUSPacific, MIN_NONE, C_MENU, Date201103021030, Date201103021030 + 3.0*_DAY, "mars 2011" }, | |
90 | { "fr", "yMMMM", tzUSPacific, MIN_NONE, C_ALONE, Date201103021030, Date201103021030 + 3.0*_DAY, "Mars 2011" }, | |
91 | { "fr", "yMMMM", tzUSPacific, MIN_NONE, C_NONE, Date201103021030, Date201103021030 + 40.0*_DAY, "mars\\u2009\\u2013\\u2009avril 2011" }, | |
92 | { "fr", "yMMMM", tzUSPacific, MIN_NONE, C_BEGIN, Date201103021030, Date201103021030 + 40.0*_DAY, "Mars\\u2009\\u2013\\u2009avril 2011" }, | |
93 | { "fr", "yMMMM", tzUSPacific, MIN_NONE, C_MENU, Date201103021030, Date201103021030 + 40.0*_DAY, "mars\\u2009\\u2013\\u2009avril 2011" }, | |
94 | { "fr", "yMMMM", tzUSPacific, MIN_NONE, C_ALONE, Date201103021030, Date201103021030 + 40.0*_DAY, "Mars\\u2009\\u2013\\u2009avril 2011" }, | |
2ca993e8 | 95 | // Apple-specific |
3d1f044b A |
96 | { "en", "MMMd", tzUSPacific, MIN_MONTHS, C_NONE, Date201009270800, Date201009270800 + 6.0*_DAY, "Sep 27\\u2009\\u2013\\u20093" }, |
97 | { "en", "MMMd", tzUSPacific, MIN_MONTHS, C_NONE, Date201009270800, Date201009270800 + 32.0*_DAY, "Sep 27\\u2009\\u2013\\u2009Oct 29" }, | |
98 | { "en", "MMMd", tzUSPacific, MIN_MONTHS, C_NONE, Date201712300900, Date201712300900 + 6.0*_DAY, "Dec 30\\u2009\\u2013\\u20095" }, // across year boundary | |
99 | { "en", "MMMd", tzUSPacific, MIN_MONTHS, C_NONE, Date201712300900, Date201712300900 + 32.0*_DAY, "Dec 30, 2017\\u2009\\u2013\\u2009Jan 31, 2018" }, // across year boundary but > 1 month | |
100 | { "fr", "MMMd", tzUSPacific, MIN_MONTHS, C_NONE, Date201009270800, Date201009270800 + 6.0*_DAY, "27\\u20133 oct." }, | |
101 | { "fr", "MMMd", tzUSPacific, MIN_MONTHS, C_NONE, Date201009270800, Date201009270800 + 32.0*_DAY, "27 sept.\\u2009\\u2013\\u200929 oct." }, | |
102 | { "fr", "MMMd", tzUSPacific, MIN_MONTHS, C_NONE, Date201712300900, Date201712300900 + 6.0*_DAY, "30\\u20135 janv." }, // across year boundary | |
103 | { "fr", "MMMd", tzUSPacific, MIN_MONTHS, C_NONE, Date201712300900, Date201712300900 + 32.0*_DAY, "30 d\\u00E9c. 2017\\u2009\\u2013\\u200931 janv. 2018" }, // across year boundary but > 1 month | |
104 | ||
105 | { "en", "yMMMd", tzUSPacific, MIN_MONTHS, C_NONE, Date201009270800, Date201009270800 + 6.0*_DAY, "Sep 27\\u2009\\u2013\\u20093, 2010" }, | |
106 | { "en", "yMMMd", tzUSPacific, MIN_MONTHS, C_NONE, Date201009270800, Date201009270800 + 32.0*_DAY, "Sep 27\\u2009\\u2013\\u2009Oct 29, 2010" }, | |
107 | { "en", "yMMMd", tzUSPacific, MIN_MONTHS, C_NONE, Date201712300900, Date201712300900 + 6.0*_DAY, "Dec 30, 2017\\u2009\\u2013\\u2009Jan 5, 2018" }, // across year boundary | |
108 | { "en", "yMMMd", tzUSPacific, MIN_MONTHS, C_NONE, Date201712300900, Date201712300900 + 32.0*_DAY, "Dec 30, 2017\\u2009\\u2013\\u2009Jan 31, 2018" }, // across year boundary but > 1 month | |
109 | { "fr", "yMMMd", tzUSPacific, MIN_MONTHS, C_NONE, Date201009270800, Date201009270800 + 6.0*_DAY, "27\\u20133 oct. 2010" }, | |
110 | { "fr", "yMMMd", tzUSPacific, MIN_MONTHS, C_NONE, Date201009270800, Date201009270800 + 32.0*_DAY, "27 sept.\\u2009\\u2013\\u200929 oct. 2010" }, | |
111 | { "fr", "yMMMd", tzUSPacific, MIN_MONTHS, C_NONE, Date201712300900, Date201712300900 + 6.0*_DAY, "30 d\\u00E9c. 2017\\u2009\\u2013\\u20095 janv. 2018" }, // across year boundary | |
112 | { "fr", "yMMMd", tzUSPacific, MIN_MONTHS, C_NONE, Date201712300900, Date201712300900 + 32.0*_DAY, "30 d\\u00E9c. 2017\\u2009\\u2013\\u200931 janv. 2018" }, // across year boundary but > 1 month | |
113 | ||
114 | { "en", "MMMdjmm", tzUSPacific, MIN_DAYS, C_NONE, Date201009270800, Date201009270800 + 10.0*_HOUR, "Sep 27, 8:00 AM\\u2009\\u2013\\u20096:00 PM" }, | |
115 | { "en", "MMMdjmm", tzUSPacific, MIN_DAYS, C_NONE, Date201009270800, Date201009270800 + 17.0*_HOUR, "Sep 27, 8:00 AM\\u2009\\u2013\\u2009Sep 28, 1:00 AM" }, | |
116 | { "en", "MMMdjmm", tzUSPacific, MIN_DAYS, C_NONE, Date201009270800 + 12.0*_HOUR, Date201009270800 + 17.0*_HOUR, "Sep 27, 8:00 PM\\u2009\\u2013\\u20091:00 AM" }, | |
117 | { "en", "MMMdjmm", tzUSPacific, MIN_DAYS, C_NONE, Date201009270800 + 12.0*_HOUR, Date201009270800 + 26.0*_HOUR, "Sep 27, 8:00 PM\\u2009\\u2013\\u2009Sep 28, 10:00 AM" }, | |
118 | { "en", "MMMdjmm", tzUSPacific, MIN_DAYS, C_NONE, Date201009270800 + 12.0*_HOUR, Date201009270800 + 35.0*_HOUR, "Sep 27, 8:00 PM\\u2009\\u2013\\u2009Sep 28, 7:00 PM" }, | |
119 | { "fr", "MMMdjmm", tzUSPacific, MIN_DAYS, C_NONE, Date201009270800, Date201009270800 + 10.0*_HOUR, "27 sept. \\u00E0 08:00\\u2009\\u2013\\u200918:00" }, | |
120 | { "fr", "MMMdjmm", tzUSPacific, MIN_DAYS, C_NONE, Date201009270800, Date201009270800 + 17.0*_HOUR, "27 sept. \\u00E0 08:00\\u2009\\u2013\\u200928 sept. \\u00E0 01:00" }, | |
121 | { "fr", "MMMdjmm", tzUSPacific, MIN_DAYS, C_NONE, Date201009270800 + 12.0*_HOUR, Date201009270800 + 17.0*_HOUR, "27 sept. \\u00E0 20:00\\u2009\\u2013\\u200901:00" }, | |
122 | { "fr", "MMMdjmm", tzUSPacific, MIN_DAYS, C_NONE, Date201009270800 + 12.0*_HOUR, Date201009270800 + 26.0*_HOUR, "27 sept. \\u00E0 20:00\\u2009\\u2013\\u200928 sept. \\u00E0 10:00" }, | |
123 | { "fr", "MMMdjmm", tzUSPacific, MIN_DAYS, C_NONE, Date201009270800 + 12.0*_HOUR, Date201009270800 + 35.0*_HOUR, "27 sept. \\u00E0 20:00\\u2009\\u2013\\u200928 sept. \\u00E0 19:00" }, | |
124 | ||
340931cb A |
125 | // additional tests for rdar://problem/26911014 (spot check only for now) |
126 | { "fr_US", "MMMMdjmm", tzUSPacific, MIN_DAYS, C_NONE, Date201009270800, Date201009270800 + 17.0*_HOUR, "27 septembre \\u00E0 8:00 AM\\u2009\\u2013\\u200928 septembre \\u00E0 1:00 AM" }, | |
127 | { "fr_US", "MMMMdjmm", tzUSPacific, MIN_DAYS, C_NONE, Date201009270800 + 12.0*_HOUR, Date201009270800 + 17.0*_HOUR, "27 septembre \\u00E0 8:00 PM\\u2009\\u2013\\u20091:00 AM" }, | |
128 | { "fr_AR", "MMMMdjmm", tzUSPacific, MIN_DAYS, C_NONE, Date201009270800, Date201009270800 + 17.0*_HOUR, "27 septembre \\u00e0 08:00\\u2009\\u2013\\u200928 septembre \\u00e0 01:00" }, | |
129 | { "fr_AR", "MMMMdjmm", tzUSPacific, MIN_DAYS, C_NONE, Date201009270800 + 12.0*_HOUR, Date201009270800 + 17.0*_HOUR, "27 septembre \\u00e0 20:00\\u2009\\u2013\\u200901:00" }, | |
130 | { "fr_JP", "MMMMdjmm", tzUSPacific, MIN_DAYS, C_NONE, Date201009270800, Date201009270800 + 17.0*_HOUR, "27 septembre \\u00e0 08:00\\u2009\\u2013\\u200928 septembre \\u00e0 01:00" }, | |
131 | { "fr_JP", "MMMMdjmm", tzUSPacific, MIN_DAYS, C_NONE, Date201009270800 + 12.0*_HOUR, Date201009270800 + 17.0*_HOUR, "27 septembre \\u00e0 20:00\\u2009\\u2013\\u200901:00" }, | |
132 | { "ja_US", "MMMMdjmm", tzUSPacific, MIN_DAYS, C_NONE, Date201009270800, Date201009270800 + 17.0*_HOUR, "9\\u670827\\u65e5 \\u5348\\u524d8:00\\uff5e9\\u670828\\u65e5 \\u5348\\u524d1:00" }, | |
133 | { "ja_US", "MMMMdjmm", tzUSPacific, MIN_DAYS, C_NONE, Date201009270800 + 12.0*_HOUR, Date201009270800 + 17.0*_HOUR, "9\\u670827\\u65e5 \\u5348\\u5f8c8:00\\uff5e\\u5348\\u524d1:00" }, | |
134 | ||
135 | // additional tests for rdar://63628118 (spot check only for now) | |
136 | { "fr_DE", "yMEd", tzUSPacific, MIN_DAYS, C_NONE, Date201103021030, Date201712300900, "mer. 02.03.2011\\u2009\\u2013\\u2009sam. 30.12.2017" }, | |
137 | { "de_FR", "yMEd", tzUSPacific, MIN_DAYS, C_NONE, Date201103021030, Date201712300900, "Mi. 02/03/2011\\u2009\\u2013\\u2009Sa. 30/12/2017" }, | |
138 | { "fr_SA", "yMEd", tzUSPacific, MIN_DAYS, C_NONE, Date201103021030, Date201712300900, "mer.\\u060c 27/3/1432 \\u2013 sam.\\u060c 12/4/1439" }, | |
139 | ||
140 | // tests for rdar://63926701 (the first test is the 'real' test; the second one never failed and is there to guard against regressions) | |
141 | { "fi_US", "yMdhmm", tzUSPacific, MIN_NONE, C_NONE, Date200101012200, Date200101012200 + 1.5*_HOUR, "12/31/2018 klo 10.00\\u201311.30 ip." }, | |
142 | { "fi_US", "yMdjmm", tzUSPacific, MIN_NONE, C_NONE, Date200101012200, Date200101012200 + 1.5*_HOUR, "12/31/2018 klo 10.00 ip.\\u201311.30 ip." }, | |
143 | ||
144 | // rdar://55667608 and https://unicode-org.atlassian.net/browse/CLDR-10321 | |
145 | { "fi", "MMMdjjmm", tzUSPacific, MIN_DAYS, C_NONE, Date201009270800 + 12.0*_HOUR, Date201009270800 + 17.0*_HOUR, "27.9. klo 20.00\\u20131.00" }, | |
146 | ||
3d1f044b | 147 | { NULL, NULL, NULL, MIN_NONE, C_NONE, 0, 0, NULL } |
4388f060 A |
148 | }; |
149 | ||
150 | enum { | |
151 | kSkelBufLen = 32, | |
152 | kTZIDBufLen = 96, | |
153 | kFormatBufLen = 128 | |
154 | }; | |
155 | ||
156 | static void TestDateIntervalFormat() | |
157 | { | |
158 | const DateIntervalFormatTestItem * testItemPtr; | |
159 | UErrorCode status = U_ZERO_ERROR; | |
160 | ctest_setTimeZone(NULL, &status); | |
161 | log_verbose("\nTesting udtitvfmt_open() and udtitvfmt_format() with various parameters\n"); | |
162 | for ( testItemPtr = testItems; testItemPtr->locale != NULL; ++testItemPtr ) { | |
163 | UDateIntervalFormat* udtitvfmt; | |
164 | int32_t tzidLen; | |
165 | UChar skelBuf[kSkelBufLen]; | |
166 | UChar tzidBuf[kTZIDBufLen]; | |
167 | const char * tzidForLog = (testItemPtr->tzid)? testItemPtr->tzid: "NULL"; | |
168 | ||
169 | status = U_ZERO_ERROR; | |
170 | u_unescape(testItemPtr->skeleton, skelBuf, kSkelBufLen); | |
171 | if ( testItemPtr->tzid ) { | |
172 | u_unescape(testItemPtr->tzid, tzidBuf, kTZIDBufLen); | |
173 | tzidLen = -1; | |
174 | } else { | |
175 | tzidLen = 0; | |
176 | } | |
177 | udtitvfmt = udtitvfmt_open(testItemPtr->locale, skelBuf, -1, tzidBuf, tzidLen, &status); | |
178 | if ( U_SUCCESS(status) ) { | |
179 | UChar result[kFormatBufLen]; | |
180 | UChar resultExpected[kFormatBufLen]; | |
2ca993e8 A |
181 | udtitvfmt_setAttribute(udtitvfmt, UDTITVFMT_MINIMIZE_TYPE, testItemPtr->minimizeType, &status); |
182 | if ( U_FAILURE(status) ) { | |
183 | log_err("FAIL: udtitvfmt_setAttribute for locale %s, skeleton %s, tzid %s, minimizeType %d: %s\n", | |
184 | testItemPtr->locale, testItemPtr->skeleton, tzidForLog, (int)testItemPtr->minimizeType, myErrorName(status) ); | |
3d1f044b | 185 | continue; |
2ca993e8 | 186 | } |
3d1f044b A |
187 | udtitvfmt_setContext(udtitvfmt, testItemPtr->context, &status); |
188 | if ( U_FAILURE(status) ) { | |
189 | log_err("FAIL: udtitvfmt_setContext for locale %s, skeleton %s, tzid %s, context %04X: %s\n", | |
190 | testItemPtr->locale, testItemPtr->skeleton, tzidForLog, (int)testItemPtr->context, myErrorName(status) ); | |
191 | continue; | |
192 | } | |
193 | UDisplayContext getContext = udtitvfmt_getContext(udtitvfmt, UDISPCTX_TYPE_CAPITALIZATION, &status); | |
194 | if ( U_FAILURE(status) ) { | |
195 | log_err("FAIL: udtitvfmt_getContext for locale %s, skeleton %s, tzid %s, context %04X: %s\n", | |
196 | testItemPtr->locale, testItemPtr->skeleton, tzidForLog, (int)testItemPtr->context, myErrorName(status) ); | |
197 | continue; | |
198 | } else if (getContext != testItemPtr->context) { | |
199 | log_err("FAIL: udtitvfmt_getContext for locale %s, skeleton %s, tzid %s, set context %04X but got %04X\n", | |
200 | testItemPtr->locale, testItemPtr->skeleton, tzidForLog, (int)testItemPtr->context, getContext ); | |
201 | continue; | |
202 | } | |
203 | ||
4388f060 A |
204 | int32_t fmtLen = udtitvfmt_format(udtitvfmt, testItemPtr->from, testItemPtr->to, result, kFormatBufLen, NULL, &status); |
205 | if (fmtLen >= kFormatBufLen) { | |
206 | result[kFormatBufLen-1] = 0; | |
207 | } | |
208 | if ( U_SUCCESS(status) ) { | |
209 | u_unescape(testItemPtr->resultExpected, resultExpected, kFormatBufLen); | |
210 | if ( u_strcmp(result, resultExpected) != 0 ) { | |
211 | char bcharBuf[kFormatBufLen]; | |
2ca993e8 A |
212 | #if 0 |
213 | log_err("ERROR: udtitvfmt_format for locale %s, skeleton %s, tzid %s, minimizeType %d, from %.1f, to %.1f: expect %s, get %s\n", | |
214 | testItemPtr->locale, testItemPtr->skeleton, tzidForLog, (int)testItemPtr->minimizeType, | |
215 | testItemPtr->from, testItemPtr->to, testItemPtr->resultExpected, u_austrcpy(bcharBuf,result) ); | |
216 | #else | |
217 | // Apple-specific version | |
218 | char bexpbuf[kFormatBufLen]; | |
219 | u_strToUTF8(bexpbuf, kFormatBufLen, NULL, resultExpected, -1, &status); | |
220 | u_strToUTF8(bcharBuf, kFormatBufLen, NULL, result, fmtLen, &status); | |
3d1f044b A |
221 | log_err("ERROR: udtitvfmt_format for locale %s, skeleton %s, tzid %s, minimizeType %d, context %04X, from %.1f, to %.1f: expect %s, get %s\n", |
222 | testItemPtr->locale, testItemPtr->skeleton, tzidForLog, (int)testItemPtr->minimizeType, (int)testItemPtr->context, | |
2ca993e8 A |
223 | testItemPtr->from, testItemPtr->to, bexpbuf, bcharBuf ); |
224 | #endif | |
4388f060 A |
225 | } |
226 | } else { | |
2ca993e8 A |
227 | log_err("FAIL: udtitvfmt_format for locale %s, skeleton %s, tzid %s, minimizeType %d, from %.1f, to %.1f: %s\n", |
228 | testItemPtr->locale, testItemPtr->skeleton, tzidForLog, (int)testItemPtr->minimizeType, | |
229 | testItemPtr->from, testItemPtr->to, myErrorName(status) ); | |
4388f060 A |
230 | } |
231 | udtitvfmt_close(udtitvfmt); | |
232 | } else { | |
233 | log_data_err("FAIL: udtitvfmt_open for locale %s, skeleton %s, tzid %s - %s\n", | |
234 | testItemPtr->locale, testItemPtr->skeleton, tzidForLog, myErrorName(status) ); | |
235 | } | |
236 | } | |
237 | ctest_resetTimeZone(); | |
238 | } | |
239 | ||
b331163b A |
240 | /******************************************************************** |
241 | * TestFPos_SkelWithSeconds and related data | |
242 | ******************************************************************** | |
243 | */ | |
244 | ||
245 | static UChar zoneGMT[] = { 0x47,0x4D,0x54,0 }; // GMT | |
246 | static const UDate startTime = 1416474000000.0; // 2014 Nov 20 09:00 GMT | |
247 | ||
248 | static const double deltas[] = { | |
249 | 0.0, // none | |
250 | 200.0, // 200 millisec | |
251 | 20000.0, // 20 sec | |
252 | 1200000.0, // 20 min | |
253 | 7200000.0, // 2 hrs | |
254 | 43200000.0, // 12 hrs | |
255 | 691200000.0, // 8 days | |
256 | 1382400000.0, // 16 days, | |
257 | 8640000000.0, // 100 days | |
258 | -1.0 | |
259 | }; | |
2ca993e8 | 260 | enum { kNumDeltas = UPRV_LENGTHOF(deltas) - 1 }; |
b331163b A |
261 | |
262 | typedef struct { | |
263 | int32_t posBegin; | |
264 | int32_t posEnd; | |
265 | const char * format; | |
266 | } ExpectPosAndFormat; | |
267 | ||
268 | static const ExpectPosAndFormat exp_en_HHmm[kNumDeltas] = { | |
269 | { 3, 5, "09:00" }, | |
270 | { 3, 5, "09:00" }, | |
271 | { 3, 5, "09:00" }, | |
f3c0d7a5 A |
272 | { 3, 5, "09:00\\u2009\\u2013\\u200909:20" }, |
273 | { 3, 5, "09:00\\u2009\\u2013\\u200911:00" }, | |
274 | { 3, 5, "09:00\\u2009\\u2013\\u200921:00" }, | |
275 | { 15, 17, "11/20/2014, 09:00\\u2009\\u2013\\u200911/28/2014, 09:00" }, | |
276 | { 15, 17, "11/20/2014, 09:00\\u2009\\u2013\\u200912/6/2014, 09:00" }, | |
277 | { 15, 17, "11/20/2014, 09:00\\u2009\\u2013\\u20092/28/2015, 09:00" } | |
b331163b A |
278 | }; |
279 | ||
280 | static const ExpectPosAndFormat exp_en_HHmmss[kNumDeltas] = { | |
281 | { 3, 5, "09:00:00" }, | |
282 | { 3, 5, "09:00:00" }, | |
f3c0d7a5 A |
283 | { 3, 5, "09:00:00\\u2009\\u2013\\u200909:00:20" }, |
284 | { 3, 5, "09:00:00\\u2009\\u2013\\u200909:20:00" }, | |
285 | { 3, 5, "09:00:00\\u2009\\u2013\\u200911:00:00" }, | |
286 | { 3, 5, "09:00:00\\u2009\\u2013\\u200921:00:00" }, | |
287 | { 15, 17, "11/20/2014, 09:00:00\\u2009\\u2013\\u200911/28/2014, 09:00:00" }, | |
288 | { 15, 17, "11/20/2014, 09:00:00\\u2009\\u2013\\u200912/6/2014, 09:00:00" }, | |
289 | { 15, 17, "11/20/2014, 09:00:00\\u2009\\u2013\\u20092/28/2015, 09:00:00" } | |
b331163b A |
290 | }; |
291 | ||
292 | static const ExpectPosAndFormat exp_en_yyMMdd[kNumDeltas] = { | |
293 | { 0, 0, "11/20/14" }, | |
294 | { 0, 0, "11/20/14" }, | |
295 | { 0, 0, "11/20/14" }, | |
296 | { 0, 0, "11/20/14" }, | |
297 | { 0, 0, "11/20/14" }, | |
298 | { 0, 0, "11/20/14" }, | |
f3c0d7a5 A |
299 | { 0, 0, "11/20/14\\u2009\\u2013\\u200911/28/14" }, |
300 | { 0, 0, "11/20/14\\u2009\\u2013\\u200912/6/14" }, | |
301 | { 0, 0, "11/20/14\\u2009\\u2013\\u20092/28/15" } | |
b331163b A |
302 | }; |
303 | ||
304 | static const ExpectPosAndFormat exp_en_yyMMddHHmm[kNumDeltas] = { | |
305 | { 13, 15, "11/20/14, 09:00" }, | |
306 | { 13, 15, "11/20/14, 09:00" }, | |
307 | { 13, 15, "11/20/14, 09:00" }, | |
f3c0d7a5 A |
308 | { 13, 15, "11/20/14, 09:00\\u2009\\u2013\\u200909:20" }, |
309 | { 13, 15, "11/20/14, 09:00\\u2009\\u2013\\u200911:00" }, | |
310 | { 13, 15, "11/20/14, 09:00\\u2009\\u2013\\u200921:00" }, | |
311 | { 13, 15, "11/20/14, 09:00\\u2009\\u2013\\u200911/28/14, 09:00" }, | |
312 | { 13, 15, "11/20/14, 09:00\\u2009\\u2013\\u200912/06/14, 09:00" }, | |
313 | { 13, 15, "11/20/14, 09:00\\u2009\\u2013\\u200902/28/15, 09:00" } | |
b331163b A |
314 | }; |
315 | ||
316 | static const ExpectPosAndFormat exp_en_yyMMddHHmmss[kNumDeltas] = { | |
317 | { 13, 15, "11/20/14, 09:00:00" }, | |
318 | { 13, 15, "11/20/14, 09:00:00" }, | |
f3c0d7a5 A |
319 | { 13, 15, "11/20/14, 09:00:00\\u2009\\u2013\\u200909:00:20" }, |
320 | { 13, 15, "11/20/14, 09:00:00\\u2009\\u2013\\u200909:20:00" }, | |
321 | { 13, 15, "11/20/14, 09:00:00\\u2009\\u2013\\u200911:00:00" }, | |
322 | { 13, 15, "11/20/14, 09:00:00\\u2009\\u2013\\u200921:00:00" }, | |
323 | { 13, 15, "11/20/14, 09:00:00\\u2009\\u2013\\u200911/28/14, 09:00:00" }, | |
324 | { 13, 15, "11/20/14, 09:00:00\\u2009\\u2013\\u200912/06/14, 09:00:00" }, | |
325 | { 13, 15, "11/20/14, 09:00:00\\u2009\\u2013\\u200902/28/15, 09:00:00" } | |
b331163b A |
326 | }; |
327 | ||
328 | static const ExpectPosAndFormat exp_en_yMMMdhmmssz[kNumDeltas] = { | |
329 | { 16, 18, "Nov 20, 2014, 9:00:00 AM GMT" }, | |
330 | { 16, 18, "Nov 20, 2014, 9:00:00 AM GMT" }, | |
f3c0d7a5 A |
331 | { 16, 18, "Nov 20, 2014, 9:00:00 AM GMT\\u2009\\u2013\\u20099:00:20 AM GMT" }, |
332 | { 16, 18, "Nov 20, 2014, 9:00:00 AM GMT\\u2009\\u2013\\u20099:20:00 AM GMT" }, | |
333 | { 16, 18, "Nov 20, 2014, 9:00:00 AM GMT\\u2009\\u2013\\u200911:00:00 AM GMT" }, | |
334 | { 16, 18, "Nov 20, 2014, 9:00:00 AM GMT\\u2009\\u2013\\u20099:00:00 PM GMT" }, | |
335 | { 16, 18, "Nov 20, 2014, 9:00:00 AM GMT\\u2009\\u2013\\u2009Nov 28, 2014, 9:00:00 AM GMT" }, | |
336 | { 16, 18, "Nov 20, 2014, 9:00:00 AM GMT\\u2009\\u2013\\u2009Dec 6, 2014, 9:00:00 AM GMT" }, | |
337 | { 16, 18, "Nov 20, 2014, 9:00:00 AM GMT\\u2009\\u2013\\u2009Feb 28, 2015, 9:00:00 AM GMT" } | |
b331163b A |
338 | }; |
339 | ||
340 | static const ExpectPosAndFormat exp_ja_yyMMddHHmm[kNumDeltas] = { | |
341 | { 11, 13, "14/11/20 9:00" }, | |
342 | { 11, 13, "14/11/20 9:00" }, | |
343 | { 11, 13, "14/11/20 9:00" }, | |
344 | { 11, 13, "14/11/20 9\\u664200\\u5206\\uFF5E9\\u664220\\u5206" }, | |
345 | { 11, 13, "14/11/20 9\\u664200\\u5206\\uFF5E11\\u664200\\u5206" }, | |
346 | { 11, 13, "14/11/20 9\\u664200\\u5206\\uFF5E21\\u664200\\u5206" }, | |
347 | { 11, 13, "14/11/20 9:00\\uFF5E14/11/28 9:00" }, | |
348 | { 11, 13, "14/11/20 9:00\\uFF5E14/12/06 9:00" }, | |
349 | { 11, 13, "14/11/20 9:00\\uFF5E15/02/28 9:00" } | |
350 | }; | |
351 | ||
352 | static const ExpectPosAndFormat exp_ja_yyMMddHHmmss[kNumDeltas] = { | |
353 | { 11, 13, "14/11/20 9:00:00" }, | |
354 | { 11, 13, "14/11/20 9:00:00" }, | |
355 | { 11, 13, "14/11/20 9:00:00\\uFF5E9:00:20" }, | |
356 | { 11, 13, "14/11/20 9:00:00\\uFF5E9:20:00" }, | |
357 | { 11, 13, "14/11/20 9:00:00\\uFF5E11:00:00" }, | |
358 | { 11, 13, "14/11/20 9:00:00\\uFF5E21:00:00" }, | |
359 | { 11, 13, "14/11/20 9:00:00\\uFF5E14/11/28 9:00:00" }, | |
360 | { 11, 13, "14/11/20 9:00:00\\uFF5E14/12/06 9:00:00" }, | |
361 | { 11, 13, "14/11/20 9:00:00\\uFF5E15/02/28 9:00:00" } | |
362 | }; | |
363 | ||
364 | static const ExpectPosAndFormat exp_ja_yMMMdHHmmss[kNumDeltas] = { | |
365 | { 14, 16, "2014\\u5E7411\\u670820\\u65E5 9:00:00" }, | |
366 | { 14, 16, "2014\\u5E7411\\u670820\\u65E5 9:00:00" }, | |
367 | { 14, 16, "2014\\u5E7411\\u670820\\u65E5 9:00:00\\uFF5E9:00:20" }, | |
368 | { 14, 16, "2014\\u5E7411\\u670820\\u65E5 9:00:00\\uFF5E9:20:00" }, | |
369 | { 14, 16, "2014\\u5E7411\\u670820\\u65E5 9:00:00\\uFF5E11:00:00" }, | |
370 | { 14, 16, "2014\\u5E7411\\u670820\\u65E5 9:00:00\\uFF5E21:00:00" }, | |
371 | { 14, 16, "2014\\u5E7411\\u670820\\u65E5 9:00:00\\uFF5E2014\\u5E7411\\u670828\\u65E5 9:00:00" }, | |
372 | { 14, 16, "2014\\u5E7411\\u670820\\u65E5 9:00:00\\uFF5E2014\\u5E7412\\u67086\\u65E5 9:00:00" }, | |
373 | { 14, 16, "2014\\u5E7411\\u670820\\u65E5 9:00:00\\uFF5E2015\\u5E742\\u670828\\u65E5 9:00:00" } | |
374 | }; | |
375 | ||
340931cb A |
376 | // rdar://55667608 and https://unicode-org.atlassian.net/browse/CLDR-10321 |
377 | static const ExpectPosAndFormat exp_fi_MMMdjjmm[kNumDeltas] = { | |
378 | { 13, 15, "20.11. klo 9.00" }, | |
379 | { 13, 15, "20.11. klo 9.00" }, | |
380 | { 13, 15, "20.11. klo 9.00" }, | |
381 | { 13, 15, "20.11. klo 9.00\\u20139.20" }, | |
382 | { 13, 15, "20.11. klo 9.00\\u201311.00" }, | |
383 | { 13, 15, "20.11. klo 9.00\\u201321.00" }, | |
384 | { 13, 15, "20.11. klo 9.00\\u201328.11. klo 9.00" }, | |
385 | { 13, 15, "20.11. klo 9.00\\u20136.12. klo 9.00" }, | |
386 | { 13, 15, "20.11. klo 9.00\\u201328.2. klo 9.00" } | |
387 | }; | |
388 | ||
b331163b A |
389 | typedef struct { |
390 | const char * locale; | |
391 | const char * skeleton; | |
392 | UDateFormatField fieldToCheck; | |
393 | const ExpectPosAndFormat * expected; | |
394 | } LocaleAndSkeletonItem; | |
395 | ||
396 | static const LocaleAndSkeletonItem locSkelItems[] = { | |
397 | { "en", "HHmm", UDAT_MINUTE_FIELD, exp_en_HHmm }, | |
398 | { "en", "HHmmss", UDAT_MINUTE_FIELD, exp_en_HHmmss }, | |
399 | { "en", "yyMMdd", UDAT_MINUTE_FIELD, exp_en_yyMMdd }, | |
400 | { "en", "yyMMddHHmm", UDAT_MINUTE_FIELD, exp_en_yyMMddHHmm }, | |
401 | { "en", "yyMMddHHmmss", UDAT_MINUTE_FIELD, exp_en_yyMMddHHmmss }, | |
402 | { "en", "yMMMdhmmssz", UDAT_MINUTE_FIELD, exp_en_yMMMdhmmssz }, | |
403 | { "ja", "yyMMddHHmm", UDAT_MINUTE_FIELD, exp_ja_yyMMddHHmm }, | |
404 | { "ja", "yyMMddHHmmss", UDAT_MINUTE_FIELD, exp_ja_yyMMddHHmmss }, | |
405 | { "ja", "yMMMdHHmmss", UDAT_MINUTE_FIELD, exp_ja_yMMMdHHmmss }, | |
340931cb | 406 | { "fi", "MMMdjjmm", UDAT_MINUTE_FIELD, exp_fi_MMMdjjmm }, |
b331163b A |
407 | { NULL, NULL, (UDateFormatField)0, NULL } |
408 | }; | |
409 | ||
410 | enum { kSizeUBuf = 96, kSizeBBuf = 192 }; | |
411 | ||
412 | static void TestFPos_SkelWithSeconds() | |
413 | { | |
414 | const LocaleAndSkeletonItem * locSkelItemPtr; | |
415 | for (locSkelItemPtr = locSkelItems; locSkelItemPtr->locale != NULL; locSkelItemPtr++) { | |
416 | UDateIntervalFormat* udifmt; | |
417 | UChar ubuf[kSizeUBuf]; | |
418 | int32_t ulen, uelen; | |
419 | UErrorCode status = U_ZERO_ERROR; | |
f3c0d7a5 | 420 | ulen = u_unescape(locSkelItemPtr->skeleton, ubuf, kSizeUBuf); |
b331163b A |
421 | udifmt = udtitvfmt_open(locSkelItemPtr->locale, ubuf, ulen, zoneGMT, -1, &status); |
422 | if ( U_FAILURE(status) ) { | |
423 | log_data_err("FAIL: udtitvfmt_open for locale %s, skeleton %s: %s\n", | |
424 | locSkelItemPtr->locale, locSkelItemPtr->skeleton, u_errorName(status)); | |
425 | } else { | |
426 | const double * deltasPtr = deltas; | |
427 | const ExpectPosAndFormat * expectedPtr = locSkelItemPtr->expected; | |
428 | for (; *deltasPtr >= 0.0; deltasPtr++, expectedPtr++) { | |
429 | UFieldPosition fpos = { locSkelItemPtr->fieldToCheck, 0, 0 }; | |
430 | UChar uebuf[kSizeUBuf]; | |
431 | char bbuf[kSizeBBuf]; | |
432 | char bebuf[kSizeBBuf]; | |
433 | status = U_ZERO_ERROR; | |
434 | uelen = u_unescape(expectedPtr->format, uebuf, kSizeUBuf); | |
435 | ulen = udtitvfmt_format(udifmt, startTime, startTime + *deltasPtr, ubuf, kSizeUBuf, &fpos, &status); | |
436 | if ( U_FAILURE(status) ) { | |
437 | log_err("FAIL: udtitvfmt_format for locale %s, skeleton %s, delta %.1f: %s\n", | |
438 | locSkelItemPtr->locale, locSkelItemPtr->skeleton, *deltasPtr, u_errorName(status)); | |
439 | } else if ( ulen != uelen || u_strncmp(ubuf,uebuf,uelen) != 0 || | |
440 | fpos.beginIndex != expectedPtr->posBegin || fpos.endIndex != expectedPtr->posEnd ) { | |
441 | u_strToUTF8(bbuf, kSizeBBuf, NULL, ubuf, ulen, &status); | |
442 | u_strToUTF8(bebuf, kSizeBBuf, NULL, uebuf, uelen, &status); // convert back to get unescaped string | |
443 | log_err("FAIL: udtitvfmt_format for locale %s, skeleton %s, delta %12.1f, expect %d-%d \"%s\", get %d-%d \"%s\"\n", | |
444 | locSkelItemPtr->locale, locSkelItemPtr->skeleton, *deltasPtr, | |
445 | expectedPtr->posBegin, expectedPtr->posEnd, bebuf, | |
446 | fpos.beginIndex, fpos.endIndex, bbuf); | |
447 | } | |
448 | } | |
449 | udtitvfmt_close(udifmt); | |
450 | } | |
451 | } | |
452 | } | |
453 | ||
3d1f044b A |
454 | static void TestFormatToResult() { |
455 | UErrorCode ec = U_ZERO_ERROR; | |
456 | UDateIntervalFormat* fmt = udtitvfmt_open("de", u"dMMMMyHHmm", -1, zoneGMT, -1, &ec); | |
457 | UFormattedDateInterval* fdi = udtitvfmt_openResult(&ec); | |
458 | assertSuccess("Opening", &ec); | |
459 | ||
460 | { | |
461 | const char* message = "Field position test 1"; | |
462 | const UChar* expectedString = u"27. September 2010, 15:00\u2009–\u20092. März 2011, 18:30"; | |
463 | udtitvfmt_formatToResult(fmt, fdi, Date201009270800, Date201103021030, &ec); | |
464 | assertSuccess("Formatting", &ec); | |
465 | static const UFieldPositionWithCategory expectedFieldPositions[] = { | |
466 | // category, field, begin index, end index | |
467 | {UFIELD_CATEGORY_DATE_INTERVAL_SPAN, 0, 0, 25}, | |
468 | {UFIELD_CATEGORY_DATE, UDAT_DATE_FIELD, 0, 2}, | |
469 | {UFIELD_CATEGORY_DATE, UDAT_MONTH_FIELD, 4, 13}, | |
470 | {UFIELD_CATEGORY_DATE, UDAT_YEAR_FIELD, 14, 18}, | |
471 | {UFIELD_CATEGORY_DATE, UDAT_HOUR_OF_DAY0_FIELD, 20, 22}, | |
472 | {UFIELD_CATEGORY_DATE, UDAT_MINUTE_FIELD, 23, 25}, | |
473 | {UFIELD_CATEGORY_DATE_INTERVAL_SPAN, 1, 28, 47}, | |
474 | {UFIELD_CATEGORY_DATE, UDAT_DATE_FIELD, 28, 29}, | |
475 | {UFIELD_CATEGORY_DATE, UDAT_MONTH_FIELD, 31, 35}, | |
476 | {UFIELD_CATEGORY_DATE, UDAT_YEAR_FIELD, 36, 40}, | |
477 | {UFIELD_CATEGORY_DATE, UDAT_HOUR_OF_DAY0_FIELD, 42, 44}, | |
478 | {UFIELD_CATEGORY_DATE, UDAT_MINUTE_FIELD, 45, 47}}; | |
479 | checkMixedFormattedValue( | |
480 | message, | |
481 | udtitvfmt_resultAsValue(fdi, &ec), | |
482 | expectedString, | |
483 | expectedFieldPositions, | |
484 | UPRV_LENGTHOF(expectedFieldPositions)); | |
485 | } | |
486 | { | |
487 | const char* message = "Field position test 1"; | |
488 | const UChar* expectedString = u"27. September 2010, 15:00–22:00 Uhr"; | |
489 | udtitvfmt_formatToResult(fmt, fdi, Date201009270800, Date201009270800 + 7*_HOUR, &ec); | |
490 | assertSuccess("Formatting", &ec); | |
491 | static const UFieldPositionWithCategory expectedFieldPositions[] = { | |
492 | // category, field, begin index, end index | |
493 | {UFIELD_CATEGORY_DATE, UDAT_DATE_FIELD, 0, 2}, | |
494 | {UFIELD_CATEGORY_DATE, UDAT_MONTH_FIELD, 4, 13}, | |
495 | {UFIELD_CATEGORY_DATE, UDAT_YEAR_FIELD, 14, 18}, | |
496 | {UFIELD_CATEGORY_DATE_INTERVAL_SPAN, 0, 20, 25}, | |
497 | {UFIELD_CATEGORY_DATE, UDAT_HOUR_OF_DAY0_FIELD, 20, 22}, | |
498 | {UFIELD_CATEGORY_DATE, UDAT_MINUTE_FIELD, 23, 25}, | |
499 | {UFIELD_CATEGORY_DATE_INTERVAL_SPAN, 1, 26, 31}, | |
500 | {UFIELD_CATEGORY_DATE, UDAT_HOUR_OF_DAY0_FIELD, 26, 28}, | |
501 | {UFIELD_CATEGORY_DATE, UDAT_MINUTE_FIELD, 29, 31}, | |
502 | {UFIELD_CATEGORY_DATE, UDAT_AM_PM_FIELD, 32, 35}}; | |
503 | checkMixedFormattedValue( | |
504 | message, | |
505 | udtitvfmt_resultAsValue(fdi, &ec), | |
506 | expectedString, | |
507 | expectedFieldPositions, | |
508 | UPRV_LENGTHOF(expectedFieldPositions)); | |
509 | } | |
510 | ||
511 | udtitvfmt_close(fmt); | |
512 | udtitvfmt_closeResult(fdi); | |
513 | } | |
514 | ||
0f5d89e8 A |
515 | static const char* openLocales[] = { |
516 | "en", | |
517 | "en@calendar=japanese", | |
518 | "en@calendar=coptic", | |
519 | "en@calendar=chinese", | |
520 | "en_001", | |
521 | "en_001@calendar=japanese", | |
522 | "en_001@calendar=coptic", | |
523 | "en_001@calendar=chinese", | |
524 | "en_AU", | |
525 | "en_AU@calendar=japanese", // had problems | |
526 | "en_AU@calendar=coptic", // had problems | |
527 | "en_AU@calendar=chinese", | |
528 | "en_CA", | |
529 | "en_CA@calendar=japanese", // had problems | |
530 | "en_CA@calendar=coptic", // had problems | |
531 | "en_CA@calendar=chinese", | |
532 | "en_CN", | |
533 | "en_CN@calendar=japanese", // had problems | |
534 | "en_CN@calendar=coptic", // had problems | |
535 | "en_CN@calendar=chinese", | |
536 | "en_DE@calendar=japanese", // had problems | |
537 | "en_DE@calendar=coptic", // had problems | |
538 | "en_GB", | |
539 | "en_GB@calendar=japanese", // had problems | |
540 | "en_GB@calendar=coptic", // had problems | |
541 | "en_GB@calendar=chinese", | |
542 | "en_HK@calendar=japanese", // had problems | |
543 | "en_HK@calendar=coptic", // had problems | |
544 | "en_IE@calendar=japanese", // had problems | |
545 | "en_IE@calendar=coptic", // had problems | |
546 | "en_IN@calendar=japanese", // had problems | |
547 | "en_IN@calendar=coptic", // had problems | |
548 | "en_JP", | |
549 | "en_JP@calendar=japanese", | |
550 | "en_JP@calendar=coptic", | |
551 | "en_JP@calendar=chinese", | |
552 | "en_NZ", | |
553 | "en_NZ@calendar=japanese", // had problems | |
554 | "en_NZ@calendar=coptic", // had problems | |
555 | "en_NZ@calendar=chinese", | |
556 | "en_SG@calendar=japanese", // had problems | |
557 | "en_SG@calendar=coptic", // had problems | |
558 | "es", | |
559 | "es@calendar=japanese", | |
560 | "es@calendar=coptic", | |
561 | "es@calendar=chinese", | |
562 | "es_419", | |
563 | "es_419@calendar=japanese", // had problems | |
564 | "es_419@calendar=coptic", // had problems | |
565 | "es_419@calendar=chinese", | |
566 | "es_MX", | |
567 | "es_MX@calendar=japanese", | |
568 | "es_MX@calendar=coptic", | |
569 | "es_MX@calendar=chinese", | |
570 | "es_US", | |
571 | "es_US@calendar=japanese", | |
572 | "es_US@calendar=coptic", | |
573 | "es_US@calendar=chinese", | |
574 | "fr", | |
575 | "fr@calendar=japanese", | |
576 | "fr@calendar=coptic", | |
577 | "fr@calendar=chinese", | |
578 | "fr_CA", | |
579 | "fr_CA@calendar=japanese", // had problems | |
580 | "fr_CA@calendar=coptic", // had problems | |
581 | "fr_CA@calendar=chinese", | |
582 | "fr_CH", | |
583 | "fr_CH@calendar=japanese", | |
584 | "fr_CH@calendar=coptic", | |
585 | "fr_CH@calendar=chinese", | |
586 | "fr_BE", | |
587 | "fr_BE@calendar=japanese", | |
588 | "fr_BE@calendar=coptic", | |
589 | "fr_BE@calendar=chinese", | |
590 | "nl_BE@calendar=japanese", // had problems | |
591 | "nl_BE@calendar=coptic", // had problems | |
592 | "pt", | |
593 | "pt@calendar=japanese", | |
594 | "pt@calendar=coptic", | |
595 | "pt@calendar=chinese", | |
596 | "pt_PT", | |
597 | "pt_PT@calendar=japanese", // had problems | |
598 | "pt_PT@calendar=coptic", // had problems | |
599 | "pt_PT@calendar=chinese", | |
600 | "zh_Hant", | |
601 | "zh_Hant@calendar=japanese", | |
602 | "zh_Hant@calendar=coptic", | |
603 | "zh_Hant@calendar=chinese", | |
604 | "zh_Hant_HK", | |
605 | "zh_Hant_HK@calendar=japanese", // had problems | |
606 | "zh_Hant_HK@calendar=coptic", // had problems | |
607 | "zh_Hant_HK@calendar=chinese", | |
608 | NULL | |
609 | }; | |
610 | static const UChar* openSkeleton = u"zzzzyMMMMEEEEdhmmss"; | |
611 | static const UChar* openZone = u"America/Vancouver"; | |
612 | ||
613 | static void TestOpen() | |
614 | { | |
615 | const char* locale; | |
616 | const char** localesPtr = openLocales; | |
617 | while ((locale = *localesPtr++) != NULL) { | |
618 | UErrorCode status = U_ZERO_ERROR; | |
619 | UDateIntervalFormat* udatintv = udtitvfmt_open(locale, openSkeleton, -1, openZone, -1, &status); | |
620 | if ( U_FAILURE(status) ) { | |
621 | log_err("FAIL: udtitvfmt_open for locale %s: %s\n", locale, u_errorName(status)); | |
622 | } else { | |
623 | udtitvfmt_close(udatintv); | |
624 | } | |
625 | } | |
626 | } | |
627 | ||
4388f060 | 628 | #endif /* #if !UCONFIG_NO_FORMATTING */ |