1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
4 *******************************************************************************
5 * Copyright (C) 2014-2016, International Business Machines Corporation and *
6 * others. All Rights Reserved. *
7 *******************************************************************************
11 *******************************************************************************
18 #if !UCONFIG_NO_FORMATTING
20 #include "unicode/decimfmt.h"
21 #include "unicode/measfmt.h"
22 #include "unicode/measure.h"
23 #include "unicode/measunit.h"
24 #include "unicode/strenum.h"
25 #include "unicode/tmunit.h"
26 #include "unicode/plurrule.h"
27 #include "unicode/ustring.h"
30 #include "unicode/reldatefmt.h"
32 struct ExpectedResult
{
33 const Measure
*measures
;
38 class MeasureFormatTest
: public IntlTest
{
43 void runIndexedTest(int32_t index
, UBool exec
, const char *&name
, char *par
=0);
46 void TestCompatible53();
47 void TestCompatible54();
48 void TestCompatible55();
49 void TestCompatible56();
50 void TestCompatible57();
51 void TestCompatible58();
52 void TestCompatible59();
53 void TestGetAvailable();
54 void TestExamplesInDocs();
55 void TestFormatPeriodEn();
56 void Test10219FractionalPlurals();
58 void TestFormatSingleArg();
59 void TestFormatMeasuresZeroArg();
61 void TestNumeratorPlurals();
63 void TestManyLocaleDurations();
65 void TestCurrencies();
66 void TestDisplayNames();
67 void TestFieldPosition();
68 void TestFieldPositionMultiple();
71 void TestGroupingSeparator();
72 void TestDoubleZero();
73 void TestUnitPerUnitResolution();
74 void TestIndividualPluralFallback();
76 const char *description
,
77 const MeasureFormat
&fmt
,
78 const Measure
*measures
,
80 const char *expected
);
81 void verifyFormatWithPrefix(
82 const char *description
,
83 const MeasureFormat
&fmt
,
84 const UnicodeString
&prefix
,
85 const Measure
*measures
,
87 const char *expected
);
89 const char *description
,
90 const MeasureFormat
&fmt
,
91 const ExpectedResult
*expectedResults
,
93 void helperTestSimplePer(
95 UMeasureFormatWidth width
,
97 const MeasureUnit
&unit
,
98 const MeasureUnit
&perUnit
,
99 const char *expected
);
100 void helperTestSimplePer(
101 const Locale
&locale
,
102 UMeasureFormatWidth width
,
104 const MeasureUnit
&unit
,
105 const MeasureUnit
&perUnit
,
106 const char *expected
,
108 int32_t expected_start
,
109 int32_t expected_end
);
110 void helperTestMultiples(
111 const Locale
&locale
,
112 UMeasureFormatWidth width
,
113 const char *expected
);
114 void helperTestManyLocaleDurations(
115 const char *localeID
,
116 UMeasureFormatWidth width
,
117 const Measure
*measures
,
118 int32_t measureCount
,
119 const char *expected
);
120 void helperTestDisplayName(
121 const MeasureUnit
*unit
,
122 const char *localeID
,
123 UMeasureFormatWidth width
,
124 const char *expected
);
125 void verifyFieldPosition(
126 const char *description
,
127 const MeasureFormat
&fmt
,
128 const UnicodeString
&prefix
,
129 const Measure
*measures
,
130 int32_t measureCount
,
131 NumberFormat::EAlignmentFields field
,
136 void MeasureFormatTest::runIndexedTest(
137 int32_t index
, UBool exec
, const char *&name
, char *) {
139 logln("TestSuite MeasureFormatTest: ");
142 TESTCASE_AUTO(TestBasic
);
143 TESTCASE_AUTO(TestCompatible53
);
144 TESTCASE_AUTO(TestCompatible54
);
145 TESTCASE_AUTO(TestCompatible55
);
146 TESTCASE_AUTO(TestCompatible56
);
147 TESTCASE_AUTO(TestCompatible57
);
148 TESTCASE_AUTO(TestCompatible58
);
149 TESTCASE_AUTO(TestCompatible59
);
150 TESTCASE_AUTO(TestGetAvailable
);
151 TESTCASE_AUTO(TestExamplesInDocs
);
152 TESTCASE_AUTO(TestFormatPeriodEn
);
153 TESTCASE_AUTO(Test10219FractionalPlurals
);
154 TESTCASE_AUTO(TestGreek
);
155 TESTCASE_AUTO(TestFormatSingleArg
);
156 TESTCASE_AUTO(TestFormatMeasuresZeroArg
);
157 TESTCASE_AUTO(TestSimplePer
);
158 TESTCASE_AUTO(TestNumeratorPlurals
);
159 TESTCASE_AUTO(TestMultiples
);
160 TESTCASE_AUTO(TestManyLocaleDurations
);
161 TESTCASE_AUTO(TestGram
);
162 TESTCASE_AUTO(TestCurrencies
);
163 TESTCASE_AUTO(TestDisplayNames
);
164 TESTCASE_AUTO(TestFieldPosition
);
165 TESTCASE_AUTO(TestFieldPositionMultiple
);
166 TESTCASE_AUTO(TestBadArg
);
167 TESTCASE_AUTO(TestEquality
);
168 TESTCASE_AUTO(TestGroupingSeparator
);
169 TESTCASE_AUTO(TestDoubleZero
);
170 TESTCASE_AUTO(TestUnitPerUnitResolution
);
171 TESTCASE_AUTO(TestIndividualPluralFallback
);
175 void MeasureFormatTest::TestCompatible53() {
176 UErrorCode status
= U_ZERO_ERROR
;
177 LocalPointer
<MeasureUnit
> measureUnit
;
178 measureUnit
.adoptInstead(MeasureUnit::createGForce(status
));
179 measureUnit
.adoptInstead(MeasureUnit::createArcMinute(status
));
180 measureUnit
.adoptInstead(MeasureUnit::createArcSecond(status
));
181 measureUnit
.adoptInstead(MeasureUnit::createDegree(status
));
182 measureUnit
.adoptInstead(MeasureUnit::createAcre(status
));
183 measureUnit
.adoptInstead(MeasureUnit::createHectare(status
));
184 measureUnit
.adoptInstead(MeasureUnit::createSquareFoot(status
));
185 measureUnit
.adoptInstead(MeasureUnit::createSquareKilometer(status
));
186 measureUnit
.adoptInstead(MeasureUnit::createSquareMeter(status
));
187 measureUnit
.adoptInstead(MeasureUnit::createSquareMile(status
));
188 measureUnit
.adoptInstead(MeasureUnit::createDay(status
));
189 measureUnit
.adoptInstead(MeasureUnit::createHour(status
));
190 measureUnit
.adoptInstead(MeasureUnit::createMillisecond(status
));
191 measureUnit
.adoptInstead(MeasureUnit::createMinute(status
));
192 measureUnit
.adoptInstead(MeasureUnit::createMonth(status
));
193 measureUnit
.adoptInstead(MeasureUnit::createSecond(status
));
194 measureUnit
.adoptInstead(MeasureUnit::createWeek(status
));
195 measureUnit
.adoptInstead(MeasureUnit::createYear(status
));
196 measureUnit
.adoptInstead(MeasureUnit::createCentimeter(status
));
197 measureUnit
.adoptInstead(MeasureUnit::createFoot(status
));
198 measureUnit
.adoptInstead(MeasureUnit::createInch(status
));
199 measureUnit
.adoptInstead(MeasureUnit::createKilometer(status
));
200 measureUnit
.adoptInstead(MeasureUnit::createLightYear(status
));
201 measureUnit
.adoptInstead(MeasureUnit::createMeter(status
));
202 measureUnit
.adoptInstead(MeasureUnit::createMile(status
));
203 measureUnit
.adoptInstead(MeasureUnit::createMillimeter(status
));
204 measureUnit
.adoptInstead(MeasureUnit::createPicometer(status
));
205 measureUnit
.adoptInstead(MeasureUnit::createYard(status
));
206 measureUnit
.adoptInstead(MeasureUnit::createGram(status
));
207 measureUnit
.adoptInstead(MeasureUnit::createKilogram(status
));
208 measureUnit
.adoptInstead(MeasureUnit::createOunce(status
));
209 measureUnit
.adoptInstead(MeasureUnit::createPound(status
));
210 measureUnit
.adoptInstead(MeasureUnit::createHorsepower(status
));
211 measureUnit
.adoptInstead(MeasureUnit::createKilowatt(status
));
212 measureUnit
.adoptInstead(MeasureUnit::createWatt(status
));
213 measureUnit
.adoptInstead(MeasureUnit::createHectopascal(status
));
214 measureUnit
.adoptInstead(MeasureUnit::createInchHg(status
));
215 measureUnit
.adoptInstead(MeasureUnit::createMillibar(status
));
216 measureUnit
.adoptInstead(MeasureUnit::createKilometerPerHour(status
));
217 measureUnit
.adoptInstead(MeasureUnit::createMeterPerSecond(status
));
218 measureUnit
.adoptInstead(MeasureUnit::createMilePerHour(status
));
219 measureUnit
.adoptInstead(MeasureUnit::createCelsius(status
));
220 measureUnit
.adoptInstead(MeasureUnit::createFahrenheit(status
));
221 measureUnit
.adoptInstead(MeasureUnit::createCubicKilometer(status
));
222 measureUnit
.adoptInstead(MeasureUnit::createCubicMile(status
));
223 measureUnit
.adoptInstead(MeasureUnit::createLiter(status
));
224 assertSuccess("", status
);
227 void MeasureFormatTest::TestCompatible54() {
228 UErrorCode status
= U_ZERO_ERROR
;
229 LocalPointer
<MeasureUnit
> measureUnit
;
230 measureUnit
.adoptInstead(MeasureUnit::createGForce(status
));
231 measureUnit
.adoptInstead(MeasureUnit::createMeterPerSecondSquared(status
));
232 measureUnit
.adoptInstead(MeasureUnit::createArcMinute(status
));
233 measureUnit
.adoptInstead(MeasureUnit::createArcSecond(status
));
234 measureUnit
.adoptInstead(MeasureUnit::createDegree(status
));
235 measureUnit
.adoptInstead(MeasureUnit::createRadian(status
));
236 measureUnit
.adoptInstead(MeasureUnit::createAcre(status
));
237 measureUnit
.adoptInstead(MeasureUnit::createHectare(status
));
238 measureUnit
.adoptInstead(MeasureUnit::createSquareCentimeter(status
));
239 measureUnit
.adoptInstead(MeasureUnit::createSquareFoot(status
));
240 measureUnit
.adoptInstead(MeasureUnit::createSquareInch(status
));
241 measureUnit
.adoptInstead(MeasureUnit::createSquareKilometer(status
));
242 measureUnit
.adoptInstead(MeasureUnit::createSquareMeter(status
));
243 measureUnit
.adoptInstead(MeasureUnit::createSquareMile(status
));
244 measureUnit
.adoptInstead(MeasureUnit::createSquareYard(status
));
245 measureUnit
.adoptInstead(MeasureUnit::createLiterPerKilometer(status
));
246 measureUnit
.adoptInstead(MeasureUnit::createMilePerGallon(status
));
247 measureUnit
.adoptInstead(MeasureUnit::createBit(status
));
248 measureUnit
.adoptInstead(MeasureUnit::createByte(status
));
249 measureUnit
.adoptInstead(MeasureUnit::createGigabit(status
));
250 measureUnit
.adoptInstead(MeasureUnit::createGigabyte(status
));
251 measureUnit
.adoptInstead(MeasureUnit::createKilobit(status
));
252 measureUnit
.adoptInstead(MeasureUnit::createKilobyte(status
));
253 measureUnit
.adoptInstead(MeasureUnit::createMegabit(status
));
254 measureUnit
.adoptInstead(MeasureUnit::createMegabyte(status
));
255 measureUnit
.adoptInstead(MeasureUnit::createTerabit(status
));
256 measureUnit
.adoptInstead(MeasureUnit::createTerabyte(status
));
257 measureUnit
.adoptInstead(MeasureUnit::createDay(status
));
258 measureUnit
.adoptInstead(MeasureUnit::createHour(status
));
259 measureUnit
.adoptInstead(MeasureUnit::createMicrosecond(status
));
260 measureUnit
.adoptInstead(MeasureUnit::createMillisecond(status
));
261 measureUnit
.adoptInstead(MeasureUnit::createMinute(status
));
262 measureUnit
.adoptInstead(MeasureUnit::createMonth(status
));
263 measureUnit
.adoptInstead(MeasureUnit::createNanosecond(status
));
264 measureUnit
.adoptInstead(MeasureUnit::createSecond(status
));
265 measureUnit
.adoptInstead(MeasureUnit::createWeek(status
));
266 measureUnit
.adoptInstead(MeasureUnit::createYear(status
));
267 measureUnit
.adoptInstead(MeasureUnit::createAmpere(status
));
268 measureUnit
.adoptInstead(MeasureUnit::createMilliampere(status
));
269 measureUnit
.adoptInstead(MeasureUnit::createOhm(status
));
270 measureUnit
.adoptInstead(MeasureUnit::createVolt(status
));
271 measureUnit
.adoptInstead(MeasureUnit::createCalorie(status
));
272 measureUnit
.adoptInstead(MeasureUnit::createFoodcalorie(status
));
273 measureUnit
.adoptInstead(MeasureUnit::createJoule(status
));
274 measureUnit
.adoptInstead(MeasureUnit::createKilocalorie(status
));
275 measureUnit
.adoptInstead(MeasureUnit::createKilojoule(status
));
276 measureUnit
.adoptInstead(MeasureUnit::createKilowattHour(status
));
277 measureUnit
.adoptInstead(MeasureUnit::createGigahertz(status
));
278 measureUnit
.adoptInstead(MeasureUnit::createHertz(status
));
279 measureUnit
.adoptInstead(MeasureUnit::createKilohertz(status
));
280 measureUnit
.adoptInstead(MeasureUnit::createMegahertz(status
));
281 measureUnit
.adoptInstead(MeasureUnit::createAstronomicalUnit(status
));
282 measureUnit
.adoptInstead(MeasureUnit::createCentimeter(status
));
283 measureUnit
.adoptInstead(MeasureUnit::createDecimeter(status
));
284 measureUnit
.adoptInstead(MeasureUnit::createFathom(status
));
285 measureUnit
.adoptInstead(MeasureUnit::createFoot(status
));
286 measureUnit
.adoptInstead(MeasureUnit::createFurlong(status
));
287 measureUnit
.adoptInstead(MeasureUnit::createInch(status
));
288 measureUnit
.adoptInstead(MeasureUnit::createKilometer(status
));
289 measureUnit
.adoptInstead(MeasureUnit::createLightYear(status
));
290 measureUnit
.adoptInstead(MeasureUnit::createMeter(status
));
291 measureUnit
.adoptInstead(MeasureUnit::createMicrometer(status
));
292 measureUnit
.adoptInstead(MeasureUnit::createMile(status
));
293 measureUnit
.adoptInstead(MeasureUnit::createMillimeter(status
));
294 measureUnit
.adoptInstead(MeasureUnit::createNanometer(status
));
295 measureUnit
.adoptInstead(MeasureUnit::createNauticalMile(status
));
296 measureUnit
.adoptInstead(MeasureUnit::createParsec(status
));
297 measureUnit
.adoptInstead(MeasureUnit::createPicometer(status
));
298 measureUnit
.adoptInstead(MeasureUnit::createYard(status
));
299 measureUnit
.adoptInstead(MeasureUnit::createLux(status
));
300 measureUnit
.adoptInstead(MeasureUnit::createCarat(status
));
301 measureUnit
.adoptInstead(MeasureUnit::createGram(status
));
302 measureUnit
.adoptInstead(MeasureUnit::createKilogram(status
));
303 measureUnit
.adoptInstead(MeasureUnit::createMetricTon(status
));
304 measureUnit
.adoptInstead(MeasureUnit::createMicrogram(status
));
305 measureUnit
.adoptInstead(MeasureUnit::createMilligram(status
));
306 measureUnit
.adoptInstead(MeasureUnit::createOunce(status
));
307 measureUnit
.adoptInstead(MeasureUnit::createOunceTroy(status
));
308 measureUnit
.adoptInstead(MeasureUnit::createPound(status
));
309 measureUnit
.adoptInstead(MeasureUnit::createStone(status
));
310 measureUnit
.adoptInstead(MeasureUnit::createTon(status
));
311 measureUnit
.adoptInstead(MeasureUnit::createGigawatt(status
));
312 measureUnit
.adoptInstead(MeasureUnit::createHorsepower(status
));
313 measureUnit
.adoptInstead(MeasureUnit::createKilowatt(status
));
314 measureUnit
.adoptInstead(MeasureUnit::createMegawatt(status
));
315 measureUnit
.adoptInstead(MeasureUnit::createMilliwatt(status
));
316 measureUnit
.adoptInstead(MeasureUnit::createWatt(status
));
317 measureUnit
.adoptInstead(MeasureUnit::createHectopascal(status
));
318 measureUnit
.adoptInstead(MeasureUnit::createInchHg(status
));
319 measureUnit
.adoptInstead(MeasureUnit::createMillibar(status
));
320 measureUnit
.adoptInstead(MeasureUnit::createMillimeterOfMercury(status
));
321 measureUnit
.adoptInstead(MeasureUnit::createPoundPerSquareInch(status
));
322 measureUnit
.adoptInstead(MeasureUnit::createKarat(status
));
323 measureUnit
.adoptInstead(MeasureUnit::createKilometerPerHour(status
));
324 measureUnit
.adoptInstead(MeasureUnit::createMeterPerSecond(status
));
325 measureUnit
.adoptInstead(MeasureUnit::createMilePerHour(status
));
326 measureUnit
.adoptInstead(MeasureUnit::createCelsius(status
));
327 measureUnit
.adoptInstead(MeasureUnit::createFahrenheit(status
));
328 measureUnit
.adoptInstead(MeasureUnit::createKelvin(status
));
329 measureUnit
.adoptInstead(MeasureUnit::createAcreFoot(status
));
330 measureUnit
.adoptInstead(MeasureUnit::createBushel(status
));
331 measureUnit
.adoptInstead(MeasureUnit::createCentiliter(status
));
332 measureUnit
.adoptInstead(MeasureUnit::createCubicCentimeter(status
));
333 measureUnit
.adoptInstead(MeasureUnit::createCubicFoot(status
));
334 measureUnit
.adoptInstead(MeasureUnit::createCubicInch(status
));
335 measureUnit
.adoptInstead(MeasureUnit::createCubicKilometer(status
));
336 measureUnit
.adoptInstead(MeasureUnit::createCubicMeter(status
));
337 measureUnit
.adoptInstead(MeasureUnit::createCubicMile(status
));
338 measureUnit
.adoptInstead(MeasureUnit::createCubicYard(status
));
339 measureUnit
.adoptInstead(MeasureUnit::createCup(status
));
340 measureUnit
.adoptInstead(MeasureUnit::createDeciliter(status
));
341 measureUnit
.adoptInstead(MeasureUnit::createFluidOunce(status
));
342 measureUnit
.adoptInstead(MeasureUnit::createGallon(status
));
343 measureUnit
.adoptInstead(MeasureUnit::createHectoliter(status
));
344 measureUnit
.adoptInstead(MeasureUnit::createLiter(status
));
345 measureUnit
.adoptInstead(MeasureUnit::createMegaliter(status
));
346 measureUnit
.adoptInstead(MeasureUnit::createMilliliter(status
));
347 measureUnit
.adoptInstead(MeasureUnit::createPint(status
));
348 measureUnit
.adoptInstead(MeasureUnit::createQuart(status
));
349 measureUnit
.adoptInstead(MeasureUnit::createTablespoon(status
));
350 measureUnit
.adoptInstead(MeasureUnit::createTeaspoon(status
));
351 assertSuccess("", status
);
354 void MeasureFormatTest::TestCompatible55() {
355 UErrorCode status
= U_ZERO_ERROR
;
356 LocalPointer
<MeasureUnit
> measureUnit
;
357 measureUnit
.adoptInstead(MeasureUnit::createGForce(status
));
358 measureUnit
.adoptInstead(MeasureUnit::createMeterPerSecondSquared(status
));
359 measureUnit
.adoptInstead(MeasureUnit::createArcMinute(status
));
360 measureUnit
.adoptInstead(MeasureUnit::createArcSecond(status
));
361 measureUnit
.adoptInstead(MeasureUnit::createDegree(status
));
362 measureUnit
.adoptInstead(MeasureUnit::createRadian(status
));
363 measureUnit
.adoptInstead(MeasureUnit::createAcre(status
));
364 measureUnit
.adoptInstead(MeasureUnit::createHectare(status
));
365 measureUnit
.adoptInstead(MeasureUnit::createSquareCentimeter(status
));
366 measureUnit
.adoptInstead(MeasureUnit::createSquareFoot(status
));
367 measureUnit
.adoptInstead(MeasureUnit::createSquareInch(status
));
368 measureUnit
.adoptInstead(MeasureUnit::createSquareKilometer(status
));
369 measureUnit
.adoptInstead(MeasureUnit::createSquareMeter(status
));
370 measureUnit
.adoptInstead(MeasureUnit::createSquareMile(status
));
371 measureUnit
.adoptInstead(MeasureUnit::createSquareYard(status
));
372 measureUnit
.adoptInstead(MeasureUnit::createLiterPerKilometer(status
));
373 measureUnit
.adoptInstead(MeasureUnit::createMilePerGallon(status
));
374 measureUnit
.adoptInstead(MeasureUnit::createBit(status
));
375 measureUnit
.adoptInstead(MeasureUnit::createByte(status
));
376 measureUnit
.adoptInstead(MeasureUnit::createGigabit(status
));
377 measureUnit
.adoptInstead(MeasureUnit::createGigabyte(status
));
378 measureUnit
.adoptInstead(MeasureUnit::createKilobit(status
));
379 measureUnit
.adoptInstead(MeasureUnit::createKilobyte(status
));
380 measureUnit
.adoptInstead(MeasureUnit::createMegabit(status
));
381 measureUnit
.adoptInstead(MeasureUnit::createMegabyte(status
));
382 measureUnit
.adoptInstead(MeasureUnit::createTerabit(status
));
383 measureUnit
.adoptInstead(MeasureUnit::createTerabyte(status
));
384 measureUnit
.adoptInstead(MeasureUnit::createDay(status
));
385 measureUnit
.adoptInstead(MeasureUnit::createHour(status
));
386 measureUnit
.adoptInstead(MeasureUnit::createMicrosecond(status
));
387 measureUnit
.adoptInstead(MeasureUnit::createMillisecond(status
));
388 measureUnit
.adoptInstead(MeasureUnit::createMinute(status
));
389 measureUnit
.adoptInstead(MeasureUnit::createMonth(status
));
390 measureUnit
.adoptInstead(MeasureUnit::createNanosecond(status
));
391 measureUnit
.adoptInstead(MeasureUnit::createSecond(status
));
392 measureUnit
.adoptInstead(MeasureUnit::createWeek(status
));
393 measureUnit
.adoptInstead(MeasureUnit::createYear(status
));
394 measureUnit
.adoptInstead(MeasureUnit::createAmpere(status
));
395 measureUnit
.adoptInstead(MeasureUnit::createMilliampere(status
));
396 measureUnit
.adoptInstead(MeasureUnit::createOhm(status
));
397 measureUnit
.adoptInstead(MeasureUnit::createVolt(status
));
398 measureUnit
.adoptInstead(MeasureUnit::createCalorie(status
));
399 measureUnit
.adoptInstead(MeasureUnit::createFoodcalorie(status
));
400 measureUnit
.adoptInstead(MeasureUnit::createJoule(status
));
401 measureUnit
.adoptInstead(MeasureUnit::createKilocalorie(status
));
402 measureUnit
.adoptInstead(MeasureUnit::createKilojoule(status
));
403 measureUnit
.adoptInstead(MeasureUnit::createKilowattHour(status
));
404 measureUnit
.adoptInstead(MeasureUnit::createGigahertz(status
));
405 measureUnit
.adoptInstead(MeasureUnit::createHertz(status
));
406 measureUnit
.adoptInstead(MeasureUnit::createKilohertz(status
));
407 measureUnit
.adoptInstead(MeasureUnit::createMegahertz(status
));
408 measureUnit
.adoptInstead(MeasureUnit::createAstronomicalUnit(status
));
409 measureUnit
.adoptInstead(MeasureUnit::createCentimeter(status
));
410 measureUnit
.adoptInstead(MeasureUnit::createDecimeter(status
));
411 measureUnit
.adoptInstead(MeasureUnit::createFathom(status
));
412 measureUnit
.adoptInstead(MeasureUnit::createFoot(status
));
413 measureUnit
.adoptInstead(MeasureUnit::createFurlong(status
));
414 measureUnit
.adoptInstead(MeasureUnit::createInch(status
));
415 measureUnit
.adoptInstead(MeasureUnit::createKilometer(status
));
416 measureUnit
.adoptInstead(MeasureUnit::createLightYear(status
));
417 measureUnit
.adoptInstead(MeasureUnit::createMeter(status
));
418 measureUnit
.adoptInstead(MeasureUnit::createMicrometer(status
));
419 measureUnit
.adoptInstead(MeasureUnit::createMile(status
));
420 measureUnit
.adoptInstead(MeasureUnit::createMillimeter(status
));
421 measureUnit
.adoptInstead(MeasureUnit::createNanometer(status
));
422 measureUnit
.adoptInstead(MeasureUnit::createNauticalMile(status
));
423 measureUnit
.adoptInstead(MeasureUnit::createParsec(status
));
424 measureUnit
.adoptInstead(MeasureUnit::createPicometer(status
));
425 measureUnit
.adoptInstead(MeasureUnit::createYard(status
));
426 measureUnit
.adoptInstead(MeasureUnit::createLux(status
));
427 measureUnit
.adoptInstead(MeasureUnit::createCarat(status
));
428 measureUnit
.adoptInstead(MeasureUnit::createGram(status
));
429 measureUnit
.adoptInstead(MeasureUnit::createKilogram(status
));
430 measureUnit
.adoptInstead(MeasureUnit::createMetricTon(status
));
431 measureUnit
.adoptInstead(MeasureUnit::createMicrogram(status
));
432 measureUnit
.adoptInstead(MeasureUnit::createMilligram(status
));
433 measureUnit
.adoptInstead(MeasureUnit::createOunce(status
));
434 measureUnit
.adoptInstead(MeasureUnit::createOunceTroy(status
));
435 measureUnit
.adoptInstead(MeasureUnit::createPound(status
));
436 measureUnit
.adoptInstead(MeasureUnit::createStone(status
));
437 measureUnit
.adoptInstead(MeasureUnit::createTon(status
));
438 measureUnit
.adoptInstead(MeasureUnit::createGigawatt(status
));
439 measureUnit
.adoptInstead(MeasureUnit::createHorsepower(status
));
440 measureUnit
.adoptInstead(MeasureUnit::createKilowatt(status
));
441 measureUnit
.adoptInstead(MeasureUnit::createMegawatt(status
));
442 measureUnit
.adoptInstead(MeasureUnit::createMilliwatt(status
));
443 measureUnit
.adoptInstead(MeasureUnit::createWatt(status
));
444 measureUnit
.adoptInstead(MeasureUnit::createHectopascal(status
));
445 measureUnit
.adoptInstead(MeasureUnit::createInchHg(status
));
446 measureUnit
.adoptInstead(MeasureUnit::createMillibar(status
));
447 measureUnit
.adoptInstead(MeasureUnit::createMillimeterOfMercury(status
));
448 measureUnit
.adoptInstead(MeasureUnit::createPoundPerSquareInch(status
));
449 measureUnit
.adoptInstead(MeasureUnit::createKarat(status
));
450 measureUnit
.adoptInstead(MeasureUnit::createKilometerPerHour(status
));
451 measureUnit
.adoptInstead(MeasureUnit::createMeterPerSecond(status
));
452 measureUnit
.adoptInstead(MeasureUnit::createMilePerHour(status
));
453 measureUnit
.adoptInstead(MeasureUnit::createCelsius(status
));
454 measureUnit
.adoptInstead(MeasureUnit::createFahrenheit(status
));
455 measureUnit
.adoptInstead(MeasureUnit::createGenericTemperature(status
));
456 measureUnit
.adoptInstead(MeasureUnit::createKelvin(status
));
457 measureUnit
.adoptInstead(MeasureUnit::createAcreFoot(status
));
458 measureUnit
.adoptInstead(MeasureUnit::createBushel(status
));
459 measureUnit
.adoptInstead(MeasureUnit::createCentiliter(status
));
460 measureUnit
.adoptInstead(MeasureUnit::createCubicCentimeter(status
));
461 measureUnit
.adoptInstead(MeasureUnit::createCubicFoot(status
));
462 measureUnit
.adoptInstead(MeasureUnit::createCubicInch(status
));
463 measureUnit
.adoptInstead(MeasureUnit::createCubicKilometer(status
));
464 measureUnit
.adoptInstead(MeasureUnit::createCubicMeter(status
));
465 measureUnit
.adoptInstead(MeasureUnit::createCubicMile(status
));
466 measureUnit
.adoptInstead(MeasureUnit::createCubicYard(status
));
467 measureUnit
.adoptInstead(MeasureUnit::createCup(status
));
468 measureUnit
.adoptInstead(MeasureUnit::createDeciliter(status
));
469 measureUnit
.adoptInstead(MeasureUnit::createFluidOunce(status
));
470 measureUnit
.adoptInstead(MeasureUnit::createGallon(status
));
471 measureUnit
.adoptInstead(MeasureUnit::createHectoliter(status
));
472 measureUnit
.adoptInstead(MeasureUnit::createLiter(status
));
473 measureUnit
.adoptInstead(MeasureUnit::createMegaliter(status
));
474 measureUnit
.adoptInstead(MeasureUnit::createMilliliter(status
));
475 measureUnit
.adoptInstead(MeasureUnit::createPint(status
));
476 measureUnit
.adoptInstead(MeasureUnit::createQuart(status
));
477 measureUnit
.adoptInstead(MeasureUnit::createTablespoon(status
));
478 measureUnit
.adoptInstead(MeasureUnit::createTeaspoon(status
));
479 assertSuccess("", status
);
482 void MeasureFormatTest::TestCompatible56() {
483 UErrorCode status
= U_ZERO_ERROR
;
484 LocalPointer
<MeasureUnit
> measureUnit
;
485 measureUnit
.adoptInstead(MeasureUnit::createGForce(status
));
486 measureUnit
.adoptInstead(MeasureUnit::createMeterPerSecondSquared(status
));
487 measureUnit
.adoptInstead(MeasureUnit::createArcMinute(status
));
488 measureUnit
.adoptInstead(MeasureUnit::createArcSecond(status
));
489 measureUnit
.adoptInstead(MeasureUnit::createDegree(status
));
490 measureUnit
.adoptInstead(MeasureUnit::createRadian(status
));
491 measureUnit
.adoptInstead(MeasureUnit::createRevolutionAngle(status
));
492 measureUnit
.adoptInstead(MeasureUnit::createAcre(status
));
493 measureUnit
.adoptInstead(MeasureUnit::createHectare(status
));
494 measureUnit
.adoptInstead(MeasureUnit::createSquareCentimeter(status
));
495 measureUnit
.adoptInstead(MeasureUnit::createSquareFoot(status
));
496 measureUnit
.adoptInstead(MeasureUnit::createSquareInch(status
));
497 measureUnit
.adoptInstead(MeasureUnit::createSquareKilometer(status
));
498 measureUnit
.adoptInstead(MeasureUnit::createSquareMeter(status
));
499 measureUnit
.adoptInstead(MeasureUnit::createSquareMile(status
));
500 measureUnit
.adoptInstead(MeasureUnit::createSquareYard(status
));
501 measureUnit
.adoptInstead(MeasureUnit::createLiterPer100Kilometers(status
));
502 measureUnit
.adoptInstead(MeasureUnit::createLiterPerKilometer(status
));
503 measureUnit
.adoptInstead(MeasureUnit::createMilePerGallon(status
));
504 measureUnit
.adoptInstead(MeasureUnit::createBit(status
));
505 measureUnit
.adoptInstead(MeasureUnit::createByte(status
));
506 measureUnit
.adoptInstead(MeasureUnit::createGigabit(status
));
507 measureUnit
.adoptInstead(MeasureUnit::createGigabyte(status
));
508 measureUnit
.adoptInstead(MeasureUnit::createKilobit(status
));
509 measureUnit
.adoptInstead(MeasureUnit::createKilobyte(status
));
510 measureUnit
.adoptInstead(MeasureUnit::createMegabit(status
));
511 measureUnit
.adoptInstead(MeasureUnit::createMegabyte(status
));
512 measureUnit
.adoptInstead(MeasureUnit::createTerabit(status
));
513 measureUnit
.adoptInstead(MeasureUnit::createTerabyte(status
));
514 measureUnit
.adoptInstead(MeasureUnit::createCentury(status
));
515 measureUnit
.adoptInstead(MeasureUnit::createDay(status
));
516 measureUnit
.adoptInstead(MeasureUnit::createHour(status
));
517 measureUnit
.adoptInstead(MeasureUnit::createMicrosecond(status
));
518 measureUnit
.adoptInstead(MeasureUnit::createMillisecond(status
));
519 measureUnit
.adoptInstead(MeasureUnit::createMinute(status
));
520 measureUnit
.adoptInstead(MeasureUnit::createMonth(status
));
521 measureUnit
.adoptInstead(MeasureUnit::createNanosecond(status
));
522 measureUnit
.adoptInstead(MeasureUnit::createSecond(status
));
523 measureUnit
.adoptInstead(MeasureUnit::createWeek(status
));
524 measureUnit
.adoptInstead(MeasureUnit::createYear(status
));
525 measureUnit
.adoptInstead(MeasureUnit::createAmpere(status
));
526 measureUnit
.adoptInstead(MeasureUnit::createMilliampere(status
));
527 measureUnit
.adoptInstead(MeasureUnit::createOhm(status
));
528 measureUnit
.adoptInstead(MeasureUnit::createVolt(status
));
529 measureUnit
.adoptInstead(MeasureUnit::createCalorie(status
));
530 measureUnit
.adoptInstead(MeasureUnit::createFoodcalorie(status
));
531 measureUnit
.adoptInstead(MeasureUnit::createJoule(status
));
532 measureUnit
.adoptInstead(MeasureUnit::createKilocalorie(status
));
533 measureUnit
.adoptInstead(MeasureUnit::createKilojoule(status
));
534 measureUnit
.adoptInstead(MeasureUnit::createKilowattHour(status
));
535 measureUnit
.adoptInstead(MeasureUnit::createGigahertz(status
));
536 measureUnit
.adoptInstead(MeasureUnit::createHertz(status
));
537 measureUnit
.adoptInstead(MeasureUnit::createKilohertz(status
));
538 measureUnit
.adoptInstead(MeasureUnit::createMegahertz(status
));
539 measureUnit
.adoptInstead(MeasureUnit::createAstronomicalUnit(status
));
540 measureUnit
.adoptInstead(MeasureUnit::createCentimeter(status
));
541 measureUnit
.adoptInstead(MeasureUnit::createDecimeter(status
));
542 measureUnit
.adoptInstead(MeasureUnit::createFathom(status
));
543 measureUnit
.adoptInstead(MeasureUnit::createFoot(status
));
544 measureUnit
.adoptInstead(MeasureUnit::createFurlong(status
));
545 measureUnit
.adoptInstead(MeasureUnit::createInch(status
));
546 measureUnit
.adoptInstead(MeasureUnit::createKilometer(status
));
547 measureUnit
.adoptInstead(MeasureUnit::createLightYear(status
));
548 measureUnit
.adoptInstead(MeasureUnit::createMeter(status
));
549 measureUnit
.adoptInstead(MeasureUnit::createMicrometer(status
));
550 measureUnit
.adoptInstead(MeasureUnit::createMile(status
));
551 measureUnit
.adoptInstead(MeasureUnit::createMileScandinavian(status
));
552 measureUnit
.adoptInstead(MeasureUnit::createMillimeter(status
));
553 measureUnit
.adoptInstead(MeasureUnit::createNanometer(status
));
554 measureUnit
.adoptInstead(MeasureUnit::createNauticalMile(status
));
555 measureUnit
.adoptInstead(MeasureUnit::createParsec(status
));
556 measureUnit
.adoptInstead(MeasureUnit::createPicometer(status
));
557 measureUnit
.adoptInstead(MeasureUnit::createYard(status
));
558 measureUnit
.adoptInstead(MeasureUnit::createLux(status
));
559 measureUnit
.adoptInstead(MeasureUnit::createCarat(status
));
560 measureUnit
.adoptInstead(MeasureUnit::createGram(status
));
561 measureUnit
.adoptInstead(MeasureUnit::createKilogram(status
));
562 measureUnit
.adoptInstead(MeasureUnit::createMetricTon(status
));
563 measureUnit
.adoptInstead(MeasureUnit::createMicrogram(status
));
564 measureUnit
.adoptInstead(MeasureUnit::createMilligram(status
));
565 measureUnit
.adoptInstead(MeasureUnit::createOunce(status
));
566 measureUnit
.adoptInstead(MeasureUnit::createOunceTroy(status
));
567 measureUnit
.adoptInstead(MeasureUnit::createPound(status
));
568 measureUnit
.adoptInstead(MeasureUnit::createStone(status
));
569 measureUnit
.adoptInstead(MeasureUnit::createTon(status
));
570 measureUnit
.adoptInstead(MeasureUnit::createGigawatt(status
));
571 measureUnit
.adoptInstead(MeasureUnit::createHorsepower(status
));
572 measureUnit
.adoptInstead(MeasureUnit::createKilowatt(status
));
573 measureUnit
.adoptInstead(MeasureUnit::createMegawatt(status
));
574 measureUnit
.adoptInstead(MeasureUnit::createMilliwatt(status
));
575 measureUnit
.adoptInstead(MeasureUnit::createWatt(status
));
576 measureUnit
.adoptInstead(MeasureUnit::createHectopascal(status
));
577 measureUnit
.adoptInstead(MeasureUnit::createInchHg(status
));
578 measureUnit
.adoptInstead(MeasureUnit::createMillibar(status
));
579 measureUnit
.adoptInstead(MeasureUnit::createMillimeterOfMercury(status
));
580 measureUnit
.adoptInstead(MeasureUnit::createPoundPerSquareInch(status
));
581 measureUnit
.adoptInstead(MeasureUnit::createKarat(status
));
582 measureUnit
.adoptInstead(MeasureUnit::createKilometerPerHour(status
));
583 measureUnit
.adoptInstead(MeasureUnit::createKnot(status
));
584 measureUnit
.adoptInstead(MeasureUnit::createMeterPerSecond(status
));
585 measureUnit
.adoptInstead(MeasureUnit::createMilePerHour(status
));
586 measureUnit
.adoptInstead(MeasureUnit::createCelsius(status
));
587 measureUnit
.adoptInstead(MeasureUnit::createFahrenheit(status
));
588 measureUnit
.adoptInstead(MeasureUnit::createGenericTemperature(status
));
589 measureUnit
.adoptInstead(MeasureUnit::createKelvin(status
));
590 measureUnit
.adoptInstead(MeasureUnit::createAcreFoot(status
));
591 measureUnit
.adoptInstead(MeasureUnit::createBushel(status
));
592 measureUnit
.adoptInstead(MeasureUnit::createCentiliter(status
));
593 measureUnit
.adoptInstead(MeasureUnit::createCubicCentimeter(status
));
594 measureUnit
.adoptInstead(MeasureUnit::createCubicFoot(status
));
595 measureUnit
.adoptInstead(MeasureUnit::createCubicInch(status
));
596 measureUnit
.adoptInstead(MeasureUnit::createCubicKilometer(status
));
597 measureUnit
.adoptInstead(MeasureUnit::createCubicMeter(status
));
598 measureUnit
.adoptInstead(MeasureUnit::createCubicMile(status
));
599 measureUnit
.adoptInstead(MeasureUnit::createCubicYard(status
));
600 measureUnit
.adoptInstead(MeasureUnit::createCup(status
));
601 measureUnit
.adoptInstead(MeasureUnit::createCupMetric(status
));
602 measureUnit
.adoptInstead(MeasureUnit::createDeciliter(status
));
603 measureUnit
.adoptInstead(MeasureUnit::createFluidOunce(status
));
604 measureUnit
.adoptInstead(MeasureUnit::createGallon(status
));
605 measureUnit
.adoptInstead(MeasureUnit::createHectoliter(status
));
606 measureUnit
.adoptInstead(MeasureUnit::createLiter(status
));
607 measureUnit
.adoptInstead(MeasureUnit::createMegaliter(status
));
608 measureUnit
.adoptInstead(MeasureUnit::createMilliliter(status
));
609 measureUnit
.adoptInstead(MeasureUnit::createPint(status
));
610 measureUnit
.adoptInstead(MeasureUnit::createPintMetric(status
));
611 measureUnit
.adoptInstead(MeasureUnit::createQuart(status
));
612 measureUnit
.adoptInstead(MeasureUnit::createTablespoon(status
));
613 measureUnit
.adoptInstead(MeasureUnit::createTeaspoon(status
));
614 assertSuccess("", status
);
617 void MeasureFormatTest::TestCompatible57() {
618 UErrorCode status
= U_ZERO_ERROR
;
619 LocalPointer
<MeasureUnit
> measureUnit
;
620 measureUnit
.adoptInstead(MeasureUnit::createGForce(status
));
621 measureUnit
.adoptInstead(MeasureUnit::createMeterPerSecondSquared(status
));
622 measureUnit
.adoptInstead(MeasureUnit::createArcMinute(status
));
623 measureUnit
.adoptInstead(MeasureUnit::createArcSecond(status
));
624 measureUnit
.adoptInstead(MeasureUnit::createDegree(status
));
625 measureUnit
.adoptInstead(MeasureUnit::createRadian(status
));
626 measureUnit
.adoptInstead(MeasureUnit::createRevolutionAngle(status
));
627 measureUnit
.adoptInstead(MeasureUnit::createAcre(status
));
628 measureUnit
.adoptInstead(MeasureUnit::createHectare(status
));
629 measureUnit
.adoptInstead(MeasureUnit::createSquareCentimeter(status
));
630 measureUnit
.adoptInstead(MeasureUnit::createSquareFoot(status
));
631 measureUnit
.adoptInstead(MeasureUnit::createSquareInch(status
));
632 measureUnit
.adoptInstead(MeasureUnit::createSquareKilometer(status
));
633 measureUnit
.adoptInstead(MeasureUnit::createSquareMeter(status
));
634 measureUnit
.adoptInstead(MeasureUnit::createSquareMile(status
));
635 measureUnit
.adoptInstead(MeasureUnit::createSquareYard(status
));
636 measureUnit
.adoptInstead(MeasureUnit::createKarat(status
));
637 measureUnit
.adoptInstead(MeasureUnit::createMilligramPerDeciliter(status
));
638 measureUnit
.adoptInstead(MeasureUnit::createMillimolePerLiter(status
));
639 measureUnit
.adoptInstead(MeasureUnit::createPartPerMillion(status
));
640 measureUnit
.adoptInstead(MeasureUnit::createLiterPer100Kilometers(status
));
641 measureUnit
.adoptInstead(MeasureUnit::createLiterPerKilometer(status
));
642 measureUnit
.adoptInstead(MeasureUnit::createMilePerGallon(status
));
643 measureUnit
.adoptInstead(MeasureUnit::createMilePerGallonImperial(status
));
644 measureUnit
.adoptInstead(MeasureUnit::createBit(status
));
645 measureUnit
.adoptInstead(MeasureUnit::createByte(status
));
646 measureUnit
.adoptInstead(MeasureUnit::createGigabit(status
));
647 measureUnit
.adoptInstead(MeasureUnit::createGigabyte(status
));
648 measureUnit
.adoptInstead(MeasureUnit::createKilobit(status
));
649 measureUnit
.adoptInstead(MeasureUnit::createKilobyte(status
));
650 measureUnit
.adoptInstead(MeasureUnit::createMegabit(status
));
651 measureUnit
.adoptInstead(MeasureUnit::createMegabyte(status
));
652 measureUnit
.adoptInstead(MeasureUnit::createTerabit(status
));
653 measureUnit
.adoptInstead(MeasureUnit::createTerabyte(status
));
654 measureUnit
.adoptInstead(MeasureUnit::createCentury(status
));
655 measureUnit
.adoptInstead(MeasureUnit::createDay(status
));
656 measureUnit
.adoptInstead(MeasureUnit::createHour(status
));
657 measureUnit
.adoptInstead(MeasureUnit::createMicrosecond(status
));
658 measureUnit
.adoptInstead(MeasureUnit::createMillisecond(status
));
659 measureUnit
.adoptInstead(MeasureUnit::createMinute(status
));
660 measureUnit
.adoptInstead(MeasureUnit::createMonth(status
));
661 measureUnit
.adoptInstead(MeasureUnit::createNanosecond(status
));
662 measureUnit
.adoptInstead(MeasureUnit::createSecond(status
));
663 measureUnit
.adoptInstead(MeasureUnit::createWeek(status
));
664 measureUnit
.adoptInstead(MeasureUnit::createYear(status
));
665 measureUnit
.adoptInstead(MeasureUnit::createAmpere(status
));
666 measureUnit
.adoptInstead(MeasureUnit::createMilliampere(status
));
667 measureUnit
.adoptInstead(MeasureUnit::createOhm(status
));
668 measureUnit
.adoptInstead(MeasureUnit::createVolt(status
));
669 measureUnit
.adoptInstead(MeasureUnit::createCalorie(status
));
670 measureUnit
.adoptInstead(MeasureUnit::createFoodcalorie(status
));
671 measureUnit
.adoptInstead(MeasureUnit::createJoule(status
));
672 measureUnit
.adoptInstead(MeasureUnit::createKilocalorie(status
));
673 measureUnit
.adoptInstead(MeasureUnit::createKilojoule(status
));
674 measureUnit
.adoptInstead(MeasureUnit::createKilowattHour(status
));
675 measureUnit
.adoptInstead(MeasureUnit::createGigahertz(status
));
676 measureUnit
.adoptInstead(MeasureUnit::createHertz(status
));
677 measureUnit
.adoptInstead(MeasureUnit::createKilohertz(status
));
678 measureUnit
.adoptInstead(MeasureUnit::createMegahertz(status
));
679 measureUnit
.adoptInstead(MeasureUnit::createAstronomicalUnit(status
));
680 measureUnit
.adoptInstead(MeasureUnit::createCentimeter(status
));
681 measureUnit
.adoptInstead(MeasureUnit::createDecimeter(status
));
682 measureUnit
.adoptInstead(MeasureUnit::createFathom(status
));
683 measureUnit
.adoptInstead(MeasureUnit::createFoot(status
));
684 measureUnit
.adoptInstead(MeasureUnit::createFurlong(status
));
685 measureUnit
.adoptInstead(MeasureUnit::createInch(status
));
686 measureUnit
.adoptInstead(MeasureUnit::createKilometer(status
));
687 measureUnit
.adoptInstead(MeasureUnit::createLightYear(status
));
688 measureUnit
.adoptInstead(MeasureUnit::createMeter(status
));
689 measureUnit
.adoptInstead(MeasureUnit::createMicrometer(status
));
690 measureUnit
.adoptInstead(MeasureUnit::createMile(status
));
691 measureUnit
.adoptInstead(MeasureUnit::createMileScandinavian(status
));
692 measureUnit
.adoptInstead(MeasureUnit::createMillimeter(status
));
693 measureUnit
.adoptInstead(MeasureUnit::createNanometer(status
));
694 measureUnit
.adoptInstead(MeasureUnit::createNauticalMile(status
));
695 measureUnit
.adoptInstead(MeasureUnit::createParsec(status
));
696 measureUnit
.adoptInstead(MeasureUnit::createPicometer(status
));
697 measureUnit
.adoptInstead(MeasureUnit::createYard(status
));
698 measureUnit
.adoptInstead(MeasureUnit::createLux(status
));
699 measureUnit
.adoptInstead(MeasureUnit::createCarat(status
));
700 measureUnit
.adoptInstead(MeasureUnit::createGram(status
));
701 measureUnit
.adoptInstead(MeasureUnit::createKilogram(status
));
702 measureUnit
.adoptInstead(MeasureUnit::createMetricTon(status
));
703 measureUnit
.adoptInstead(MeasureUnit::createMicrogram(status
));
704 measureUnit
.adoptInstead(MeasureUnit::createMilligram(status
));
705 measureUnit
.adoptInstead(MeasureUnit::createOunce(status
));
706 measureUnit
.adoptInstead(MeasureUnit::createOunceTroy(status
));
707 measureUnit
.adoptInstead(MeasureUnit::createPound(status
));
708 measureUnit
.adoptInstead(MeasureUnit::createStone(status
));
709 measureUnit
.adoptInstead(MeasureUnit::createTon(status
));
710 measureUnit
.adoptInstead(MeasureUnit::createGigawatt(status
));
711 measureUnit
.adoptInstead(MeasureUnit::createHorsepower(status
));
712 measureUnit
.adoptInstead(MeasureUnit::createKilowatt(status
));
713 measureUnit
.adoptInstead(MeasureUnit::createMegawatt(status
));
714 measureUnit
.adoptInstead(MeasureUnit::createMilliwatt(status
));
715 measureUnit
.adoptInstead(MeasureUnit::createWatt(status
));
716 measureUnit
.adoptInstead(MeasureUnit::createHectopascal(status
));
717 measureUnit
.adoptInstead(MeasureUnit::createInchHg(status
));
718 measureUnit
.adoptInstead(MeasureUnit::createMillibar(status
));
719 measureUnit
.adoptInstead(MeasureUnit::createMillimeterOfMercury(status
));
720 measureUnit
.adoptInstead(MeasureUnit::createPoundPerSquareInch(status
));
721 measureUnit
.adoptInstead(MeasureUnit::createKilometerPerHour(status
));
722 measureUnit
.adoptInstead(MeasureUnit::createKnot(status
));
723 measureUnit
.adoptInstead(MeasureUnit::createMeterPerSecond(status
));
724 measureUnit
.adoptInstead(MeasureUnit::createMilePerHour(status
));
725 measureUnit
.adoptInstead(MeasureUnit::createCelsius(status
));
726 measureUnit
.adoptInstead(MeasureUnit::createFahrenheit(status
));
727 measureUnit
.adoptInstead(MeasureUnit::createGenericTemperature(status
));
728 measureUnit
.adoptInstead(MeasureUnit::createKelvin(status
));
729 measureUnit
.adoptInstead(MeasureUnit::createAcreFoot(status
));
730 measureUnit
.adoptInstead(MeasureUnit::createBushel(status
));
731 measureUnit
.adoptInstead(MeasureUnit::createCentiliter(status
));
732 measureUnit
.adoptInstead(MeasureUnit::createCubicCentimeter(status
));
733 measureUnit
.adoptInstead(MeasureUnit::createCubicFoot(status
));
734 measureUnit
.adoptInstead(MeasureUnit::createCubicInch(status
));
735 measureUnit
.adoptInstead(MeasureUnit::createCubicKilometer(status
));
736 measureUnit
.adoptInstead(MeasureUnit::createCubicMeter(status
));
737 measureUnit
.adoptInstead(MeasureUnit::createCubicMile(status
));
738 measureUnit
.adoptInstead(MeasureUnit::createCubicYard(status
));
739 measureUnit
.adoptInstead(MeasureUnit::createCup(status
));
740 measureUnit
.adoptInstead(MeasureUnit::createCupMetric(status
));
741 measureUnit
.adoptInstead(MeasureUnit::createDeciliter(status
));
742 measureUnit
.adoptInstead(MeasureUnit::createFluidOunce(status
));
743 measureUnit
.adoptInstead(MeasureUnit::createGallon(status
));
744 measureUnit
.adoptInstead(MeasureUnit::createGallonImperial(status
));
745 measureUnit
.adoptInstead(MeasureUnit::createHectoliter(status
));
746 measureUnit
.adoptInstead(MeasureUnit::createLiter(status
));
747 measureUnit
.adoptInstead(MeasureUnit::createMegaliter(status
));
748 measureUnit
.adoptInstead(MeasureUnit::createMilliliter(status
));
749 measureUnit
.adoptInstead(MeasureUnit::createPint(status
));
750 measureUnit
.adoptInstead(MeasureUnit::createPintMetric(status
));
751 measureUnit
.adoptInstead(MeasureUnit::createQuart(status
));
752 measureUnit
.adoptInstead(MeasureUnit::createTablespoon(status
));
753 measureUnit
.adoptInstead(MeasureUnit::createTeaspoon(status
));
754 assertSuccess("", status
);
757 void MeasureFormatTest::TestCompatible58() {
758 UErrorCode status
= U_ZERO_ERROR
;
759 LocalPointer
<MeasureUnit
> measureUnit
;
760 measureUnit
.adoptInstead(MeasureUnit::createGForce(status
));
761 measureUnit
.adoptInstead(MeasureUnit::createMeterPerSecondSquared(status
));
762 measureUnit
.adoptInstead(MeasureUnit::createArcMinute(status
));
763 measureUnit
.adoptInstead(MeasureUnit::createArcSecond(status
));
764 measureUnit
.adoptInstead(MeasureUnit::createDegree(status
));
765 measureUnit
.adoptInstead(MeasureUnit::createRadian(status
));
766 measureUnit
.adoptInstead(MeasureUnit::createRevolutionAngle(status
));
767 measureUnit
.adoptInstead(MeasureUnit::createAcre(status
));
768 measureUnit
.adoptInstead(MeasureUnit::createHectare(status
));
769 measureUnit
.adoptInstead(MeasureUnit::createSquareCentimeter(status
));
770 measureUnit
.adoptInstead(MeasureUnit::createSquareFoot(status
));
771 measureUnit
.adoptInstead(MeasureUnit::createSquareInch(status
));
772 measureUnit
.adoptInstead(MeasureUnit::createSquareKilometer(status
));
773 measureUnit
.adoptInstead(MeasureUnit::createSquareMeter(status
));
774 measureUnit
.adoptInstead(MeasureUnit::createSquareMile(status
));
775 measureUnit
.adoptInstead(MeasureUnit::createSquareYard(status
));
776 measureUnit
.adoptInstead(MeasureUnit::createKarat(status
));
777 measureUnit
.adoptInstead(MeasureUnit::createMilligramPerDeciliter(status
));
778 measureUnit
.adoptInstead(MeasureUnit::createMillimolePerLiter(status
));
779 measureUnit
.adoptInstead(MeasureUnit::createPartPerMillion(status
));
780 measureUnit
.adoptInstead(MeasureUnit::createLiterPer100Kilometers(status
));
781 measureUnit
.adoptInstead(MeasureUnit::createLiterPerKilometer(status
));
782 measureUnit
.adoptInstead(MeasureUnit::createMilePerGallon(status
));
783 measureUnit
.adoptInstead(MeasureUnit::createMilePerGallonImperial(status
));
784 // measureUnit.adoptInstead(MeasureUnit::createEast(status));
785 // measureUnit.adoptInstead(MeasureUnit::createNorth(status));
786 // measureUnit.adoptInstead(MeasureUnit::createSouth(status));
787 // measureUnit.adoptInstead(MeasureUnit::createWest(status));
788 measureUnit
.adoptInstead(MeasureUnit::createBit(status
));
789 measureUnit
.adoptInstead(MeasureUnit::createByte(status
));
790 measureUnit
.adoptInstead(MeasureUnit::createGigabit(status
));
791 measureUnit
.adoptInstead(MeasureUnit::createGigabyte(status
));
792 measureUnit
.adoptInstead(MeasureUnit::createKilobit(status
));
793 measureUnit
.adoptInstead(MeasureUnit::createKilobyte(status
));
794 measureUnit
.adoptInstead(MeasureUnit::createMegabit(status
));
795 measureUnit
.adoptInstead(MeasureUnit::createMegabyte(status
));
796 measureUnit
.adoptInstead(MeasureUnit::createTerabit(status
));
797 measureUnit
.adoptInstead(MeasureUnit::createTerabyte(status
));
798 measureUnit
.adoptInstead(MeasureUnit::createCentury(status
));
799 measureUnit
.adoptInstead(MeasureUnit::createDay(status
));
800 measureUnit
.adoptInstead(MeasureUnit::createHour(status
));
801 measureUnit
.adoptInstead(MeasureUnit::createMicrosecond(status
));
802 measureUnit
.adoptInstead(MeasureUnit::createMillisecond(status
));
803 measureUnit
.adoptInstead(MeasureUnit::createMinute(status
));
804 measureUnit
.adoptInstead(MeasureUnit::createMonth(status
));
805 measureUnit
.adoptInstead(MeasureUnit::createNanosecond(status
));
806 measureUnit
.adoptInstead(MeasureUnit::createSecond(status
));
807 measureUnit
.adoptInstead(MeasureUnit::createWeek(status
));
808 measureUnit
.adoptInstead(MeasureUnit::createYear(status
));
809 measureUnit
.adoptInstead(MeasureUnit::createAmpere(status
));
810 measureUnit
.adoptInstead(MeasureUnit::createMilliampere(status
));
811 measureUnit
.adoptInstead(MeasureUnit::createOhm(status
));
812 measureUnit
.adoptInstead(MeasureUnit::createVolt(status
));
813 measureUnit
.adoptInstead(MeasureUnit::createCalorie(status
));
814 measureUnit
.adoptInstead(MeasureUnit::createFoodcalorie(status
));
815 measureUnit
.adoptInstead(MeasureUnit::createJoule(status
));
816 measureUnit
.adoptInstead(MeasureUnit::createKilocalorie(status
));
817 measureUnit
.adoptInstead(MeasureUnit::createKilojoule(status
));
818 measureUnit
.adoptInstead(MeasureUnit::createKilowattHour(status
));
819 measureUnit
.adoptInstead(MeasureUnit::createGigahertz(status
));
820 measureUnit
.adoptInstead(MeasureUnit::createHertz(status
));
821 measureUnit
.adoptInstead(MeasureUnit::createKilohertz(status
));
822 measureUnit
.adoptInstead(MeasureUnit::createMegahertz(status
));
823 measureUnit
.adoptInstead(MeasureUnit::createAstronomicalUnit(status
));
824 measureUnit
.adoptInstead(MeasureUnit::createCentimeter(status
));
825 measureUnit
.adoptInstead(MeasureUnit::createDecimeter(status
));
826 measureUnit
.adoptInstead(MeasureUnit::createFathom(status
));
827 measureUnit
.adoptInstead(MeasureUnit::createFoot(status
));
828 measureUnit
.adoptInstead(MeasureUnit::createFurlong(status
));
829 measureUnit
.adoptInstead(MeasureUnit::createInch(status
));
830 measureUnit
.adoptInstead(MeasureUnit::createKilometer(status
));
831 measureUnit
.adoptInstead(MeasureUnit::createLightYear(status
));
832 measureUnit
.adoptInstead(MeasureUnit::createMeter(status
));
833 measureUnit
.adoptInstead(MeasureUnit::createMicrometer(status
));
834 measureUnit
.adoptInstead(MeasureUnit::createMile(status
));
835 measureUnit
.adoptInstead(MeasureUnit::createMileScandinavian(status
));
836 measureUnit
.adoptInstead(MeasureUnit::createMillimeter(status
));
837 measureUnit
.adoptInstead(MeasureUnit::createNanometer(status
));
838 measureUnit
.adoptInstead(MeasureUnit::createNauticalMile(status
));
839 measureUnit
.adoptInstead(MeasureUnit::createParsec(status
));
840 measureUnit
.adoptInstead(MeasureUnit::createPicometer(status
));
841 measureUnit
.adoptInstead(MeasureUnit::createYard(status
));
842 measureUnit
.adoptInstead(MeasureUnit::createLux(status
));
843 measureUnit
.adoptInstead(MeasureUnit::createCarat(status
));
844 measureUnit
.adoptInstead(MeasureUnit::createGram(status
));
845 measureUnit
.adoptInstead(MeasureUnit::createKilogram(status
));
846 measureUnit
.adoptInstead(MeasureUnit::createMetricTon(status
));
847 measureUnit
.adoptInstead(MeasureUnit::createMicrogram(status
));
848 measureUnit
.adoptInstead(MeasureUnit::createMilligram(status
));
849 measureUnit
.adoptInstead(MeasureUnit::createOunce(status
));
850 measureUnit
.adoptInstead(MeasureUnit::createOunceTroy(status
));
851 measureUnit
.adoptInstead(MeasureUnit::createPound(status
));
852 measureUnit
.adoptInstead(MeasureUnit::createStone(status
));
853 measureUnit
.adoptInstead(MeasureUnit::createTon(status
));
854 measureUnit
.adoptInstead(MeasureUnit::createGigawatt(status
));
855 measureUnit
.adoptInstead(MeasureUnit::createHorsepower(status
));
856 measureUnit
.adoptInstead(MeasureUnit::createKilowatt(status
));
857 measureUnit
.adoptInstead(MeasureUnit::createMegawatt(status
));
858 measureUnit
.adoptInstead(MeasureUnit::createMilliwatt(status
));
859 measureUnit
.adoptInstead(MeasureUnit::createWatt(status
));
860 measureUnit
.adoptInstead(MeasureUnit::createHectopascal(status
));
861 measureUnit
.adoptInstead(MeasureUnit::createInchHg(status
));
862 measureUnit
.adoptInstead(MeasureUnit::createMillibar(status
));
863 measureUnit
.adoptInstead(MeasureUnit::createMillimeterOfMercury(status
));
864 measureUnit
.adoptInstead(MeasureUnit::createPoundPerSquareInch(status
));
865 measureUnit
.adoptInstead(MeasureUnit::createKilometerPerHour(status
));
866 measureUnit
.adoptInstead(MeasureUnit::createKnot(status
));
867 measureUnit
.adoptInstead(MeasureUnit::createMeterPerSecond(status
));
868 measureUnit
.adoptInstead(MeasureUnit::createMilePerHour(status
));
869 measureUnit
.adoptInstead(MeasureUnit::createCelsius(status
));
870 measureUnit
.adoptInstead(MeasureUnit::createFahrenheit(status
));
871 measureUnit
.adoptInstead(MeasureUnit::createGenericTemperature(status
));
872 measureUnit
.adoptInstead(MeasureUnit::createKelvin(status
));
873 measureUnit
.adoptInstead(MeasureUnit::createAcreFoot(status
));
874 measureUnit
.adoptInstead(MeasureUnit::createBushel(status
));
875 measureUnit
.adoptInstead(MeasureUnit::createCentiliter(status
));
876 measureUnit
.adoptInstead(MeasureUnit::createCubicCentimeter(status
));
877 measureUnit
.adoptInstead(MeasureUnit::createCubicFoot(status
));
878 measureUnit
.adoptInstead(MeasureUnit::createCubicInch(status
));
879 measureUnit
.adoptInstead(MeasureUnit::createCubicKilometer(status
));
880 measureUnit
.adoptInstead(MeasureUnit::createCubicMeter(status
));
881 measureUnit
.adoptInstead(MeasureUnit::createCubicMile(status
));
882 measureUnit
.adoptInstead(MeasureUnit::createCubicYard(status
));
883 measureUnit
.adoptInstead(MeasureUnit::createCup(status
));
884 measureUnit
.adoptInstead(MeasureUnit::createCupMetric(status
));
885 measureUnit
.adoptInstead(MeasureUnit::createDeciliter(status
));
886 measureUnit
.adoptInstead(MeasureUnit::createFluidOunce(status
));
887 measureUnit
.adoptInstead(MeasureUnit::createGallon(status
));
888 measureUnit
.adoptInstead(MeasureUnit::createGallonImperial(status
));
889 measureUnit
.adoptInstead(MeasureUnit::createHectoliter(status
));
890 measureUnit
.adoptInstead(MeasureUnit::createLiter(status
));
891 measureUnit
.adoptInstead(MeasureUnit::createMegaliter(status
));
892 measureUnit
.adoptInstead(MeasureUnit::createMilliliter(status
));
893 measureUnit
.adoptInstead(MeasureUnit::createPint(status
));
894 measureUnit
.adoptInstead(MeasureUnit::createPintMetric(status
));
895 measureUnit
.adoptInstead(MeasureUnit::createQuart(status
));
896 measureUnit
.adoptInstead(MeasureUnit::createTablespoon(status
));
897 measureUnit
.adoptInstead(MeasureUnit::createTeaspoon(status
));
898 assertSuccess("", status
);
901 void MeasureFormatTest::TestCompatible59() {
902 UErrorCode status
= U_ZERO_ERROR
;
903 LocalPointer
<MeasureUnit
> measureUnit
;
904 measureUnit
.adoptInstead(MeasureUnit::createGForce(status
));
905 measureUnit
.adoptInstead(MeasureUnit::createMeterPerSecondSquared(status
));
906 measureUnit
.adoptInstead(MeasureUnit::createArcMinute(status
));
907 measureUnit
.adoptInstead(MeasureUnit::createArcSecond(status
));
908 measureUnit
.adoptInstead(MeasureUnit::createDegree(status
));
909 measureUnit
.adoptInstead(MeasureUnit::createRadian(status
));
910 measureUnit
.adoptInstead(MeasureUnit::createRevolutionAngle(status
));
911 measureUnit
.adoptInstead(MeasureUnit::createAcre(status
));
912 measureUnit
.adoptInstead(MeasureUnit::createHectare(status
));
913 measureUnit
.adoptInstead(MeasureUnit::createSquareCentimeter(status
));
914 measureUnit
.adoptInstead(MeasureUnit::createSquareFoot(status
));
915 measureUnit
.adoptInstead(MeasureUnit::createSquareInch(status
));
916 measureUnit
.adoptInstead(MeasureUnit::createSquareKilometer(status
));
917 measureUnit
.adoptInstead(MeasureUnit::createSquareMeter(status
));
918 measureUnit
.adoptInstead(MeasureUnit::createSquareMile(status
));
919 measureUnit
.adoptInstead(MeasureUnit::createSquareYard(status
));
920 measureUnit
.adoptInstead(MeasureUnit::createKarat(status
));
921 measureUnit
.adoptInstead(MeasureUnit::createMilligramPerDeciliter(status
));
922 measureUnit
.adoptInstead(MeasureUnit::createMillimolePerLiter(status
));
923 measureUnit
.adoptInstead(MeasureUnit::createPartPerMillion(status
));
924 measureUnit
.adoptInstead(MeasureUnit::createLiterPer100Kilometers(status
));
925 measureUnit
.adoptInstead(MeasureUnit::createLiterPerKilometer(status
));
926 measureUnit
.adoptInstead(MeasureUnit::createMilePerGallon(status
));
927 measureUnit
.adoptInstead(MeasureUnit::createMilePerGallonImperial(status
));
928 measureUnit
.adoptInstead(MeasureUnit::createBit(status
));
929 measureUnit
.adoptInstead(MeasureUnit::createByte(status
));
930 measureUnit
.adoptInstead(MeasureUnit::createGigabit(status
));
931 measureUnit
.adoptInstead(MeasureUnit::createGigabyte(status
));
932 measureUnit
.adoptInstead(MeasureUnit::createKilobit(status
));
933 measureUnit
.adoptInstead(MeasureUnit::createKilobyte(status
));
934 measureUnit
.adoptInstead(MeasureUnit::createMegabit(status
));
935 measureUnit
.adoptInstead(MeasureUnit::createMegabyte(status
));
936 measureUnit
.adoptInstead(MeasureUnit::createTerabit(status
));
937 measureUnit
.adoptInstead(MeasureUnit::createTerabyte(status
));
938 measureUnit
.adoptInstead(MeasureUnit::createCentury(status
));
939 measureUnit
.adoptInstead(MeasureUnit::createDay(status
));
940 measureUnit
.adoptInstead(MeasureUnit::createHour(status
));
941 measureUnit
.adoptInstead(MeasureUnit::createMicrosecond(status
));
942 measureUnit
.adoptInstead(MeasureUnit::createMillisecond(status
));
943 measureUnit
.adoptInstead(MeasureUnit::createMinute(status
));
944 measureUnit
.adoptInstead(MeasureUnit::createMonth(status
));
945 measureUnit
.adoptInstead(MeasureUnit::createNanosecond(status
));
946 measureUnit
.adoptInstead(MeasureUnit::createSecond(status
));
947 measureUnit
.adoptInstead(MeasureUnit::createWeek(status
));
948 measureUnit
.adoptInstead(MeasureUnit::createYear(status
));
949 measureUnit
.adoptInstead(MeasureUnit::createAmpere(status
));
950 measureUnit
.adoptInstead(MeasureUnit::createMilliampere(status
));
951 measureUnit
.adoptInstead(MeasureUnit::createOhm(status
));
952 measureUnit
.adoptInstead(MeasureUnit::createVolt(status
));
953 measureUnit
.adoptInstead(MeasureUnit::createCalorie(status
));
954 measureUnit
.adoptInstead(MeasureUnit::createFoodcalorie(status
));
955 measureUnit
.adoptInstead(MeasureUnit::createJoule(status
));
956 measureUnit
.adoptInstead(MeasureUnit::createKilocalorie(status
));
957 measureUnit
.adoptInstead(MeasureUnit::createKilojoule(status
));
958 measureUnit
.adoptInstead(MeasureUnit::createKilowattHour(status
));
959 measureUnit
.adoptInstead(MeasureUnit::createGigahertz(status
));
960 measureUnit
.adoptInstead(MeasureUnit::createHertz(status
));
961 measureUnit
.adoptInstead(MeasureUnit::createKilohertz(status
));
962 measureUnit
.adoptInstead(MeasureUnit::createMegahertz(status
));
963 measureUnit
.adoptInstead(MeasureUnit::createAstronomicalUnit(status
));
964 measureUnit
.adoptInstead(MeasureUnit::createCentimeter(status
));
965 measureUnit
.adoptInstead(MeasureUnit::createDecimeter(status
));
966 measureUnit
.adoptInstead(MeasureUnit::createFathom(status
));
967 measureUnit
.adoptInstead(MeasureUnit::createFoot(status
));
968 measureUnit
.adoptInstead(MeasureUnit::createFurlong(status
));
969 measureUnit
.adoptInstead(MeasureUnit::createInch(status
));
970 measureUnit
.adoptInstead(MeasureUnit::createKilometer(status
));
971 measureUnit
.adoptInstead(MeasureUnit::createLightYear(status
));
972 measureUnit
.adoptInstead(MeasureUnit::createMeter(status
));
973 measureUnit
.adoptInstead(MeasureUnit::createMicrometer(status
));
974 measureUnit
.adoptInstead(MeasureUnit::createMile(status
));
975 measureUnit
.adoptInstead(MeasureUnit::createMileScandinavian(status
));
976 measureUnit
.adoptInstead(MeasureUnit::createMillimeter(status
));
977 measureUnit
.adoptInstead(MeasureUnit::createNanometer(status
));
978 measureUnit
.adoptInstead(MeasureUnit::createNauticalMile(status
));
979 measureUnit
.adoptInstead(MeasureUnit::createParsec(status
));
980 measureUnit
.adoptInstead(MeasureUnit::createPicometer(status
));
981 measureUnit
.adoptInstead(MeasureUnit::createPoint(status
));
982 measureUnit
.adoptInstead(MeasureUnit::createYard(status
));
983 measureUnit
.adoptInstead(MeasureUnit::createLux(status
));
984 measureUnit
.adoptInstead(MeasureUnit::createCarat(status
));
985 measureUnit
.adoptInstead(MeasureUnit::createGram(status
));
986 measureUnit
.adoptInstead(MeasureUnit::createKilogram(status
));
987 measureUnit
.adoptInstead(MeasureUnit::createMetricTon(status
));
988 measureUnit
.adoptInstead(MeasureUnit::createMicrogram(status
));
989 measureUnit
.adoptInstead(MeasureUnit::createMilligram(status
));
990 measureUnit
.adoptInstead(MeasureUnit::createOunce(status
));
991 measureUnit
.adoptInstead(MeasureUnit::createOunceTroy(status
));
992 measureUnit
.adoptInstead(MeasureUnit::createPound(status
));
993 measureUnit
.adoptInstead(MeasureUnit::createStone(status
));
994 measureUnit
.adoptInstead(MeasureUnit::createTon(status
));
995 measureUnit
.adoptInstead(MeasureUnit::createGigawatt(status
));
996 measureUnit
.adoptInstead(MeasureUnit::createHorsepower(status
));
997 measureUnit
.adoptInstead(MeasureUnit::createKilowatt(status
));
998 measureUnit
.adoptInstead(MeasureUnit::createMegawatt(status
));
999 measureUnit
.adoptInstead(MeasureUnit::createMilliwatt(status
));
1000 measureUnit
.adoptInstead(MeasureUnit::createWatt(status
));
1001 measureUnit
.adoptInstead(MeasureUnit::createHectopascal(status
));
1002 measureUnit
.adoptInstead(MeasureUnit::createInchHg(status
));
1003 measureUnit
.adoptInstead(MeasureUnit::createMillibar(status
));
1004 measureUnit
.adoptInstead(MeasureUnit::createMillimeterOfMercury(status
));
1005 measureUnit
.adoptInstead(MeasureUnit::createPoundPerSquareInch(status
));
1006 measureUnit
.adoptInstead(MeasureUnit::createKilometerPerHour(status
));
1007 measureUnit
.adoptInstead(MeasureUnit::createKnot(status
));
1008 measureUnit
.adoptInstead(MeasureUnit::createMeterPerSecond(status
));
1009 measureUnit
.adoptInstead(MeasureUnit::createMilePerHour(status
));
1010 measureUnit
.adoptInstead(MeasureUnit::createCelsius(status
));
1011 measureUnit
.adoptInstead(MeasureUnit::createFahrenheit(status
));
1012 measureUnit
.adoptInstead(MeasureUnit::createGenericTemperature(status
));
1013 measureUnit
.adoptInstead(MeasureUnit::createKelvin(status
));
1014 measureUnit
.adoptInstead(MeasureUnit::createAcreFoot(status
));
1015 measureUnit
.adoptInstead(MeasureUnit::createBushel(status
));
1016 measureUnit
.adoptInstead(MeasureUnit::createCentiliter(status
));
1017 measureUnit
.adoptInstead(MeasureUnit::createCubicCentimeter(status
));
1018 measureUnit
.adoptInstead(MeasureUnit::createCubicFoot(status
));
1019 measureUnit
.adoptInstead(MeasureUnit::createCubicInch(status
));
1020 measureUnit
.adoptInstead(MeasureUnit::createCubicKilometer(status
));
1021 measureUnit
.adoptInstead(MeasureUnit::createCubicMeter(status
));
1022 measureUnit
.adoptInstead(MeasureUnit::createCubicMile(status
));
1023 measureUnit
.adoptInstead(MeasureUnit::createCubicYard(status
));
1024 measureUnit
.adoptInstead(MeasureUnit::createCup(status
));
1025 measureUnit
.adoptInstead(MeasureUnit::createCupMetric(status
));
1026 measureUnit
.adoptInstead(MeasureUnit::createDeciliter(status
));
1027 measureUnit
.adoptInstead(MeasureUnit::createFluidOunce(status
));
1028 measureUnit
.adoptInstead(MeasureUnit::createGallon(status
));
1029 measureUnit
.adoptInstead(MeasureUnit::createGallonImperial(status
));
1030 measureUnit
.adoptInstead(MeasureUnit::createHectoliter(status
));
1031 measureUnit
.adoptInstead(MeasureUnit::createLiter(status
));
1032 measureUnit
.adoptInstead(MeasureUnit::createMegaliter(status
));
1033 measureUnit
.adoptInstead(MeasureUnit::createMilliliter(status
));
1034 measureUnit
.adoptInstead(MeasureUnit::createPint(status
));
1035 measureUnit
.adoptInstead(MeasureUnit::createPintMetric(status
));
1036 measureUnit
.adoptInstead(MeasureUnit::createQuart(status
));
1037 measureUnit
.adoptInstead(MeasureUnit::createTablespoon(status
));
1038 measureUnit
.adoptInstead(MeasureUnit::createTeaspoon(status
));
1039 assertSuccess("", status
);
1042 // Note that TestCompatible60(), TestCompatible61(), TestCompatible62()
1043 // would be the same as TestCompatible59(), no need to add them.
1045 void MeasureFormatTest::TestBasic() {
1046 UErrorCode status
= U_ZERO_ERROR
;
1047 MeasureUnit
*ptr1
= MeasureUnit::createArcMinute(status
);
1048 MeasureUnit
*ptr2
= MeasureUnit::createArcMinute(status
);
1049 if (!(*ptr1
== *ptr2
)) {
1050 errln("Expect == to work.");
1052 if (*ptr1
!= *ptr2
) {
1053 errln("Expect != to work.");
1055 MeasureUnit
*ptr3
= MeasureUnit::createMeter(status
);
1056 if (*ptr1
== *ptr3
) {
1057 errln("Expect == to work.");
1059 if (!(*ptr1
!= *ptr3
)) {
1060 errln("Expect != to work.");
1062 MeasureUnit
*ptr4
= (MeasureUnit
*) ptr1
->clone();
1063 if (*ptr1
!= *ptr4
) {
1064 errln("Expect clone to work.");
1068 if (*ptr1
!= stack
) {
1069 errln("Expect assignment to work.");
1078 void MeasureFormatTest::TestGetAvailable() {
1079 MeasureUnit
*units
= NULL
;
1080 UErrorCode status
= U_ZERO_ERROR
;
1081 int32_t totalCount
= MeasureUnit::getAvailable(units
, 0, status
);
1082 while (status
== U_BUFFER_OVERFLOW_ERROR
) {
1083 status
= U_ZERO_ERROR
;
1085 units
= new MeasureUnit
[totalCount
];
1086 totalCount
= MeasureUnit::getAvailable(units
, totalCount
, status
);
1088 if (U_FAILURE(status
)) {
1089 dataerrln("Failure creating format object - %s", u_errorName(status
));
1093 if (totalCount
< 200) {
1094 errln("Expect at least 200 measure units including currencies.");
1097 StringEnumeration
*types
= MeasureUnit::getAvailableTypes(status
);
1098 if (U_FAILURE(status
)) {
1099 dataerrln("Failure getting types - %s", u_errorName(status
));
1103 if (types
->count(status
) < 10) {
1104 errln("Expect at least 10 distinct unit types.");
1107 int32_t unitCapacity
= 0;
1108 int32_t unitCountSum
= 0;
1110 const char* type
= types
->next(NULL
, status
);
1112 type
= types
->next(NULL
, status
)) {
1113 int32_t unitCount
= MeasureUnit::getAvailable(type
, units
, unitCapacity
, status
);
1114 while (status
== U_BUFFER_OVERFLOW_ERROR
) {
1115 status
= U_ZERO_ERROR
;
1117 units
= new MeasureUnit
[unitCount
];
1118 unitCapacity
= unitCount
;
1119 unitCount
= MeasureUnit::getAvailable(type
, units
, unitCapacity
, status
);
1121 if (U_FAILURE(status
)) {
1122 dataerrln("Failure getting units - %s", u_errorName(status
));
1127 if (unitCount
< 1) {
1128 errln("Expect at least one unit count per type.");
1130 unitCountSum
+= unitCount
;
1132 if (unitCountSum
!= totalCount
) {
1133 errln("Expected total unit count to equal sum of unit counts by type.");
1139 void MeasureFormatTest::TestExamplesInDocs() {
1140 UErrorCode status
= U_ZERO_ERROR
;
1141 MeasureFormat
fmtFr(Locale::getFrench(), UMEASFMT_WIDTH_SHORT
, status
);
1142 MeasureFormat
fmtFrFull(
1143 Locale::getFrench(), UMEASFMT_WIDTH_WIDE
, status
);
1144 MeasureFormat
fmtFrNarrow(
1145 Locale::getFrench(), UMEASFMT_WIDTH_NARROW
, status
);
1146 MeasureFormat
fmtEn(Locale::getUS(), UMEASFMT_WIDTH_WIDE
, status
);
1147 if (!assertSuccess("Error creating formatters", status
)) {
1150 Measure
measureC((double)23, MeasureUnit::createCelsius(status
), status
);
1151 Measure
measureF((double)70, MeasureUnit::createFahrenheit(status
), status
);
1152 Measure feetAndInches
[] = {
1153 Measure((double)70, MeasureUnit::createFoot(status
), status
),
1154 Measure((double)5.3, MeasureUnit::createInch(status
), status
)};
1155 Measure footAndInch
[] = {
1156 Measure((double)1, MeasureUnit::createFoot(status
), status
),
1157 Measure((double)1, MeasureUnit::createInch(status
), status
)};
1158 Measure inchAndFeet
[] = {
1159 Measure((double)1, MeasureUnit::createInch(status
), status
),
1160 Measure((double)2, MeasureUnit::createFoot(status
), status
)};
1161 if (!assertSuccess("Error creating measurements.", status
)) {
1170 verifyFormatWithPrefix(
1176 "Prefix: 23 \\u00B0C");
1187 UPRV_LENGTHOF(feetAndInches
),
1188 "70 pieds et 5,3 pouces");
1189 verifyFormatWithPrefix(
1194 UPRV_LENGTHOF(feetAndInches
),
1195 "Prefix: 70 pieds et 5,3 pouces");
1200 UPRV_LENGTHOF(footAndInch
),
1201 "1 pied et 1 pouce");
1203 "Foot and inch narrow",
1206 UPRV_LENGTHOF(footAndInch
),
1207 "1\\u2032 1\\u2033");
1212 UPRV_LENGTHOF(inchAndFeet
),
1216 void MeasureFormatTest::TestFormatPeriodEn() {
1217 UErrorCode status
= U_ZERO_ERROR
;
1218 Measure t_19m
[] = {Measure((double)19, MeasureUnit::createMinute(status
), status
)};
1219 Measure t_1h_23_5s
[] = {
1220 Measure((double)1.0, MeasureUnit::createHour(status
), status
),
1221 Measure((double)23.5, MeasureUnit::createSecond(status
), status
)
1223 Measure t_1h_23_5m
[] = {
1224 Measure((double)1.0, MeasureUnit::createHour(status
), status
),
1225 Measure((double)23.5, MeasureUnit::createMinute(status
), status
)
1227 Measure t_1h_0m_23s
[] = {
1230 TimeUnit::createInstance(
1231 TimeUnit::UTIMEUNIT_HOUR
, status
),
1235 TimeUnit::createInstance(
1236 TimeUnit::UTIMEUNIT_MINUTE
, status
),
1240 TimeUnit::createInstance(
1241 TimeUnit::UTIMEUNIT_SECOND
, status
),
1244 Measure t_2y_5M_3w_4d
[] = {
1245 Measure(2.0, MeasureUnit::createYear(status
), status
),
1246 Measure(5.0, MeasureUnit::createMonth(status
), status
),
1247 Measure(3.0, MeasureUnit::createWeek(status
), status
),
1248 Measure(4.0, MeasureUnit::createDay(status
), status
)
1250 Measure t_1m_59_9996s
[] = {
1251 Measure(1.0, MeasureUnit::createMinute(status
), status
),
1252 Measure(59.9996, MeasureUnit::createSecond(status
), status
)
1254 Measure t_5h_17m
[] = {
1255 Measure(5.0, MeasureUnit::createHour(status
), status
),
1256 Measure(17.0, MeasureUnit::createMinute(status
), status
)
1258 Measure t_neg5h_17m
[] = {
1259 Measure(-5.0, MeasureUnit::createHour(status
), status
),
1260 Measure(17.0, MeasureUnit::createMinute(status
), status
)
1262 Measure t_19m_28s
[] = {
1263 Measure(19.0, MeasureUnit::createMinute(status
), status
),
1264 Measure(28.0, MeasureUnit::createSecond(status
), status
)
1266 Measure t_0h_0m_9s
[] = {
1267 Measure(0.0, MeasureUnit::createHour(status
), status
),
1268 Measure(0.0, MeasureUnit::createMinute(status
), status
),
1269 Measure(9.0, MeasureUnit::createSecond(status
), status
)
1271 Measure t_0h_0m_17s
[] = {
1272 Measure(0.0, MeasureUnit::createHour(status
), status
),
1273 Measure(0.0, MeasureUnit::createMinute(status
), status
),
1274 Measure(17.0, MeasureUnit::createSecond(status
), status
)
1276 Measure t_6h_56_92m
[] = {
1277 Measure(6.0, MeasureUnit::createHour(status
), status
),
1278 Measure(56.92, MeasureUnit::createMinute(status
), status
)
1280 Measure t_3h_4s_5m
[] = {
1281 Measure(3.0, MeasureUnit::createHour(status
), status
),
1282 Measure(4.0, MeasureUnit::createSecond(status
), status
),
1283 Measure(5.0, MeasureUnit::createMinute(status
), status
)
1285 Measure t_6_7h_56_92m
[] = {
1286 Measure(6.7, MeasureUnit::createHour(status
), status
),
1287 Measure(56.92, MeasureUnit::createMinute(status
), status
)
1290 Measure t_3h_5h
[] = {
1291 Measure(3.0, MeasureUnit::createHour(status
), status
),
1292 Measure(5.0, MeasureUnit::createHour(status
), status
)
1295 if (!assertSuccess("Error creating Measure objects", status
)) {
1299 ExpectedResult fullData
[] = {
1300 {t_1m_59_9996s
, UPRV_LENGTHOF(t_1m_59_9996s
), "1 minute, 59.9996 seconds"},
1301 {t_19m
, UPRV_LENGTHOF(t_19m
), "19 minutes"},
1302 {t_1h_23_5s
, UPRV_LENGTHOF(t_1h_23_5s
), "1 hour, 23.5 seconds"},
1303 {t_1h_23_5m
, UPRV_LENGTHOF(t_1h_23_5m
), "1 hour, 23.5 minutes"},
1304 {t_1h_0m_23s
, UPRV_LENGTHOF(t_1h_0m_23s
), "1 hour, 0 minutes, 23 seconds"},
1305 {t_2y_5M_3w_4d
, UPRV_LENGTHOF(t_2y_5M_3w_4d
), "2 years, 5 months, 3 weeks, 4 days"}};
1307 ExpectedResult abbrevData
[] = {
1308 {t_1m_59_9996s
, UPRV_LENGTHOF(t_1m_59_9996s
), "1 min, 59.9996 sec"},
1309 {t_19m
, UPRV_LENGTHOF(t_19m
), "19 min"},
1310 {t_1h_23_5s
, UPRV_LENGTHOF(t_1h_23_5s
), "1 hr, 23.5 sec"},
1311 {t_1h_23_5m
, UPRV_LENGTHOF(t_1h_23_5m
), "1 hr, 23.5 min"},
1312 {t_1h_0m_23s
, UPRV_LENGTHOF(t_1h_0m_23s
), "1 hr, 0 min, 23 sec"},
1313 {t_2y_5M_3w_4d
, UPRV_LENGTHOF(t_2y_5M_3w_4d
), "2 yrs, 5 mths, 3 wks, 4 days"}};
1315 ExpectedResult narrowData
[] = {
1316 {t_1m_59_9996s
, UPRV_LENGTHOF(t_1m_59_9996s
), "1m 59.9996s"},
1317 {t_19m
, UPRV_LENGTHOF(t_19m
), "19m"},
1318 {t_1h_23_5s
, UPRV_LENGTHOF(t_1h_23_5s
), "1h 23.5s"},
1319 {t_1h_23_5m
, UPRV_LENGTHOF(t_1h_23_5m
), "1h 23.5m"},
1320 {t_1h_0m_23s
, UPRV_LENGTHOF(t_1h_0m_23s
), "1h 0m 23s"},
1321 {t_2y_5M_3w_4d
, UPRV_LENGTHOF(t_2y_5M_3w_4d
), "2y 5mo 3w 4d"}};
1323 ExpectedResult numericData
[] = {
1324 {t_1m_59_9996s
, UPRV_LENGTHOF(t_1m_59_9996s
), "1:59.9996"},
1325 {t_19m
, UPRV_LENGTHOF(t_19m
), "19m"},
1326 {t_1h_23_5s
, UPRV_LENGTHOF(t_1h_23_5s
), "1:00:23.5"},
1327 {t_1h_23_5m
, UPRV_LENGTHOF(t_1h_23_5m
), "1:23.5"},
1328 {t_1h_0m_23s
, UPRV_LENGTHOF(t_1h_0m_23s
), "1:00:23"},
1329 {t_5h_17m
, UPRV_LENGTHOF(t_5h_17m
), "5:17"},
1330 {t_neg5h_17m
, UPRV_LENGTHOF(t_neg5h_17m
), "-5h 17m"},
1331 {t_19m_28s
, UPRV_LENGTHOF(t_19m_28s
), "19:28"},
1332 {t_2y_5M_3w_4d
, UPRV_LENGTHOF(t_2y_5M_3w_4d
), "2y 5mo 3w 4d"},
1333 {t_0h_0m_9s
, UPRV_LENGTHOF(t_0h_0m_9s
), "0:00:09"},
1334 {t_6h_56_92m
, UPRV_LENGTHOF(t_6h_56_92m
), "6:56.92"},
1335 {t_6_7h_56_92m
, UPRV_LENGTHOF(t_6_7h_56_92m
), "6:56.92"},
1336 {t_3h_4s_5m
, UPRV_LENGTHOF(t_3h_4s_5m
), "3h 4s 5m"},
1337 {t_3h_5h
, UPRV_LENGTHOF(t_3h_5h
), "3h 5h"}};
1339 ExpectedResult fullDataDe
[] = {
1340 {t_1m_59_9996s
, UPRV_LENGTHOF(t_1m_59_9996s
), "1 Minute und 59,9996 Sekunden"},
1341 {t_19m
, UPRV_LENGTHOF(t_19m
), "19 Minuten"},
1342 {t_1h_23_5s
, UPRV_LENGTHOF(t_1h_23_5s
), "1 Stunde und 23,5 Sekunden"},
1343 {t_1h_23_5m
, UPRV_LENGTHOF(t_1h_23_5m
), "1 Stunde und 23,5 Minuten"},
1344 {t_1h_0m_23s
, UPRV_LENGTHOF(t_1h_0m_23s
), "1 Stunde, 0 Minuten und 23 Sekunden"},
1345 {t_2y_5M_3w_4d
, UPRV_LENGTHOF(t_2y_5M_3w_4d
), "2 Jahre, 5 Monate, 3 Wochen und 4 Tage"}};
1347 ExpectedResult numericDataDe
[] = {
1348 {t_1m_59_9996s
, UPRV_LENGTHOF(t_1m_59_9996s
), "1:59,9996"},
1349 {t_19m
, UPRV_LENGTHOF(t_19m
), "19min"},
1350 {t_1h_23_5s
, UPRV_LENGTHOF(t_1h_23_5s
), "1:00:23,5"},
1351 {t_1h_23_5m
, UPRV_LENGTHOF(t_1h_23_5m
), "1:23,5"},
1352 {t_1h_0m_23s
, UPRV_LENGTHOF(t_1h_0m_23s
), "1:00:23"},
1353 {t_5h_17m
, UPRV_LENGTHOF(t_5h_17m
), "5:17"},
1354 {t_19m_28s
, UPRV_LENGTHOF(t_19m_28s
), "19:28"},
1355 {t_2y_5M_3w_4d
, UPRV_LENGTHOF(t_2y_5M_3w_4d
), "2J 5M 3W 4d"},
1356 {t_0h_0m_17s
, UPRV_LENGTHOF(t_0h_0m_17s
), "0:00:17"},
1357 {t_6h_56_92m
, UPRV_LENGTHOF(t_6h_56_92m
), "6:56,92"},
1358 {t_3h_5h
, UPRV_LENGTHOF(t_3h_5h
), "3h 5h"}};
1360 Locale
en(Locale::getEnglish());
1361 LocalPointer
<NumberFormat
> nf(NumberFormat::createInstance(en
, status
));
1362 if (U_FAILURE(status
)) {
1363 dataerrln("Error creating number format en object - %s", u_errorName(status
));
1366 nf
->setMaximumFractionDigits(4);
1367 MeasureFormat
mf(en
, UMEASFMT_WIDTH_WIDE
, (NumberFormat
*) nf
->clone(), status
);
1368 if (!assertSuccess("Error creating measure format en WIDE", status
)) {
1371 verifyFormat("en WIDE", mf
, fullData
, UPRV_LENGTHOF(fullData
));
1373 // exercise copy constructor
1375 MeasureFormat
mf2(mf
);
1376 verifyFormat("en WIDE copy", mf2
, fullData
, UPRV_LENGTHOF(fullData
));
1380 MeasureFormat
*mf3
= (MeasureFormat
*) mf
.clone();
1381 verifyFormat("en WIDE copy", *mf3
, fullData
, UPRV_LENGTHOF(fullData
));
1384 mf
= MeasureFormat(en
, UMEASFMT_WIDTH_SHORT
, (NumberFormat
*) nf
->clone(), status
);
1385 if (!assertSuccess("Error creating measure format en SHORT", status
)) {
1388 verifyFormat("en SHORT", mf
, abbrevData
, UPRV_LENGTHOF(abbrevData
));
1389 mf
= MeasureFormat(en
, UMEASFMT_WIDTH_NARROW
, (NumberFormat
*) nf
->clone(), status
);
1390 if (!assertSuccess("Error creating measure format en NARROW", status
)) {
1393 verifyFormat("en NARROW", mf
, narrowData
, UPRV_LENGTHOF(narrowData
));
1394 mf
= MeasureFormat(en
, UMEASFMT_WIDTH_NUMERIC
, (NumberFormat
*) nf
->clone(), status
);
1395 if (!assertSuccess("Error creating measure format en NUMERIC", status
)) {
1398 verifyFormat("en NUMERIC", mf
, numericData
, UPRV_LENGTHOF(numericData
));
1400 Locale
de(Locale::getGerman());
1401 nf
.adoptInstead(NumberFormat::createInstance(de
, status
));
1402 if (!assertSuccess("Error creating number format de object", status
)) {
1405 nf
->setMaximumFractionDigits(4);
1406 mf
= MeasureFormat(de
, UMEASFMT_WIDTH_WIDE
, (NumberFormat
*) nf
->clone(), status
);
1407 if (!assertSuccess("Error creating measure format de WIDE", status
)) {
1410 verifyFormat("de WIDE", mf
, fullDataDe
, UPRV_LENGTHOF(fullDataDe
));
1411 mf
= MeasureFormat(de
, UMEASFMT_WIDTH_NUMERIC
, (NumberFormat
*) nf
->clone(), status
);
1412 if (!assertSuccess("Error creating measure format de NUMERIC", status
)) {
1415 verifyFormat("de NUMERIC", mf
, numericDataDe
, UPRV_LENGTHOF(numericDataDe
));
1418 void MeasureFormatTest::Test10219FractionalPlurals() {
1419 Locale
en(Locale::getEnglish());
1420 double values
[] = {1.588, 1.011};
1421 const char *expected
[2][3] = {
1422 {"1 minute", "1.5 minutes", "1.58 minutes"},
1423 {"1 minute", "1.0 minutes", "1.01 minutes"}
1425 UErrorCode status
= U_ZERO_ERROR
;
1426 for (int j
= 0; j
< UPRV_LENGTHOF(values
); j
++) {
1427 for (int i
= 0; i
< UPRV_LENGTHOF(expected
[j
]); i
++) {
1429 (DecimalFormat
*) NumberFormat::createInstance(en
, status
);
1430 if (U_FAILURE(status
)) {
1431 dataerrln("Error creating Number format - %s", u_errorName(status
));
1434 df
->setRoundingMode(DecimalFormat::kRoundDown
);
1435 df
->setMinimumFractionDigits(i
);
1436 df
->setMaximumFractionDigits(i
);
1437 MeasureFormat
mf(en
, UMEASFMT_WIDTH_WIDE
, df
, status
);
1438 if (!assertSuccess("Error creating Measure format", status
)) {
1441 Measure
measure(values
[j
], MeasureUnit::createMinute(status
), status
);
1442 if (!assertSuccess("Error creating Measure unit", status
)) {
1445 verifyFormat("Test10219", mf
, &measure
, 1, expected
[j
][i
]);
1450 static MeasureUnit
toMeasureUnit(MeasureUnit
*adopted
) {
1451 MeasureUnit
result(*adopted
);
1456 void MeasureFormatTest::TestGreek() {
1457 Locale locales
[] = {Locale("el_GR"), Locale("el")};
1458 UErrorCode status
= U_ZERO_ERROR
;
1459 MeasureUnit units
[] = {
1460 toMeasureUnit(MeasureUnit::createSecond(status
)),
1461 toMeasureUnit(MeasureUnit::createMinute(status
)),
1462 toMeasureUnit(MeasureUnit::createHour(status
)),
1463 toMeasureUnit(MeasureUnit::createDay(status
)),
1464 toMeasureUnit(MeasureUnit::createWeek(status
)),
1465 toMeasureUnit(MeasureUnit::createMonth(status
)),
1466 toMeasureUnit(MeasureUnit::createYear(status
))};
1467 if (!assertSuccess("Error creating Measure units", status
)) {
1470 UMeasureFormatWidth styles
[] = {
1471 UMEASFMT_WIDTH_WIDE
,
1472 UMEASFMT_WIDTH_SHORT
};
1473 int32_t numbers
[] = {1, 7};
1474 const char *expected
[] = {
1476 "1 \\u03B4\\u03B5\\u03C5\\u03C4\\u03B5\\u03C1\\u03CC\\u03BB\\u03B5\\u03C0\\u03C4\\u03BF",
1477 "1 \\u03BB\\u03B5\\u03C0\\u03C4\\u03CC",
1478 "1 \\u03CE\\u03C1\\u03B1",
1479 "1 \\u03B7\\u03BC\\u03AD\\u03C1\\u03B1",
1480 "1 \\u03B5\\u03B2\\u03B4\\u03BF\\u03BC\\u03AC\\u03B4\\u03B1",
1481 "1 \\u03BC\\u03AE\\u03BD\\u03B1\\u03C2",
1482 "1 \\u03AD\\u03C4\\u03BF\\u03C2",
1484 "1 \\u03B4\\u03B5\\u03C5\\u03C4.",
1485 "1 \\u03BB\\u03B5\\u03C0.",
1486 "1 \\u03CE\\u03C1\\u03B1",
1487 "1 \\u03B7\\u03BC\\u03AD\\u03C1\\u03B1",
1488 "1 \\u03B5\\u03B2\\u03B4.",
1489 "1 \\u03BC\\u03AE\\u03BD.",
1490 "1 \\u03AD\\u03C4.", // year (one)
1492 "7 \\u03B4\\u03B5\\u03C5\\u03C4\\u03B5\\u03C1\\u03CC\\u03BB\\u03B5\\u03C0\\u03C4\\u03B1",
1493 "7 \\u03BB\\u03B5\\u03C0\\u03C4\\u03AC",
1494 "7 \\u03CE\\u03C1\\u03B5\\u03C2",
1495 "7 \\u03B7\\u03BC\\u03AD\\u03C1\\u03B5\\u03C2",
1496 "7 \\u03B5\\u03B2\\u03B4\\u03BF\\u03BC\\u03AC\\u03B4\\u03B5\\u03C2",
1497 "7 \\u03BC\\u03AE\\u03BD\\u03B5\\u03C2",
1498 "7 \\u03AD\\u03C4\\u03B7",
1500 "7 \\u03B4\\u03B5\\u03C5\\u03C4.",
1501 "7 \\u03BB\\u03B5\\u03C0.",
1502 "7 \\u03CE\\u03C1.", // hour (other)
1503 "7 \\u03B7\\u03BC\\u03AD\\u03C1\\u03B5\\u03C2",
1504 "7 \\u03B5\\u03B2\\u03B4.",
1505 "7 \\u03BC\\u03AE\\u03BD.",
1506 "7 \\u03AD\\u03C4.", // year (other)
1509 "1 \\u03B4\\u03B5\\u03C5\\u03C4\\u03B5\\u03C1\\u03CC\\u03BB\\u03B5\\u03C0\\u03C4\\u03BF",
1510 "1 \\u03BB\\u03B5\\u03C0\\u03C4\\u03CC",
1511 "1 \\u03CE\\u03C1\\u03B1",
1512 "1 \\u03B7\\u03BC\\u03AD\\u03C1\\u03B1",
1513 "1 \\u03B5\\u03B2\\u03B4\\u03BF\\u03BC\\u03AC\\u03B4\\u03B1",
1514 "1 \\u03BC\\u03AE\\u03BD\\u03B1\\u03C2",
1515 "1 \\u03AD\\u03C4\\u03BF\\u03C2",
1517 "1 \\u03B4\\u03B5\\u03C5\\u03C4.",
1518 "1 \\u03BB\\u03B5\\u03C0.",
1519 "1 \\u03CE\\u03C1\\u03B1",
1520 "1 \\u03B7\\u03BC\\u03AD\\u03C1\\u03B1",
1521 "1 \\u03B5\\u03B2\\u03B4.",
1522 "1 \\u03BC\\u03AE\\u03BD.",
1523 "1 \\u03AD\\u03C4.", // year (one)
1525 "7 \\u03B4\\u03B5\\u03C5\\u03C4\\u03B5\\u03C1\\u03CC\\u03BB\\u03B5\\u03C0\\u03C4\\u03B1",
1526 "7 \\u03BB\\u03B5\\u03C0\\u03C4\\u03AC",
1527 "7 \\u03CE\\u03C1\\u03B5\\u03C2",
1528 "7 \\u03B7\\u03BC\\u03AD\\u03C1\\u03B5\\u03C2",
1529 "7 \\u03B5\\u03B2\\u03B4\\u03BF\\u03BC\\u03AC\\u03B4\\u03B5\\u03C2",
1530 "7 \\u03BC\\u03AE\\u03BD\\u03B5\\u03C2",
1531 "7 \\u03AD\\u03C4\\u03B7",
1533 "7 \\u03B4\\u03B5\\u03C5\\u03C4.",
1534 "7 \\u03BB\\u03B5\\u03C0.",
1535 "7 \\u03CE\\u03C1.", // hour (other)
1536 "7 \\u03B7\\u03BC\\u03AD\\u03C1\\u03B5\\u03C2",
1537 "7 \\u03B5\\u03B2\\u03B4.",
1538 "7 \\u03BC\\u03AE\\u03BD.",
1539 "7 \\u03AD\\u03C4."}; // year (other)
1541 int32_t counter
= 0;
1542 for (int32_t locIndex
= 0; locIndex
< UPRV_LENGTHOF(locales
); ++locIndex
) {
1543 for( int32_t numIndex
= 0; numIndex
< UPRV_LENGTHOF(numbers
); ++numIndex
) {
1544 for ( int32_t styleIndex
= 0; styleIndex
< UPRV_LENGTHOF(styles
); ++styleIndex
) {
1545 for ( int32_t unitIndex
= 0; unitIndex
< UPRV_LENGTHOF(units
); ++unitIndex
) {
1546 Measure
measure(numbers
[numIndex
], new MeasureUnit(units
[unitIndex
]), status
);
1547 if (!assertSuccess("Error creating Measure", status
)) {
1550 MeasureFormat
fmt(locales
[locIndex
], styles
[styleIndex
], status
);
1551 if (!assertSuccess("Error creating Measure format", status
)) {
1554 verifyFormat("TestGreek", fmt
, &measure
, 1, expected
[counter
]);
1562 void MeasureFormatTest::TestFormatSingleArg() {
1563 UErrorCode status
= U_ZERO_ERROR
;
1564 MeasureFormat
fmt("en", UMEASFMT_WIDTH_WIDE
, status
);
1565 if (!assertSuccess("Error creating formatter", status
)) {
1568 UnicodeString buffer
;
1569 FieldPosition
pos(FieldPosition::DONT_CARE
);
1571 new Measure(3.5, MeasureUnit::createFoot(status
), status
),
1575 if (!assertSuccess("Error formatting", status
)) {
1579 "TestFormatSingleArg",
1580 UnicodeString("3.5 feet"),
1584 void MeasureFormatTest::TestFormatMeasuresZeroArg() {
1585 UErrorCode status
= U_ZERO_ERROR
;
1586 MeasureFormat
fmt("en", UMEASFMT_WIDTH_WIDE
, status
);
1587 verifyFormat("TestFormatMeasuresZeroArg", fmt
, NULL
, 0, "");
1590 void MeasureFormatTest::TestSimplePer() {
1592 UErrorCode status
= U_ZERO_ERROR
;
1593 LocalPointer
<MeasureUnit
> second(MeasureUnit::createSecond(status
));
1594 LocalPointer
<MeasureUnit
> minute(MeasureUnit::createMinute(status
));
1595 LocalPointer
<MeasureUnit
> pound(MeasureUnit::createPound(status
));
1596 if (!assertSuccess("", status
)) {
1600 helperTestSimplePer(
1601 en
, UMEASFMT_WIDTH_WIDE
,
1602 1.0, *pound
, *second
, "1 pound per second");
1603 helperTestSimplePer(
1604 en
, UMEASFMT_WIDTH_WIDE
,
1605 2.0, *pound
, *second
, "2 pounds per second");
1606 helperTestSimplePer(
1607 en
, UMEASFMT_WIDTH_WIDE
,
1608 1.0, *pound
, *minute
, "1 pound per minute");
1609 helperTestSimplePer(
1610 en
, UMEASFMT_WIDTH_WIDE
,
1611 2.0, *pound
, *minute
, "2 pounds per minute");
1613 helperTestSimplePer(
1614 en
, UMEASFMT_WIDTH_SHORT
, 1.0, *pound
, *second
, "1 lb/s");
1615 helperTestSimplePer(
1616 en
, UMEASFMT_WIDTH_SHORT
, 2.0, *pound
, *second
, "2 lb/s");
1617 helperTestSimplePer(
1618 en
, UMEASFMT_WIDTH_SHORT
, 1.0, *pound
, *minute
, "1 lb/min");
1619 helperTestSimplePer(
1620 en
, UMEASFMT_WIDTH_SHORT
, 2.0, *pound
, *minute
, "2 lb/min");
1622 helperTestSimplePer(
1623 en
, UMEASFMT_WIDTH_NARROW
, 1.0, *pound
, *second
, "1#/s");
1624 helperTestSimplePer(
1625 en
, UMEASFMT_WIDTH_NARROW
, 2.0, *pound
, *second
, "2#/s");
1626 helperTestSimplePer(
1627 en
, UMEASFMT_WIDTH_NARROW
, 1.0, *pound
, *minute
, "1#/min");
1628 helperTestSimplePer(
1629 en
, UMEASFMT_WIDTH_NARROW
, 2.0, *pound
, *minute
, "2#/min");
1631 helperTestSimplePer(
1632 en
, UMEASFMT_WIDTH_SHORT
,
1633 23.3, *pound
, *second
, "23.3 lb/s",
1634 NumberFormat::kDecimalSeparatorField
,
1637 helperTestSimplePer(
1638 en
, UMEASFMT_WIDTH_SHORT
,
1639 23.3, *pound
, *second
, "23.3 lb/s",
1640 NumberFormat::kIntegerField
,
1643 helperTestSimplePer(
1644 en
, UMEASFMT_WIDTH_SHORT
,
1645 23.3, *pound
, *minute
, "23.3 lb/min",
1646 NumberFormat::kDecimalSeparatorField
,
1649 helperTestSimplePer(
1650 en
, UMEASFMT_WIDTH_SHORT
,
1651 23.3, *pound
, *minute
, "23.3 lb/min",
1652 NumberFormat::kIntegerField
,
1656 void MeasureFormatTest::TestNumeratorPlurals() {
1658 UErrorCode status
= U_ZERO_ERROR
;
1659 LocalPointer
<MeasureUnit
> second(MeasureUnit::createSecond(status
));
1660 LocalPointer
<MeasureUnit
> foot(MeasureUnit::createFoot(status
));
1661 if (!assertSuccess("", status
)) {
1665 helperTestSimplePer(
1667 UMEASFMT_WIDTH_WIDE
,
1668 1.0, *foot
, *second
, "1 stopa na sekund\\u0119");
1669 helperTestSimplePer(
1671 UMEASFMT_WIDTH_WIDE
,
1672 2.0, *foot
, *second
, "2 stopy na sekund\\u0119");
1673 helperTestSimplePer(
1675 UMEASFMT_WIDTH_WIDE
,
1676 5.0, *foot
, *second
, "5 st\\u00f3p na sekund\\u0119");
1677 helperTestSimplePer(
1678 pl
, UMEASFMT_WIDTH_WIDE
,
1679 1.5, *foot
, *second
, "1,5 stopy na sekund\\u0119");
1682 void MeasureFormatTest::helperTestSimplePer(
1683 const Locale
&locale
,
1684 UMeasureFormatWidth width
,
1686 const MeasureUnit
&unit
,
1687 const MeasureUnit
&perUnit
,
1688 const char *expected
) {
1689 helperTestSimplePer(
1696 FieldPosition::DONT_CARE
,
1701 void MeasureFormatTest::helperTestSimplePer(
1702 const Locale
&locale
,
1703 UMeasureFormatWidth width
,
1705 const MeasureUnit
&unit
,
1706 const MeasureUnit
&perUnit
,
1707 const char *expected
,
1709 int32_t expected_start
,
1710 int32_t expected_end
) {
1711 UErrorCode status
= U_ZERO_ERROR
;
1712 FieldPosition
pos(field
);
1713 MeasureFormat
fmt(locale
, width
, status
);
1714 if (!assertSuccess("Error creating format object", status
)) {
1717 Measure
measure(value
, (MeasureUnit
*) unit
.clone(), status
);
1718 if (!assertSuccess("Error creating measure object", status
)) {
1721 UnicodeString
prefix("prefix: ");
1722 UnicodeString
buffer(prefix
);
1723 fmt
.formatMeasurePerUnit(
1729 if (!assertSuccess("Error formatting measures with per", status
)) {
1732 UnicodeString
uexpected(expected
);
1733 uexpected
= prefix
+ uexpected
;
1736 uexpected
.unescape(),
1738 if (field
!= FieldPosition::DONT_CARE
) {
1740 "Start", expected_start
, pos
.getBeginIndex() - prefix
.length());
1742 "End", expected_end
, pos
.getEndIndex() - prefix
.length());
1746 void MeasureFormatTest::TestMultiples() {
1749 helperTestMultiples(en
, UMEASFMT_WIDTH_WIDE
, "2 miles, 1 foot, 2.3 inches");
1750 helperTestMultiples(en
, UMEASFMT_WIDTH_SHORT
, "2 mi, 1 ft, 2.3 in");
1751 helperTestMultiples(en
, UMEASFMT_WIDTH_NARROW
, "2mi 1\\u2032 2.3\\u2033");
1752 helperTestMultiples(ru
, UMEASFMT_WIDTH_WIDE
, "2 \\u043C\\u0438\\u043B\\u0438, 1 \\u0444\\u0443\\u0442, 2,3 \\u0434\\u044E\\u0439\\u043C\\u0430");
1753 helperTestMultiples(ru
, UMEASFMT_WIDTH_SHORT
, "2 \\u043C\\u0438\\u043B\\u0438, 1 \\u0444\\u0442., 2,3 \\u0434\\u044E\\u0439\\u043C.");
1754 helperTestMultiples(ru
, UMEASFMT_WIDTH_NARROW
, "2 \\u043C\\u0438\\u043B\\u044C 1 \\u0444\\u0442. 2,3 \\u0434\\u044E\\u0439\\u043C\\u0430");
1757 void MeasureFormatTest::helperTestMultiples(
1758 const Locale
&locale
,
1759 UMeasureFormatWidth width
,
1760 const char *expected
) {
1761 UErrorCode status
= U_ZERO_ERROR
;
1762 FieldPosition
pos(FieldPosition::DONT_CARE
);
1763 MeasureFormat
fmt(locale
, width
, status
);
1764 if (!assertSuccess("Error creating format object", status
)) {
1767 Measure measures
[] = {
1768 Measure(2.0, MeasureUnit::createMile(status
), status
),
1769 Measure(1.0, MeasureUnit::createFoot(status
), status
),
1770 Measure(2.3, MeasureUnit::createInch(status
), status
)};
1771 if (!assertSuccess("Error creating measures", status
)) {
1774 UnicodeString buffer
;
1775 fmt
.formatMeasures(measures
, UPRV_LENGTHOF(measures
), buffer
, pos
, status
);
1776 if (!assertSuccess("Error formatting measures", status
)) {
1779 assertEquals("TestMultiples", UnicodeString(expected
).unescape(), buffer
);
1782 void MeasureFormatTest::TestManyLocaleDurations() {
1783 UErrorCode status
= U_ZERO_ERROR
;
1784 Measure measures
[] = {
1785 Measure(5.0, MeasureUnit::createHour(status
), status
),
1786 Measure(37.0, MeasureUnit::createMinute(status
), status
)};
1787 if (!assertSuccess("Error creating measures", status
)) {
1790 helperTestManyLocaleDurations("da", UMEASFMT_WIDTH_NARROW
, measures
, UPRV_LENGTHOF(measures
), "5 t. 37 m."); // Apple data change
1791 helperTestManyLocaleDurations("da", UMEASFMT_WIDTH_NUMERIC
, measures
, UPRV_LENGTHOF(measures
), "5.37");
1792 helperTestManyLocaleDurations("de", UMEASFMT_WIDTH_NARROW
, measures
, UPRV_LENGTHOF(measures
), "5h 37min"); // Apple data change
1793 helperTestManyLocaleDurations("de", UMEASFMT_WIDTH_NUMERIC
, measures
, UPRV_LENGTHOF(measures
), "5:37");
1794 helperTestManyLocaleDurations("en", UMEASFMT_WIDTH_NARROW
, measures
, UPRV_LENGTHOF(measures
), "5h 37m");
1795 helperTestManyLocaleDurations("en", UMEASFMT_WIDTH_NUMERIC
, measures
, UPRV_LENGTHOF(measures
), "5:37");
1796 helperTestManyLocaleDurations("en_GB", UMEASFMT_WIDTH_NARROW
, measures
, UPRV_LENGTHOF(measures
), "5h 37m");
1797 helperTestManyLocaleDurations("en_GB", UMEASFMT_WIDTH_NUMERIC
, measures
, UPRV_LENGTHOF(measures
), "5:37");
1798 helperTestManyLocaleDurations("es", UMEASFMT_WIDTH_NARROW
, measures
, UPRV_LENGTHOF(measures
), "5h 37min");
1799 helperTestManyLocaleDurations("es", UMEASFMT_WIDTH_NUMERIC
, measures
, UPRV_LENGTHOF(measures
), "5:37");
1800 helperTestManyLocaleDurations("fi", UMEASFMT_WIDTH_NARROW
, measures
, UPRV_LENGTHOF(measures
), "5t 37min");
1801 helperTestManyLocaleDurations("fi", UMEASFMT_WIDTH_NUMERIC
, measures
, UPRV_LENGTHOF(measures
), "5.37");
1802 helperTestManyLocaleDurations("fr", UMEASFMT_WIDTH_NARROW
, measures
, UPRV_LENGTHOF(measures
), "5h 37mn");
1803 helperTestManyLocaleDurations("fr", UMEASFMT_WIDTH_NUMERIC
, measures
, UPRV_LENGTHOF(measures
), "5:37");
1804 helperTestManyLocaleDurations("is", UMEASFMT_WIDTH_NARROW
, measures
, UPRV_LENGTHOF(measures
), "5 klst. og 37 m\\u00EDn.");
1805 helperTestManyLocaleDurations("is", UMEASFMT_WIDTH_NUMERIC
, measures
, UPRV_LENGTHOF(measures
), "5:37");
1806 helperTestManyLocaleDurations("ja", UMEASFMT_WIDTH_NARROW
, measures
, UPRV_LENGTHOF(measures
), "5\\u6642\\u959337\\u5206");
1807 helperTestManyLocaleDurations("ja", UMEASFMT_WIDTH_NUMERIC
, measures
, UPRV_LENGTHOF(measures
), "5:37");
1808 helperTestManyLocaleDurations("nb", UMEASFMT_WIDTH_NARROW
, measures
, UPRV_LENGTHOF(measures
), "5t, 37m");
1809 helperTestManyLocaleDurations("nb", UMEASFMT_WIDTH_NUMERIC
, measures
, UPRV_LENGTHOF(measures
), "5:37");
1810 helperTestManyLocaleDurations("nl", UMEASFMT_WIDTH_NARROW
, measures
, UPRV_LENGTHOF(measures
), "5 u, 37 m");
1811 helperTestManyLocaleDurations("nl", UMEASFMT_WIDTH_NUMERIC
, measures
, UPRV_LENGTHOF(measures
), "5:37");
1812 helperTestManyLocaleDurations("nn", UMEASFMT_WIDTH_NARROW
, measures
, UPRV_LENGTHOF(measures
), "5t og 37m");
1813 helperTestManyLocaleDurations("nn", UMEASFMT_WIDTH_NUMERIC
, measures
, UPRV_LENGTHOF(measures
), "5:37");
1814 helperTestManyLocaleDurations("sv", UMEASFMT_WIDTH_NARROW
, measures
, UPRV_LENGTHOF(measures
), "5h 37m");
1815 helperTestManyLocaleDurations("sv", UMEASFMT_WIDTH_NUMERIC
, measures
, UPRV_LENGTHOF(measures
), "5:37");
1816 helperTestManyLocaleDurations("zh", UMEASFMT_WIDTH_NARROW
, measures
, UPRV_LENGTHOF(measures
), "5\\u5C0F\\u65F637\\u5206\\u949F");
1817 helperTestManyLocaleDurations("zh", UMEASFMT_WIDTH_NUMERIC
, measures
, UPRV_LENGTHOF(measures
), "5:37");
1820 void MeasureFormatTest::helperTestManyLocaleDurations( const char *localeID
,
1821 UMeasureFormatWidth width
,
1822 const Measure
*measures
,
1823 int32_t measureCount
,
1824 const char *expected
) {
1825 UErrorCode status
= U_ZERO_ERROR
;
1826 MeasureFormat
fmt(Locale(localeID
), width
, status
);
1827 if (U_FAILURE(status
)) {
1828 errln("Could not create MeasureFormat for locale %s, width %d, status: %s", localeID
, (int)width
, u_errorName(status
));
1831 UnicodeString buffer
;
1832 FieldPosition
pos(FieldPosition::DONT_CARE
);
1833 fmt
.formatMeasures(measures
, measureCount
, buffer
, pos
, status
);
1834 if (U_FAILURE(status
)) {
1835 errln("MeasureFormat::formatMeasures failed for locale %s, width %d, status: %s", localeID
, (int)width
, u_errorName(status
));
1838 UnicodeString
expStr(UnicodeString(expected
).unescape());
1839 if (buffer
!= expStr
) {
1840 errln("MeasureFormat::formatMeasures for locale " + UnicodeString(localeID
) + ", width " + width
+ ", expected \"" + expStr
+ "\", got \"" + buffer
+ "\"");
1844 void MeasureFormatTest::TestGram() {
1845 UErrorCode status
= U_ZERO_ERROR
;
1846 MeasureFormat
fmt("en", UMEASFMT_WIDTH_SHORT
, status
);
1847 if (!assertSuccess("Error creating format object", status
)) {
1850 Measure
gram((double)1, MeasureUnit::createGram(status
), status
);
1851 Measure
gforce((double)1, MeasureUnit::createGForce(status
), status
);
1852 if (!assertSuccess("Error creating measures", status
)) {
1855 verifyFormat("TestGram", fmt
, &gram
, 1, "1 g");
1856 verifyFormat("TestGram", fmt
, &gforce
, 1, "1 G");
1859 void MeasureFormatTest::TestCurrencies() {
1861 u_uastrcpy(USD
, "USD");
1862 UErrorCode status
= U_ZERO_ERROR
;
1863 CurrencyAmount
USD_1(1.0, USD
, status
);
1864 assertEquals("Currency Code", USD
, USD_1
.getISOCurrency());
1865 CurrencyAmount
USD_2(2.0, USD
, status
);
1866 CurrencyAmount
USD_NEG_1(-1.0, USD
, status
);
1867 if (!assertSuccess("Error creating currencies", status
)) {
1871 MeasureFormat
fmt(en
, UMEASFMT_WIDTH_WIDE
, status
);
1872 if (!assertSuccess("Error creating format object", status
)) {
1875 verifyFormat("TestCurrenciesWide", fmt
, &USD_NEG_1
, 1, "-1.00 US dollars");
1876 verifyFormat("TestCurrenciesWide", fmt
, &USD_1
, 1, "1.00 US dollars");
1877 verifyFormat("TestCurrenciesWide", fmt
, &USD_2
, 1, "2.00 US dollars");
1878 fmt
= MeasureFormat(en
, UMEASFMT_WIDTH_SHORT
, status
);
1879 if (!assertSuccess("Error creating format object", status
)) {
1882 verifyFormat("TestCurrenciesShort", fmt
, &USD_NEG_1
, 1, "-USD1.00"); // ICU 61 behavior
1883 verifyFormat("TestCurrenciesShort", fmt
, &USD_1
, 1, "USD1.00");
1884 verifyFormat("TestCurrenciesShort", fmt
, &USD_2
, 1, "USD2.00");
1885 fmt
= MeasureFormat(en
, UMEASFMT_WIDTH_NARROW
, status
);
1886 if (!assertSuccess("Error creating format object", status
)) {
1889 verifyFormat("TestCurrenciesNarrow", fmt
, &USD_NEG_1
, 1, "-$1.00");
1890 verifyFormat("TestCurrenciesNarrow", fmt
, &USD_1
, 1, "$1.00");
1891 verifyFormat("TestCurrenciesNarrow", fmt
, &USD_2
, 1, "$2.00");
1892 fmt
= MeasureFormat(en
, UMEASFMT_WIDTH_NUMERIC
, status
);
1893 if (!assertSuccess("Error creating format object", status
)) {
1896 verifyFormat("TestCurrenciesNumeric", fmt
, &USD_NEG_1
, 1, "-$1.00");
1897 verifyFormat("TestCurrenciesNumeric", fmt
, &USD_1
, 1, "$1.00");
1898 verifyFormat("TestCurrenciesNumeric", fmt
, &USD_2
, 1, "$2.00");
1901 void MeasureFormatTest::TestDisplayNames() {
1902 UErrorCode status
= U_ZERO_ERROR
;
1903 helperTestDisplayName( MeasureUnit::createYear(status
), "en", UMEASFMT_WIDTH_WIDE
, "years" );
1904 helperTestDisplayName( MeasureUnit::createYear(status
), "ja", UMEASFMT_WIDTH_WIDE
, "\\u5E74" );
1905 helperTestDisplayName( MeasureUnit::createYear(status
), "es", UMEASFMT_WIDTH_WIDE
, "a\\u00F1os" );
1906 helperTestDisplayName( MeasureUnit::createYear(status
), "pt", UMEASFMT_WIDTH_WIDE
, "anos" );
1907 helperTestDisplayName( MeasureUnit::createYear(status
), "pt-PT", UMEASFMT_WIDTH_WIDE
, "anos" );
1908 helperTestDisplayName( MeasureUnit::createAmpere(status
), "en", UMEASFMT_WIDTH_WIDE
, "amperes" );
1909 helperTestDisplayName( MeasureUnit::createAmpere(status
), "ja", UMEASFMT_WIDTH_WIDE
, "\\u30A2\\u30F3\\u30DA\\u30A2" );
1910 helperTestDisplayName( MeasureUnit::createAmpere(status
), "es", UMEASFMT_WIDTH_WIDE
, "amperios" );
1911 helperTestDisplayName( MeasureUnit::createAmpere(status
), "pt", UMEASFMT_WIDTH_WIDE
, "amperes" );
1912 helperTestDisplayName( MeasureUnit::createAmpere(status
), "pt-PT", UMEASFMT_WIDTH_WIDE
, "amperes" );
1913 helperTestDisplayName( MeasureUnit::createMeterPerSecondSquared(status
), "pt", UMEASFMT_WIDTH_WIDE
, "metros por segundo ao quadrado" );
1914 helperTestDisplayName( MeasureUnit::createMeterPerSecondSquared(status
), "pt-PT", UMEASFMT_WIDTH_WIDE
, "metros por segundo quadrado" );
1915 helperTestDisplayName( MeasureUnit::createSquareKilometer(status
), "pt", UMEASFMT_WIDTH_NARROW
, "km\\u00B2" );
1916 helperTestDisplayName( MeasureUnit::createSquareKilometer(status
), "pt", UMEASFMT_WIDTH_SHORT
, "km\\u00B2" );
1917 helperTestDisplayName( MeasureUnit::createSquareKilometer(status
), "pt", UMEASFMT_WIDTH_WIDE
, "quil\\u00F4metros quadrados" );
1918 helperTestDisplayName( MeasureUnit::createSecond(status
), "pt-PT", UMEASFMT_WIDTH_NARROW
, "s" );
1919 helperTestDisplayName( MeasureUnit::createSecond(status
), "pt-PT", UMEASFMT_WIDTH_SHORT
, "s" );
1920 helperTestDisplayName( MeasureUnit::createSecond(status
), "pt-PT", UMEASFMT_WIDTH_WIDE
, "segundos" );
1921 helperTestDisplayName( MeasureUnit::createSecond(status
), "pt", UMEASFMT_WIDTH_NARROW
, "seg" );
1922 helperTestDisplayName( MeasureUnit::createSecond(status
), "pt", UMEASFMT_WIDTH_SHORT
, "seg" );
1923 helperTestDisplayName( MeasureUnit::createSecond(status
), "pt", UMEASFMT_WIDTH_WIDE
, "segundos" );
1924 assertSuccess("Error creating measure units", status
);
1927 void MeasureFormatTest::helperTestDisplayName(const MeasureUnit
*unit
,
1928 const char *localeID
,
1929 UMeasureFormatWidth width
,
1930 const char *expected
) {
1931 UErrorCode status
= U_ZERO_ERROR
;
1932 MeasureFormat
fmt(Locale(localeID
), width
, status
);
1933 if (U_FAILURE(status
)) {
1934 errln("Could not create MeasureFormat for locale %s, width %d, status: %s",
1935 localeID
, (int)width
, u_errorName(status
));
1939 UnicodeString dnam
= fmt
.getUnitDisplayName(*unit
, status
);
1940 if (U_FAILURE(status
)) {
1941 errln("MeasureFormat::getUnitDisplayName failed for unit %s-%s, locale %s, width %d, status: %s",
1942 unit
->getType(), unit
->getSubtype(), localeID
, (int)width
, u_errorName(status
));
1946 UnicodeString
expStr(UnicodeString(expected
).unescape());
1947 if (dnam
!= expStr
) {
1948 errln("MeasureFormat::getUnitDisplayName for unit %s-%s, locale %s, width %d: expected \"%s\", got \"%s\"",
1949 unit
->getType(), unit
->getSubtype(), localeID
, (int)width
, CStr(expStr
)(), CStr(dnam
)());
1952 // Delete the measure unit
1956 void MeasureFormatTest::TestFieldPosition() {
1957 UErrorCode status
= U_ZERO_ERROR
;
1958 MeasureFormat
fmt("en", UMEASFMT_WIDTH_SHORT
, status
);
1959 if (!assertSuccess("Error creating format object", status
)) {
1962 Measure
measure(43.5, MeasureUnit::createFoot(status
), status
);
1963 if (!assertSuccess("Error creating measure object 1", status
)) {
1966 UnicodeString
prefix("123456: ");
1967 verifyFieldPosition(
1973 NumberFormat::kDecimalSeparatorField
,
1976 measure
= Measure(43.0, MeasureUnit::createFoot(status
), status
);
1977 if (!assertSuccess("Error creating measure object 2", status
)) {
1980 verifyFieldPosition(
1986 NumberFormat::kDecimalSeparatorField
,
1991 void MeasureFormatTest::TestFieldPositionMultiple() {
1992 UErrorCode status
= U_ZERO_ERROR
;
1993 MeasureFormat
fmt("en", UMEASFMT_WIDTH_SHORT
, status
);
1994 if (!assertSuccess("Error creating format object", status
)) {
1998 Measure((double)354, MeasureUnit::createMeter(status
), status
),
1999 Measure((double)23, MeasureUnit::createCentimeter(status
), status
)};
2000 Measure second
[] = {
2001 Measure((double)354, MeasureUnit::createMeter(status
), status
),
2002 Measure((double)23, MeasureUnit::createCentimeter(status
), status
),
2003 Measure((double)5.4, MeasureUnit::createMillimeter(status
), status
)};
2005 Measure((double)3, MeasureUnit::createMeter(status
), status
),
2006 Measure((double)23, MeasureUnit::createCentimeter(status
), status
),
2007 Measure((double)5, MeasureUnit::createMillimeter(status
), status
)};
2008 if (!assertSuccess("Error creating measure objects", status
)) {
2011 UnicodeString
prefix("123456: ");
2012 verifyFieldPosition(
2017 UPRV_LENGTHOF(first
),
2018 NumberFormat::kIntegerField
,
2021 verifyFieldPosition(
2022 "Decimal separator",
2026 UPRV_LENGTHOF(second
),
2027 NumberFormat::kDecimalSeparatorField
,
2030 verifyFieldPosition(
2031 "no decimal separator",
2035 UPRV_LENGTHOF(third
),
2036 NumberFormat::kDecimalSeparatorField
,
2041 void MeasureFormatTest::TestBadArg() {
2042 UErrorCode status
= U_ZERO_ERROR
;
2043 MeasureFormat
fmt("en", UMEASFMT_WIDTH_SHORT
, status
);
2044 if (!assertSuccess("Error creating format object", status
)) {
2047 FieldPosition
pos(FieldPosition::DONT_CARE
);
2048 UnicodeString buffer
;
2054 if (status
!= U_ILLEGAL_ARGUMENT_ERROR
) {
2055 errln("Expected ILLEGAL_ARGUMENT_ERROR");
2059 void MeasureFormatTest::TestEquality() {
2060 UErrorCode status
= U_ZERO_ERROR
;
2061 NumberFormat
* nfeq
= NumberFormat::createInstance("en", status
);
2062 NumberFormat
* nfne
= NumberFormat::createInstance("fr", status
);
2063 MeasureFormat
fmt("en", UMEASFMT_WIDTH_SHORT
, status
);
2064 MeasureFormat
fmtEq2("en", UMEASFMT_WIDTH_SHORT
, nfeq
, status
);
2065 MeasureFormat
fmtne1("en", UMEASFMT_WIDTH_WIDE
, status
);
2066 MeasureFormat
fmtne2("fr", UMEASFMT_WIDTH_SHORT
, status
);
2067 MeasureFormat
fmtne3("en", UMEASFMT_WIDTH_SHORT
, nfne
, status
);
2068 if (U_FAILURE(status
)) {
2069 dataerrln("Error creating MeasureFormats - %s", u_errorName(status
));
2072 MeasureFormat
fmtEq(fmt
);
2073 assertTrue("Equal", fmt
== fmtEq
);
2074 assertTrue("Equal2", fmt
== fmtEq2
);
2075 assertFalse("Equal Neg", fmt
!= fmtEq
);
2076 assertTrue("Not Equal 1", fmt
!= fmtne1
);
2077 assertFalse("Not Equal Neg 1", fmt
== fmtne1
);
2078 assertTrue("Not Equal 2", fmt
!= fmtne2
);
2079 assertTrue("Not Equal 3", fmt
!= fmtne3
);
2082 void MeasureFormatTest::TestGroupingSeparator() {
2083 UErrorCode status
= U_ZERO_ERROR
;
2085 MeasureFormat
fmt(en
, UMEASFMT_WIDTH_SHORT
, status
);
2086 if (!assertSuccess("Error creating format object", status
)) {
2090 Measure((int32_t)INT32_MAX
, MeasureUnit::createYear(status
), status
),
2091 Measure((int32_t)INT32_MIN
, MeasureUnit::createMonth(status
), status
),
2092 Measure(-987.0, MeasureUnit::createDay(status
), status
),
2093 Measure(1362.0, MeasureUnit::createHour(status
), status
),
2094 Measure(987.0, MeasureUnit::createMinute(status
), status
)};
2095 FieldPosition
pos(NumberFormat::kGroupingSeparatorField
);
2096 UnicodeString appendTo
;
2097 fmt
.formatMeasures(ms
, 5, appendTo
, pos
, status
);
2098 if (!assertSuccess("Error formatting", status
)) {
2102 "grouping separator",
2103 "2,147,483,647 yrs, -2,147,483,648 mths, -987 days, 1,362 hr, 987 min",
2105 assertEquals("begin index", 9, pos
.getBeginIndex()); // ICU 61 behavior
2106 assertEquals("end index", 10, pos
.getEndIndex());
2109 void MeasureFormatTest::TestDoubleZero() {
2110 UErrorCode status
= U_ZERO_ERROR
;
2111 Measure measures
[] = {
2112 Measure(4.7, MeasureUnit::createHour(status
), status
),
2113 Measure(23.0, MeasureUnit::createMinute(status
), status
),
2114 Measure(16.0, MeasureUnit::createSecond(status
), status
)};
2116 NumberFormat
*nf
= NumberFormat::createInstance(en
, status
);
2117 MeasureFormat
fmt("en", UMEASFMT_WIDTH_WIDE
, nf
, status
);
2118 UnicodeString appendTo
;
2119 FieldPosition
pos(FieldPosition::DONT_CARE
);
2120 if (U_FAILURE(status
)) {
2121 dataerrln("Error creating formatter - %s", u_errorName(status
));
2124 nf
->setMinimumFractionDigits(2);
2125 nf
->setMaximumFractionDigits(2);
2126 fmt
.formatMeasures(measures
, UPRV_LENGTHOF(measures
), appendTo
, pos
, status
);
2127 if (!assertSuccess("Error formatting", status
)) {
2132 UnicodeString("4 hours, 23 minutes, 16.00 seconds"),
2134 measures
[0] = Measure(-4.7, MeasureUnit::createHour(status
), status
);
2136 fmt
.formatMeasures(measures
, UPRV_LENGTHOF(measures
), appendTo
, pos
, status
);
2137 if (!assertSuccess("Error formatting", status
)) {
2142 UnicodeString("-4 hours, 23 minutes, 16.00 seconds"),
2146 void MeasureFormatTest::TestUnitPerUnitResolution() {
2147 UErrorCode status
= U_ZERO_ERROR
;
2149 MeasureFormat
fmt("en", UMEASFMT_WIDTH_SHORT
, status
);
2150 Measure
measure(50.0, MeasureUnit::createPound(status
), status
);
2151 LocalPointer
<MeasureUnit
> sqInch(MeasureUnit::createSquareInch(status
));
2152 if (!assertSuccess("Create of format unit and per unit", status
)) {
2155 FieldPosition
pos(FieldPosition::DONT_CARE
);
2156 UnicodeString actual
;
2157 fmt
.formatMeasurePerUnit(
2163 assertEquals("", "50 psi", actual
);
2166 void MeasureFormatTest::TestIndividualPluralFallback() {
2167 // See ticket #11986 "incomplete fallback in MeasureFormat".
2168 // In CLDR 28, fr_CA temperature-generic/short has only the "one" form,
2169 // and falls back to fr for the "other" form.
2170 IcuTestErrorCode
errorCode(*this, "TestIndividualPluralFallback");
2171 MeasureFormat
mf("fr_CA", UMEASFMT_WIDTH_SHORT
, errorCode
);
2172 LocalPointer
<Measure
> twoDeg(
2173 new Measure(2.0, MeasureUnit::createGenericTemperature(errorCode
), errorCode
), errorCode
);
2174 UnicodeString expected
= UNICODE_STRING_SIMPLE("2\\u00B0").unescape();
2175 UnicodeString actual
;
2176 assertEquals("2 deg temp in fr_CA", expected
, mf
.format(twoDeg
.orphan(), actual
, errorCode
), TRUE
);
2179 void MeasureFormatTest::verifyFieldPosition(
2180 const char *description
,
2181 const MeasureFormat
&fmt
,
2182 const UnicodeString
&prefix
,
2183 const Measure
*measures
,
2184 int32_t measureCount
,
2185 NumberFormat::EAlignmentFields field
,
2189 UnicodeString
result(prefix
);
2190 FieldPosition
pos(field
);
2191 UErrorCode status
= U_ZERO_ERROR
;
2193 const char *descPrefix
= ch
.append(description
, status
)
2194 .append(": ", status
).data();
2195 CharString beginIndex
;
2196 beginIndex
.append(descPrefix
, status
).append("beginIndex", status
);
2197 CharString endIndex
;
2198 endIndex
.append(descPrefix
, status
).append("endIndex", status
);
2199 fmt
.formatMeasures(measures
, measureCount
, result
, pos
, status
);
2200 if (!assertSuccess("Error formatting", status
)) {
2203 assertEquals(beginIndex
.data(), start
, pos
.getBeginIndex());
2204 assertEquals(endIndex
.data(), end
, pos
.getEndIndex());
2207 void MeasureFormatTest::verifyFormat(
2208 const char *description
,
2209 const MeasureFormat
&fmt
,
2210 const Measure
*measures
,
2211 int32_t measureCount
,
2212 const char *expected
) {
2213 verifyFormatWithPrefix(
2222 void MeasureFormatTest::verifyFormatWithPrefix(
2223 const char *description
,
2224 const MeasureFormat
&fmt
,
2225 const UnicodeString
&prefix
,
2226 const Measure
*measures
,
2227 int32_t measureCount
,
2228 const char *expected
) {
2229 UnicodeString
result(prefix
);
2230 FieldPosition
pos(FieldPosition::DONT_CARE
);
2231 UErrorCode status
= U_ZERO_ERROR
;
2232 fmt
.formatMeasures(measures
, measureCount
, result
, pos
, status
);
2233 if (!assertSuccess("Error formatting", status
)) {
2236 assertEquals(description
, ctou(expected
), result
);
2239 void MeasureFormatTest::verifyFormat(
2240 const char *description
,
2241 const MeasureFormat
&fmt
,
2242 const ExpectedResult
*expectedResults
,
2244 for (int32_t i
= 0; i
< count
; ++i
) {
2245 verifyFormat(description
, fmt
, expectedResults
[i
].measures
, expectedResults
[i
].count
, expectedResults
[i
].expected
);
2249 extern IntlTest
*createMeasureFormatTest() {
2250 return new MeasureFormatTest();