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 void MeasureFormatTest::TestBasic() {
1043 UErrorCode status
= U_ZERO_ERROR
;
1044 MeasureUnit
*ptr1
= MeasureUnit::createArcMinute(status
);
1045 MeasureUnit
*ptr2
= MeasureUnit::createArcMinute(status
);
1046 if (!(*ptr1
== *ptr2
)) {
1047 errln("Expect == to work.");
1049 if (*ptr1
!= *ptr2
) {
1050 errln("Expect != to work.");
1052 MeasureUnit
*ptr3
= MeasureUnit::createMeter(status
);
1053 if (*ptr1
== *ptr3
) {
1054 errln("Expect == to work.");
1056 if (!(*ptr1
!= *ptr3
)) {
1057 errln("Expect != to work.");
1059 MeasureUnit
*ptr4
= (MeasureUnit
*) ptr1
->clone();
1060 if (*ptr1
!= *ptr4
) {
1061 errln("Expect clone to work.");
1065 if (*ptr1
!= stack
) {
1066 errln("Expect assignment to work.");
1075 void MeasureFormatTest::TestGetAvailable() {
1076 MeasureUnit
*units
= NULL
;
1077 UErrorCode status
= U_ZERO_ERROR
;
1078 int32_t totalCount
= MeasureUnit::getAvailable(units
, 0, status
);
1079 while (status
== U_BUFFER_OVERFLOW_ERROR
) {
1080 status
= U_ZERO_ERROR
;
1082 units
= new MeasureUnit
[totalCount
];
1083 totalCount
= MeasureUnit::getAvailable(units
, totalCount
, status
);
1085 if (U_FAILURE(status
)) {
1086 dataerrln("Failure creating format object - %s", u_errorName(status
));
1090 if (totalCount
< 200) {
1091 errln("Expect at least 200 measure units including currencies.");
1094 StringEnumeration
*types
= MeasureUnit::getAvailableTypes(status
);
1095 if (U_FAILURE(status
)) {
1096 dataerrln("Failure getting types - %s", u_errorName(status
));
1100 if (types
->count(status
) < 10) {
1101 errln("Expect at least 10 distinct unit types.");
1104 int32_t unitCapacity
= 0;
1105 int32_t unitCountSum
= 0;
1107 const char* type
= types
->next(NULL
, status
);
1109 type
= types
->next(NULL
, status
)) {
1110 int32_t unitCount
= MeasureUnit::getAvailable(type
, units
, unitCapacity
, status
);
1111 while (status
== U_BUFFER_OVERFLOW_ERROR
) {
1112 status
= U_ZERO_ERROR
;
1114 units
= new MeasureUnit
[unitCount
];
1115 unitCapacity
= unitCount
;
1116 unitCount
= MeasureUnit::getAvailable(type
, units
, unitCapacity
, status
);
1118 if (U_FAILURE(status
)) {
1119 dataerrln("Failure getting units - %s", u_errorName(status
));
1124 if (unitCount
< 1) {
1125 errln("Expect at least one unit count per type.");
1127 unitCountSum
+= unitCount
;
1129 if (unitCountSum
!= totalCount
) {
1130 errln("Expected total unit count to equal sum of unit counts by type.");
1136 void MeasureFormatTest::TestExamplesInDocs() {
1137 UErrorCode status
= U_ZERO_ERROR
;
1138 MeasureFormat
fmtFr(Locale::getFrench(), UMEASFMT_WIDTH_SHORT
, status
);
1139 MeasureFormat
fmtFrFull(
1140 Locale::getFrench(), UMEASFMT_WIDTH_WIDE
, status
);
1141 MeasureFormat
fmtFrNarrow(
1142 Locale::getFrench(), UMEASFMT_WIDTH_NARROW
, status
);
1143 MeasureFormat
fmtEn(Locale::getUS(), UMEASFMT_WIDTH_WIDE
, status
);
1144 if (!assertSuccess("Error creating formatters", status
)) {
1147 Measure
measureC((double)23, MeasureUnit::createCelsius(status
), status
);
1148 Measure
measureF((double)70, MeasureUnit::createFahrenheit(status
), status
);
1149 Measure feetAndInches
[] = {
1150 Measure((double)70, MeasureUnit::createFoot(status
), status
),
1151 Measure((double)5.3, MeasureUnit::createInch(status
), status
)};
1152 Measure footAndInch
[] = {
1153 Measure((double)1, MeasureUnit::createFoot(status
), status
),
1154 Measure((double)1, MeasureUnit::createInch(status
), status
)};
1155 Measure inchAndFeet
[] = {
1156 Measure((double)1, MeasureUnit::createInch(status
), status
),
1157 Measure((double)2, MeasureUnit::createFoot(status
), status
)};
1158 if (!assertSuccess("Error creating measurements.", status
)) {
1167 verifyFormatWithPrefix(
1173 "Prefix: 23 \\u00B0C");
1184 UPRV_LENGTHOF(feetAndInches
),
1185 "70 pieds et 5,3 pouces");
1186 verifyFormatWithPrefix(
1191 UPRV_LENGTHOF(feetAndInches
),
1192 "Prefix: 70 pieds et 5,3 pouces");
1197 UPRV_LENGTHOF(footAndInch
),
1198 "1 pied et 1 pouce");
1200 "Foot and inch narrow",
1203 UPRV_LENGTHOF(footAndInch
),
1204 "1\\u2032 1\\u2033");
1209 UPRV_LENGTHOF(inchAndFeet
),
1213 void MeasureFormatTest::TestFormatPeriodEn() {
1214 UErrorCode status
= U_ZERO_ERROR
;
1215 Measure t_19m
[] = {Measure((double)19, MeasureUnit::createMinute(status
), status
)};
1216 Measure t_1h_23_5s
[] = {
1217 Measure((double)1.0, MeasureUnit::createHour(status
), status
),
1218 Measure((double)23.5, MeasureUnit::createSecond(status
), status
)
1220 Measure t_1h_23_5m
[] = {
1221 Measure((double)1.0, MeasureUnit::createHour(status
), status
),
1222 Measure((double)23.5, MeasureUnit::createMinute(status
), status
)
1224 Measure t_1h_0m_23s
[] = {
1227 TimeUnit::createInstance(
1228 TimeUnit::UTIMEUNIT_HOUR
, status
),
1232 TimeUnit::createInstance(
1233 TimeUnit::UTIMEUNIT_MINUTE
, status
),
1237 TimeUnit::createInstance(
1238 TimeUnit::UTIMEUNIT_SECOND
, status
),
1241 Measure t_2y_5M_3w_4d
[] = {
1242 Measure(2.0, MeasureUnit::createYear(status
), status
),
1243 Measure(5.0, MeasureUnit::createMonth(status
), status
),
1244 Measure(3.0, MeasureUnit::createWeek(status
), status
),
1245 Measure(4.0, MeasureUnit::createDay(status
), status
)
1247 Measure t_1m_59_9996s
[] = {
1248 Measure(1.0, MeasureUnit::createMinute(status
), status
),
1249 Measure(59.9996, MeasureUnit::createSecond(status
), status
)
1251 Measure t_5h_17m
[] = {
1252 Measure(5.0, MeasureUnit::createHour(status
), status
),
1253 Measure(17.0, MeasureUnit::createMinute(status
), status
)
1255 Measure t_neg5h_17m
[] = {
1256 Measure(-5.0, MeasureUnit::createHour(status
), status
),
1257 Measure(17.0, MeasureUnit::createMinute(status
), status
)
1259 Measure t_19m_28s
[] = {
1260 Measure(19.0, MeasureUnit::createMinute(status
), status
),
1261 Measure(28.0, MeasureUnit::createSecond(status
), status
)
1263 Measure t_0h_0m_9s
[] = {
1264 Measure(0.0, MeasureUnit::createHour(status
), status
),
1265 Measure(0.0, MeasureUnit::createMinute(status
), status
),
1266 Measure(9.0, MeasureUnit::createSecond(status
), status
)
1268 Measure t_0h_0m_17s
[] = {
1269 Measure(0.0, MeasureUnit::createHour(status
), status
),
1270 Measure(0.0, MeasureUnit::createMinute(status
), status
),
1271 Measure(17.0, MeasureUnit::createSecond(status
), status
)
1273 Measure t_6h_56_92m
[] = {
1274 Measure(6.0, MeasureUnit::createHour(status
), status
),
1275 Measure(56.92, MeasureUnit::createMinute(status
), status
)
1277 Measure t_3h_4s_5m
[] = {
1278 Measure(3.0, MeasureUnit::createHour(status
), status
),
1279 Measure(4.0, MeasureUnit::createSecond(status
), status
),
1280 Measure(5.0, MeasureUnit::createMinute(status
), status
)
1282 Measure t_6_7h_56_92m
[] = {
1283 Measure(6.7, MeasureUnit::createHour(status
), status
),
1284 Measure(56.92, MeasureUnit::createMinute(status
), status
)
1287 Measure t_3h_5h
[] = {
1288 Measure(3.0, MeasureUnit::createHour(status
), status
),
1289 Measure(5.0, MeasureUnit::createHour(status
), status
)
1292 if (!assertSuccess("Error creating Measure objects", status
)) {
1296 ExpectedResult fullData
[] = {
1297 {t_1m_59_9996s
, UPRV_LENGTHOF(t_1m_59_9996s
), "1 minute, 59.9996 seconds"},
1298 {t_19m
, UPRV_LENGTHOF(t_19m
), "19 minutes"},
1299 {t_1h_23_5s
, UPRV_LENGTHOF(t_1h_23_5s
), "1 hour, 23.5 seconds"},
1300 {t_1h_23_5m
, UPRV_LENGTHOF(t_1h_23_5m
), "1 hour, 23.5 minutes"},
1301 {t_1h_0m_23s
, UPRV_LENGTHOF(t_1h_0m_23s
), "1 hour, 0 minutes, 23 seconds"},
1302 {t_2y_5M_3w_4d
, UPRV_LENGTHOF(t_2y_5M_3w_4d
), "2 years, 5 months, 3 weeks, 4 days"}};
1304 ExpectedResult abbrevData
[] = {
1305 {t_1m_59_9996s
, UPRV_LENGTHOF(t_1m_59_9996s
), "1 min, 59.9996 sec"},
1306 {t_19m
, UPRV_LENGTHOF(t_19m
), "19 min"},
1307 {t_1h_23_5s
, UPRV_LENGTHOF(t_1h_23_5s
), "1 hr, 23.5 sec"},
1308 {t_1h_23_5m
, UPRV_LENGTHOF(t_1h_23_5m
), "1 hr, 23.5 min"},
1309 {t_1h_0m_23s
, UPRV_LENGTHOF(t_1h_0m_23s
), "1 hr, 0 min, 23 sec"},
1310 {t_2y_5M_3w_4d
, UPRV_LENGTHOF(t_2y_5M_3w_4d
), "2 yrs, 5 mths, 3 wks, 4 days"}};
1312 ExpectedResult narrowData
[] = {
1313 {t_1m_59_9996s
, UPRV_LENGTHOF(t_1m_59_9996s
), "1m 59.9996s"},
1314 {t_19m
, UPRV_LENGTHOF(t_19m
), "19m"},
1315 {t_1h_23_5s
, UPRV_LENGTHOF(t_1h_23_5s
), "1h 23.5s"},
1316 {t_1h_23_5m
, UPRV_LENGTHOF(t_1h_23_5m
), "1h 23.5m"},
1317 {t_1h_0m_23s
, UPRV_LENGTHOF(t_1h_0m_23s
), "1h 0m 23s"},
1318 {t_2y_5M_3w_4d
, UPRV_LENGTHOF(t_2y_5M_3w_4d
), "2y 5mo 3w 4d"}};
1320 ExpectedResult numericData
[] = {
1321 {t_1m_59_9996s
, UPRV_LENGTHOF(t_1m_59_9996s
), "1:59.9996"},
1322 {t_19m
, UPRV_LENGTHOF(t_19m
), "19m"},
1323 {t_1h_23_5s
, UPRV_LENGTHOF(t_1h_23_5s
), "1:00:23.5"},
1324 {t_1h_23_5m
, UPRV_LENGTHOF(t_1h_23_5m
), "1:23.5"},
1325 {t_1h_0m_23s
, UPRV_LENGTHOF(t_1h_0m_23s
), "1:00:23"},
1326 {t_5h_17m
, UPRV_LENGTHOF(t_5h_17m
), "5:17"},
1327 {t_neg5h_17m
, UPRV_LENGTHOF(t_neg5h_17m
), "-5h 17m"},
1328 {t_19m_28s
, UPRV_LENGTHOF(t_19m_28s
), "19:28"},
1329 {t_2y_5M_3w_4d
, UPRV_LENGTHOF(t_2y_5M_3w_4d
), "2y 5mo 3w 4d"},
1330 {t_0h_0m_9s
, UPRV_LENGTHOF(t_0h_0m_9s
), "0:00:09"},
1331 {t_6h_56_92m
, UPRV_LENGTHOF(t_6h_56_92m
), "6:56.92"},
1332 {t_6_7h_56_92m
, UPRV_LENGTHOF(t_6_7h_56_92m
), "6:56.92"},
1333 {t_3h_4s_5m
, UPRV_LENGTHOF(t_3h_4s_5m
), "3h 4s 5m"},
1334 {t_3h_5h
, UPRV_LENGTHOF(t_3h_5h
), "3h 5h"}};
1336 ExpectedResult fullDataDe
[] = {
1337 {t_1m_59_9996s
, UPRV_LENGTHOF(t_1m_59_9996s
), "1 Minute und 59,9996 Sekunden"},
1338 {t_19m
, UPRV_LENGTHOF(t_19m
), "19 Minuten"},
1339 {t_1h_23_5s
, UPRV_LENGTHOF(t_1h_23_5s
), "1 Stunde und 23,5 Sekunden"},
1340 {t_1h_23_5m
, UPRV_LENGTHOF(t_1h_23_5m
), "1 Stunde und 23,5 Minuten"},
1341 {t_1h_0m_23s
, UPRV_LENGTHOF(t_1h_0m_23s
), "1 Stunde, 0 Minuten und 23 Sekunden"},
1342 {t_2y_5M_3w_4d
, UPRV_LENGTHOF(t_2y_5M_3w_4d
), "2 Jahre, 5 Monate, 3 Wochen und 4 Tage"}};
1344 ExpectedResult numericDataDe
[] = {
1345 {t_1m_59_9996s
, UPRV_LENGTHOF(t_1m_59_9996s
), "1:59,9996"},
1346 {t_19m
, UPRV_LENGTHOF(t_19m
), "19min"},
1347 {t_1h_23_5s
, UPRV_LENGTHOF(t_1h_23_5s
), "1:00:23,5"},
1348 {t_1h_23_5m
, UPRV_LENGTHOF(t_1h_23_5m
), "1:23,5"},
1349 {t_1h_0m_23s
, UPRV_LENGTHOF(t_1h_0m_23s
), "1:00:23"},
1350 {t_5h_17m
, UPRV_LENGTHOF(t_5h_17m
), "5:17"},
1351 {t_19m_28s
, UPRV_LENGTHOF(t_19m_28s
), "19:28"},
1352 {t_2y_5M_3w_4d
, UPRV_LENGTHOF(t_2y_5M_3w_4d
), "2J 5M 3W 4d"},
1353 {t_0h_0m_17s
, UPRV_LENGTHOF(t_0h_0m_17s
), "0:00:17"},
1354 {t_6h_56_92m
, UPRV_LENGTHOF(t_6h_56_92m
), "6:56,92"},
1355 {t_3h_5h
, UPRV_LENGTHOF(t_3h_5h
), "3h 5h"}};
1357 Locale
en(Locale::getEnglish());
1358 LocalPointer
<NumberFormat
> nf(NumberFormat::createInstance(en
, status
));
1359 if (U_FAILURE(status
)) {
1360 dataerrln("Error creating number format en object - %s", u_errorName(status
));
1363 nf
->setMaximumFractionDigits(4);
1364 MeasureFormat
mf(en
, UMEASFMT_WIDTH_WIDE
, (NumberFormat
*) nf
->clone(), status
);
1365 if (!assertSuccess("Error creating measure format en WIDE", status
)) {
1368 verifyFormat("en WIDE", mf
, fullData
, UPRV_LENGTHOF(fullData
));
1370 // exercise copy constructor
1372 MeasureFormat
mf2(mf
);
1373 verifyFormat("en WIDE copy", mf2
, fullData
, UPRV_LENGTHOF(fullData
));
1377 MeasureFormat
*mf3
= (MeasureFormat
*) mf
.clone();
1378 verifyFormat("en WIDE copy", *mf3
, fullData
, UPRV_LENGTHOF(fullData
));
1381 mf
= MeasureFormat(en
, UMEASFMT_WIDTH_SHORT
, (NumberFormat
*) nf
->clone(), status
);
1382 if (!assertSuccess("Error creating measure format en SHORT", status
)) {
1385 verifyFormat("en SHORT", mf
, abbrevData
, UPRV_LENGTHOF(abbrevData
));
1386 mf
= MeasureFormat(en
, UMEASFMT_WIDTH_NARROW
, (NumberFormat
*) nf
->clone(), status
);
1387 if (!assertSuccess("Error creating measure format en NARROW", status
)) {
1390 verifyFormat("en NARROW", mf
, narrowData
, UPRV_LENGTHOF(narrowData
));
1391 mf
= MeasureFormat(en
, UMEASFMT_WIDTH_NUMERIC
, (NumberFormat
*) nf
->clone(), status
);
1392 if (!assertSuccess("Error creating measure format en NUMERIC", status
)) {
1395 verifyFormat("en NUMERIC", mf
, numericData
, UPRV_LENGTHOF(numericData
));
1397 Locale
de(Locale::getGerman());
1398 nf
.adoptInstead(NumberFormat::createInstance(de
, status
));
1399 if (!assertSuccess("Error creating number format de object", status
)) {
1402 nf
->setMaximumFractionDigits(4);
1403 mf
= MeasureFormat(de
, UMEASFMT_WIDTH_WIDE
, (NumberFormat
*) nf
->clone(), status
);
1404 if (!assertSuccess("Error creating measure format de WIDE", status
)) {
1407 verifyFormat("de WIDE", mf
, fullDataDe
, UPRV_LENGTHOF(fullDataDe
));
1408 mf
= MeasureFormat(de
, UMEASFMT_WIDTH_NUMERIC
, (NumberFormat
*) nf
->clone(), status
);
1409 if (!assertSuccess("Error creating measure format de NUMERIC", status
)) {
1412 verifyFormat("de NUMERIC", mf
, numericDataDe
, UPRV_LENGTHOF(numericDataDe
));
1415 void MeasureFormatTest::Test10219FractionalPlurals() {
1416 Locale
en(Locale::getEnglish());
1417 double values
[] = {1.588, 1.011};
1418 const char *expected
[2][3] = {
1419 {"1 minute", "1.5 minutes", "1.58 minutes"},
1420 {"1 minute", "1.0 minutes", "1.01 minutes"}
1422 UErrorCode status
= U_ZERO_ERROR
;
1423 for (int j
= 0; j
< UPRV_LENGTHOF(values
); j
++) {
1424 for (int i
= 0; i
< UPRV_LENGTHOF(expected
[j
]); i
++) {
1426 (DecimalFormat
*) NumberFormat::createInstance(en
, status
);
1427 if (U_FAILURE(status
)) {
1428 dataerrln("Error creating Number format - %s", u_errorName(status
));
1431 df
->setRoundingMode(DecimalFormat::kRoundDown
);
1432 df
->setMinimumFractionDigits(i
);
1433 df
->setMaximumFractionDigits(i
);
1434 MeasureFormat
mf(en
, UMEASFMT_WIDTH_WIDE
, df
, status
);
1435 if (!assertSuccess("Error creating Measure format", status
)) {
1438 Measure
measure(values
[j
], MeasureUnit::createMinute(status
), status
);
1439 if (!assertSuccess("Error creating Measure unit", status
)) {
1442 verifyFormat("Test10219", mf
, &measure
, 1, expected
[j
][i
]);
1447 static MeasureUnit
toMeasureUnit(MeasureUnit
*adopted
) {
1448 MeasureUnit
result(*adopted
);
1453 void MeasureFormatTest::TestGreek() {
1454 Locale locales
[] = {Locale("el_GR"), Locale("el")};
1455 UErrorCode status
= U_ZERO_ERROR
;
1456 MeasureUnit units
[] = {
1457 toMeasureUnit(MeasureUnit::createSecond(status
)),
1458 toMeasureUnit(MeasureUnit::createMinute(status
)),
1459 toMeasureUnit(MeasureUnit::createHour(status
)),
1460 toMeasureUnit(MeasureUnit::createDay(status
)),
1461 toMeasureUnit(MeasureUnit::createWeek(status
)),
1462 toMeasureUnit(MeasureUnit::createMonth(status
)),
1463 toMeasureUnit(MeasureUnit::createYear(status
))};
1464 if (!assertSuccess("Error creating Measure units", status
)) {
1467 UMeasureFormatWidth styles
[] = {
1468 UMEASFMT_WIDTH_WIDE
,
1469 UMEASFMT_WIDTH_SHORT
};
1470 int32_t numbers
[] = {1, 7};
1471 const char *expected
[] = {
1473 "1 \\u03B4\\u03B5\\u03C5\\u03C4\\u03B5\\u03C1\\u03CC\\u03BB\\u03B5\\u03C0\\u03C4\\u03BF",
1474 "1 \\u03BB\\u03B5\\u03C0\\u03C4\\u03CC",
1475 "1 \\u03CE\\u03C1\\u03B1",
1476 "1 \\u03B7\\u03BC\\u03AD\\u03C1\\u03B1",
1477 "1 \\u03B5\\u03B2\\u03B4\\u03BF\\u03BC\\u03AC\\u03B4\\u03B1",
1478 "1 \\u03BC\\u03AE\\u03BD\\u03B1\\u03C2",
1479 "1 \\u03AD\\u03C4\\u03BF\\u03C2",
1481 "1 \\u03B4\\u03B5\\u03C5\\u03C4.",
1482 "1 \\u03BB\\u03B5\\u03C0.",
1483 "1 \\u03CE\\u03C1\\u03B1",
1484 "1 \\u03B7\\u03BC\\u03AD\\u03C1\\u03B1",
1485 "1 \\u03B5\\u03B2\\u03B4.",
1486 "1 \\u03BC\\u03AE\\u03BD.",
1487 "1 \\u03AD\\u03C4.", // year (one)
1489 "7 \\u03B4\\u03B5\\u03C5\\u03C4\\u03B5\\u03C1\\u03CC\\u03BB\\u03B5\\u03C0\\u03C4\\u03B1",
1490 "7 \\u03BB\\u03B5\\u03C0\\u03C4\\u03AC",
1491 "7 \\u03CE\\u03C1\\u03B5\\u03C2",
1492 "7 \\u03B7\\u03BC\\u03AD\\u03C1\\u03B5\\u03C2",
1493 "7 \\u03B5\\u03B2\\u03B4\\u03BF\\u03BC\\u03AC\\u03B4\\u03B5\\u03C2",
1494 "7 \\u03BC\\u03AE\\u03BD\\u03B5\\u03C2",
1495 "7 \\u03AD\\u03C4\\u03B7",
1497 "7 \\u03B4\\u03B5\\u03C5\\u03C4.",
1498 "7 \\u03BB\\u03B5\\u03C0.",
1499 "7 \\u03CE\\u03C1.", // hour (other)
1500 "7 \\u03B7\\u03BC\\u03AD\\u03C1\\u03B5\\u03C2",
1501 "7 \\u03B5\\u03B2\\u03B4.",
1502 "7 \\u03BC\\u03AE\\u03BD.",
1503 "7 \\u03AD\\u03C4.", // year (other)
1506 "1 \\u03B4\\u03B5\\u03C5\\u03C4\\u03B5\\u03C1\\u03CC\\u03BB\\u03B5\\u03C0\\u03C4\\u03BF",
1507 "1 \\u03BB\\u03B5\\u03C0\\u03C4\\u03CC",
1508 "1 \\u03CE\\u03C1\\u03B1",
1509 "1 \\u03B7\\u03BC\\u03AD\\u03C1\\u03B1",
1510 "1 \\u03B5\\u03B2\\u03B4\\u03BF\\u03BC\\u03AC\\u03B4\\u03B1",
1511 "1 \\u03BC\\u03AE\\u03BD\\u03B1\\u03C2",
1512 "1 \\u03AD\\u03C4\\u03BF\\u03C2",
1514 "1 \\u03B4\\u03B5\\u03C5\\u03C4.",
1515 "1 \\u03BB\\u03B5\\u03C0.",
1516 "1 \\u03CE\\u03C1\\u03B1",
1517 "1 \\u03B7\\u03BC\\u03AD\\u03C1\\u03B1",
1518 "1 \\u03B5\\u03B2\\u03B4.",
1519 "1 \\u03BC\\u03AE\\u03BD.",
1520 "1 \\u03AD\\u03C4.", // year (one)
1522 "7 \\u03B4\\u03B5\\u03C5\\u03C4\\u03B5\\u03C1\\u03CC\\u03BB\\u03B5\\u03C0\\u03C4\\u03B1",
1523 "7 \\u03BB\\u03B5\\u03C0\\u03C4\\u03AC",
1524 "7 \\u03CE\\u03C1\\u03B5\\u03C2",
1525 "7 \\u03B7\\u03BC\\u03AD\\u03C1\\u03B5\\u03C2",
1526 "7 \\u03B5\\u03B2\\u03B4\\u03BF\\u03BC\\u03AC\\u03B4\\u03B5\\u03C2",
1527 "7 \\u03BC\\u03AE\\u03BD\\u03B5\\u03C2",
1528 "7 \\u03AD\\u03C4\\u03B7",
1530 "7 \\u03B4\\u03B5\\u03C5\\u03C4.",
1531 "7 \\u03BB\\u03B5\\u03C0.",
1532 "7 \\u03CE\\u03C1.", // hour (other)
1533 "7 \\u03B7\\u03BC\\u03AD\\u03C1\\u03B5\\u03C2",
1534 "7 \\u03B5\\u03B2\\u03B4.",
1535 "7 \\u03BC\\u03AE\\u03BD.",
1536 "7 \\u03AD\\u03C4."}; // year (other)
1538 int32_t counter
= 0;
1539 for (int32_t locIndex
= 0; locIndex
< UPRV_LENGTHOF(locales
); ++locIndex
) {
1540 for( int32_t numIndex
= 0; numIndex
< UPRV_LENGTHOF(numbers
); ++numIndex
) {
1541 for ( int32_t styleIndex
= 0; styleIndex
< UPRV_LENGTHOF(styles
); ++styleIndex
) {
1542 for ( int32_t unitIndex
= 0; unitIndex
< UPRV_LENGTHOF(units
); ++unitIndex
) {
1543 Measure
measure(numbers
[numIndex
], new MeasureUnit(units
[unitIndex
]), status
);
1544 if (!assertSuccess("Error creating Measure", status
)) {
1547 MeasureFormat
fmt(locales
[locIndex
], styles
[styleIndex
], status
);
1548 if (!assertSuccess("Error creating Measure format", status
)) {
1551 verifyFormat("TestGreek", fmt
, &measure
, 1, expected
[counter
]);
1559 void MeasureFormatTest::TestFormatSingleArg() {
1560 UErrorCode status
= U_ZERO_ERROR
;
1561 MeasureFormat
fmt("en", UMEASFMT_WIDTH_WIDE
, status
);
1562 if (!assertSuccess("Error creating formatter", status
)) {
1565 UnicodeString buffer
;
1566 FieldPosition
pos(FieldPosition::DONT_CARE
);
1568 new Measure(3.5, MeasureUnit::createFoot(status
), status
),
1572 if (!assertSuccess("Error formatting", status
)) {
1576 "TestFormatSingleArg",
1577 UnicodeString("3.5 feet"),
1581 void MeasureFormatTest::TestFormatMeasuresZeroArg() {
1582 UErrorCode status
= U_ZERO_ERROR
;
1583 MeasureFormat
fmt("en", UMEASFMT_WIDTH_WIDE
, status
);
1584 verifyFormat("TestFormatMeasuresZeroArg", fmt
, NULL
, 0, "");
1587 void MeasureFormatTest::TestSimplePer() {
1589 UErrorCode status
= U_ZERO_ERROR
;
1590 LocalPointer
<MeasureUnit
> second(MeasureUnit::createSecond(status
));
1591 LocalPointer
<MeasureUnit
> minute(MeasureUnit::createMinute(status
));
1592 LocalPointer
<MeasureUnit
> pound(MeasureUnit::createPound(status
));
1593 if (!assertSuccess("", status
)) {
1597 helperTestSimplePer(
1598 en
, UMEASFMT_WIDTH_WIDE
,
1599 1.0, *pound
, *second
, "1 pound per second");
1600 helperTestSimplePer(
1601 en
, UMEASFMT_WIDTH_WIDE
,
1602 2.0, *pound
, *second
, "2 pounds per second");
1603 helperTestSimplePer(
1604 en
, UMEASFMT_WIDTH_WIDE
,
1605 1.0, *pound
, *minute
, "1 pound per minute");
1606 helperTestSimplePer(
1607 en
, UMEASFMT_WIDTH_WIDE
,
1608 2.0, *pound
, *minute
, "2 pounds per minute");
1610 helperTestSimplePer(
1611 en
, UMEASFMT_WIDTH_SHORT
, 1.0, *pound
, *second
, "1 lb/s");
1612 helperTestSimplePer(
1613 en
, UMEASFMT_WIDTH_SHORT
, 2.0, *pound
, *second
, "2 lb/s");
1614 helperTestSimplePer(
1615 en
, UMEASFMT_WIDTH_SHORT
, 1.0, *pound
, *minute
, "1 lb/min");
1616 helperTestSimplePer(
1617 en
, UMEASFMT_WIDTH_SHORT
, 2.0, *pound
, *minute
, "2 lb/min");
1619 helperTestSimplePer(
1620 en
, UMEASFMT_WIDTH_NARROW
, 1.0, *pound
, *second
, "1#/s");
1621 helperTestSimplePer(
1622 en
, UMEASFMT_WIDTH_NARROW
, 2.0, *pound
, *second
, "2#/s");
1623 helperTestSimplePer(
1624 en
, UMEASFMT_WIDTH_NARROW
, 1.0, *pound
, *minute
, "1#/min");
1625 helperTestSimplePer(
1626 en
, UMEASFMT_WIDTH_NARROW
, 2.0, *pound
, *minute
, "2#/min");
1628 helperTestSimplePer(
1629 en
, UMEASFMT_WIDTH_SHORT
,
1630 23.3, *pound
, *second
, "23.3 lb/s",
1631 NumberFormat::kDecimalSeparatorField
,
1634 helperTestSimplePer(
1635 en
, UMEASFMT_WIDTH_SHORT
,
1636 23.3, *pound
, *second
, "23.3 lb/s",
1637 NumberFormat::kIntegerField
,
1640 helperTestSimplePer(
1641 en
, UMEASFMT_WIDTH_SHORT
,
1642 23.3, *pound
, *minute
, "23.3 lb/min",
1643 NumberFormat::kDecimalSeparatorField
,
1646 helperTestSimplePer(
1647 en
, UMEASFMT_WIDTH_SHORT
,
1648 23.3, *pound
, *minute
, "23.3 lb/min",
1649 NumberFormat::kIntegerField
,
1653 void MeasureFormatTest::TestNumeratorPlurals() {
1655 UErrorCode status
= U_ZERO_ERROR
;
1656 LocalPointer
<MeasureUnit
> second(MeasureUnit::createSecond(status
));
1657 LocalPointer
<MeasureUnit
> foot(MeasureUnit::createFoot(status
));
1658 if (!assertSuccess("", status
)) {
1662 helperTestSimplePer(
1664 UMEASFMT_WIDTH_WIDE
,
1665 1.0, *foot
, *second
, "1 stopa na sekund\\u0119");
1666 helperTestSimplePer(
1668 UMEASFMT_WIDTH_WIDE
,
1669 2.0, *foot
, *second
, "2 stopy na sekund\\u0119");
1670 helperTestSimplePer(
1672 UMEASFMT_WIDTH_WIDE
,
1673 5.0, *foot
, *second
, "5 st\\u00f3p na sekund\\u0119");
1674 helperTestSimplePer(
1675 pl
, UMEASFMT_WIDTH_WIDE
,
1676 1.5, *foot
, *second
, "1,5 stopy na sekund\\u0119");
1679 void MeasureFormatTest::helperTestSimplePer(
1680 const Locale
&locale
,
1681 UMeasureFormatWidth width
,
1683 const MeasureUnit
&unit
,
1684 const MeasureUnit
&perUnit
,
1685 const char *expected
) {
1686 helperTestSimplePer(
1693 FieldPosition::DONT_CARE
,
1698 void MeasureFormatTest::helperTestSimplePer(
1699 const Locale
&locale
,
1700 UMeasureFormatWidth width
,
1702 const MeasureUnit
&unit
,
1703 const MeasureUnit
&perUnit
,
1704 const char *expected
,
1706 int32_t expected_start
,
1707 int32_t expected_end
) {
1708 UErrorCode status
= U_ZERO_ERROR
;
1709 FieldPosition
pos(field
);
1710 MeasureFormat
fmt(locale
, width
, status
);
1711 if (!assertSuccess("Error creating format object", status
)) {
1714 Measure
measure(value
, (MeasureUnit
*) unit
.clone(), status
);
1715 if (!assertSuccess("Error creating measure object", status
)) {
1718 UnicodeString
prefix("prefix: ");
1719 UnicodeString
buffer(prefix
);
1720 fmt
.formatMeasurePerUnit(
1726 if (!assertSuccess("Error formatting measures with per", status
)) {
1729 UnicodeString
uexpected(expected
);
1730 uexpected
= prefix
+ uexpected
;
1733 uexpected
.unescape(),
1735 if (field
!= FieldPosition::DONT_CARE
) {
1737 "Start", expected_start
, pos
.getBeginIndex() - prefix
.length());
1739 "End", expected_end
, pos
.getEndIndex() - prefix
.length());
1743 void MeasureFormatTest::TestMultiples() {
1746 helperTestMultiples(en
, UMEASFMT_WIDTH_WIDE
, "2 miles, 1 foot, 2.3 inches");
1747 helperTestMultiples(en
, UMEASFMT_WIDTH_SHORT
, "2 mi, 1 ft, 2.3 in");
1748 helperTestMultiples(en
, UMEASFMT_WIDTH_NARROW
, "2mi 1\\u2032 2.3\\u2033");
1749 helperTestMultiples(ru
, UMEASFMT_WIDTH_WIDE
, "2 \\u043C\\u0438\\u043B\\u0438, 1 \\u0444\\u0443\\u0442, 2,3 \\u0434\\u044E\\u0439\\u043C\\u0430");
1750 helperTestMultiples(ru
, UMEASFMT_WIDTH_SHORT
, "2 \\u043C\\u0438\\u043B\\u0438, 1 \\u0444\\u0442., 2,3 \\u0434\\u044E\\u0439\\u043C.");
1751 helperTestMultiples(ru
, UMEASFMT_WIDTH_NARROW
, "2 \\u043C\\u0438\\u043B\\u044C 1 \\u0444\\u0442. 2,3 \\u0434\\u044E\\u0439\\u043C\\u0430");
1754 void MeasureFormatTest::helperTestMultiples(
1755 const Locale
&locale
,
1756 UMeasureFormatWidth width
,
1757 const char *expected
) {
1758 UErrorCode status
= U_ZERO_ERROR
;
1759 FieldPosition
pos(FieldPosition::DONT_CARE
);
1760 MeasureFormat
fmt(locale
, width
, status
);
1761 if (!assertSuccess("Error creating format object", status
)) {
1764 Measure measures
[] = {
1765 Measure(2.0, MeasureUnit::createMile(status
), status
),
1766 Measure(1.0, MeasureUnit::createFoot(status
), status
),
1767 Measure(2.3, MeasureUnit::createInch(status
), status
)};
1768 if (!assertSuccess("Error creating measures", status
)) {
1771 UnicodeString buffer
;
1772 fmt
.formatMeasures(measures
, UPRV_LENGTHOF(measures
), buffer
, pos
, status
);
1773 if (!assertSuccess("Error formatting measures", status
)) {
1776 assertEquals("TestMultiples", UnicodeString(expected
).unescape(), buffer
);
1779 void MeasureFormatTest::TestManyLocaleDurations() {
1780 UErrorCode status
= U_ZERO_ERROR
;
1781 Measure measures
[] = {
1782 Measure(5.0, MeasureUnit::createHour(status
), status
),
1783 Measure(37.0, MeasureUnit::createMinute(status
), status
)};
1784 if (!assertSuccess("Error creating measures", status
)) {
1787 helperTestManyLocaleDurations("da", UMEASFMT_WIDTH_NARROW
, measures
, UPRV_LENGTHOF(measures
), "5 t. 37 m."); // Apple data change
1788 helperTestManyLocaleDurations("da", UMEASFMT_WIDTH_NUMERIC
, measures
, UPRV_LENGTHOF(measures
), "5.37");
1789 helperTestManyLocaleDurations("de", UMEASFMT_WIDTH_NARROW
, measures
, UPRV_LENGTHOF(measures
), "5h 37min"); // Apple data change
1790 helperTestManyLocaleDurations("de", UMEASFMT_WIDTH_NUMERIC
, measures
, UPRV_LENGTHOF(measures
), "5:37");
1791 helperTestManyLocaleDurations("en", UMEASFMT_WIDTH_NARROW
, measures
, UPRV_LENGTHOF(measures
), "5h 37m");
1792 helperTestManyLocaleDurations("en", UMEASFMT_WIDTH_NUMERIC
, measures
, UPRV_LENGTHOF(measures
), "5:37");
1793 helperTestManyLocaleDurations("en_GB", UMEASFMT_WIDTH_NARROW
, measures
, UPRV_LENGTHOF(measures
), "5h 37m");
1794 helperTestManyLocaleDurations("en_GB", UMEASFMT_WIDTH_NUMERIC
, measures
, UPRV_LENGTHOF(measures
), "5:37");
1795 helperTestManyLocaleDurations("es", UMEASFMT_WIDTH_NARROW
, measures
, UPRV_LENGTHOF(measures
), "5h 37min");
1796 helperTestManyLocaleDurations("es", UMEASFMT_WIDTH_NUMERIC
, measures
, UPRV_LENGTHOF(measures
), "5:37");
1797 helperTestManyLocaleDurations("fi", UMEASFMT_WIDTH_NARROW
, measures
, UPRV_LENGTHOF(measures
), "5t 37min");
1798 helperTestManyLocaleDurations("fi", UMEASFMT_WIDTH_NUMERIC
, measures
, UPRV_LENGTHOF(measures
), "5.37");
1799 helperTestManyLocaleDurations("fr", UMEASFMT_WIDTH_NARROW
, measures
, UPRV_LENGTHOF(measures
), "5h 37mn");
1800 helperTestManyLocaleDurations("fr", UMEASFMT_WIDTH_NUMERIC
, measures
, UPRV_LENGTHOF(measures
), "05:37");
1801 helperTestManyLocaleDurations("is", UMEASFMT_WIDTH_NARROW
, measures
, UPRV_LENGTHOF(measures
), "5 klst. og 37 m\\u00EDn.");
1802 helperTestManyLocaleDurations("is", UMEASFMT_WIDTH_NUMERIC
, measures
, UPRV_LENGTHOF(measures
), "5:37");
1803 helperTestManyLocaleDurations("ja", UMEASFMT_WIDTH_NARROW
, measures
, UPRV_LENGTHOF(measures
), "5h37m");
1804 helperTestManyLocaleDurations("ja", UMEASFMT_WIDTH_NUMERIC
, measures
, UPRV_LENGTHOF(measures
), "5:37");
1805 helperTestManyLocaleDurations("nb", UMEASFMT_WIDTH_NARROW
, measures
, UPRV_LENGTHOF(measures
), "5t, 37m");
1806 helperTestManyLocaleDurations("nb", UMEASFMT_WIDTH_NUMERIC
, measures
, UPRV_LENGTHOF(measures
), "5:37");
1807 helperTestManyLocaleDurations("nl", UMEASFMT_WIDTH_NARROW
, measures
, UPRV_LENGTHOF(measures
), "5 u, 37 m");
1808 helperTestManyLocaleDurations("nl", UMEASFMT_WIDTH_NUMERIC
, measures
, UPRV_LENGTHOF(measures
), "5:37");
1809 helperTestManyLocaleDurations("nn", UMEASFMT_WIDTH_NARROW
, measures
, UPRV_LENGTHOF(measures
), "5 h og 37 min");
1810 helperTestManyLocaleDurations("nn", UMEASFMT_WIDTH_NUMERIC
, measures
, UPRV_LENGTHOF(measures
), "5:37");
1811 helperTestManyLocaleDurations("sv", UMEASFMT_WIDTH_NARROW
, measures
, UPRV_LENGTHOF(measures
), "5h 37m");
1812 helperTestManyLocaleDurations("sv", UMEASFMT_WIDTH_NUMERIC
, measures
, UPRV_LENGTHOF(measures
), "5:37");
1813 helperTestManyLocaleDurations("zh", UMEASFMT_WIDTH_NARROW
, measures
, UPRV_LENGTHOF(measures
), "5\\u5C0F\\u65F637\\u5206\\u949F");
1814 helperTestManyLocaleDurations("zh", UMEASFMT_WIDTH_NUMERIC
, measures
, UPRV_LENGTHOF(measures
), "5:37");
1817 void MeasureFormatTest::helperTestManyLocaleDurations( const char *localeID
,
1818 UMeasureFormatWidth width
,
1819 const Measure
*measures
,
1820 int32_t measureCount
,
1821 const char *expected
) {
1822 UErrorCode status
= U_ZERO_ERROR
;
1823 MeasureFormat
fmt(Locale(localeID
), width
, status
);
1824 if (U_FAILURE(status
)) {
1825 errln("Could not create MeasureFormat for locale %s, width %d, status: %s", localeID
, (int)width
, u_errorName(status
));
1828 UnicodeString buffer
;
1829 FieldPosition
pos(FieldPosition::DONT_CARE
);
1830 fmt
.formatMeasures(measures
, measureCount
, buffer
, pos
, status
);
1831 if (U_FAILURE(status
)) {
1832 errln("MeasureFormat::formatMeasures failed for locale %s, width %d, status: %s", localeID
, (int)width
, u_errorName(status
));
1835 UnicodeString
expStr(UnicodeString(expected
).unescape());
1836 if (buffer
!= expStr
) {
1837 errln("MeasureFormat::formatMeasures for locale " + UnicodeString(localeID
) + ", width " + width
+ ", expected \"" + expStr
+ "\", got \"" + buffer
+ "\"");
1841 void MeasureFormatTest::TestGram() {
1842 UErrorCode status
= U_ZERO_ERROR
;
1843 MeasureFormat
fmt("en", UMEASFMT_WIDTH_SHORT
, status
);
1844 if (!assertSuccess("Error creating format object", status
)) {
1847 Measure
gram((double)1, MeasureUnit::createGram(status
), status
);
1848 Measure
gforce((double)1, MeasureUnit::createGForce(status
), status
);
1849 if (!assertSuccess("Error creating measures", status
)) {
1852 verifyFormat("TestGram", fmt
, &gram
, 1, "1 g");
1853 verifyFormat("TestGram", fmt
, &gforce
, 1, "1 G");
1856 void MeasureFormatTest::TestCurrencies() {
1858 u_uastrcpy(USD
, "USD");
1859 UErrorCode status
= U_ZERO_ERROR
;
1860 CurrencyAmount
USD_1(1.0, USD
, status
);
1861 assertEquals("Currency Code", USD
, USD_1
.getISOCurrency());
1862 CurrencyAmount
USD_2(2.0, USD
, status
);
1863 CurrencyAmount
USD_NEG_1(-1.0, USD
, status
);
1864 if (!assertSuccess("Error creating currencies", status
)) {
1868 MeasureFormat
fmt(en
, UMEASFMT_WIDTH_WIDE
, status
);
1869 if (!assertSuccess("Error creating format object", status
)) {
1872 verifyFormat("TestCurrenciesWide", fmt
, &USD_NEG_1
, 1, "-1.00 US dollars");
1873 verifyFormat("TestCurrenciesWide", fmt
, &USD_1
, 1, "1.00 US dollars");
1874 verifyFormat("TestCurrenciesWide", fmt
, &USD_2
, 1, "2.00 US dollars");
1875 fmt
= MeasureFormat(en
, UMEASFMT_WIDTH_SHORT
, status
);
1876 if (!assertSuccess("Error creating format object", status
)) {
1879 verifyFormat("TestCurrenciesShort", fmt
, &USD_NEG_1
, 1, "-USD1.00");
1880 verifyFormat("TestCurrenciesShort", fmt
, &USD_1
, 1, "USD1.00");
1881 verifyFormat("TestCurrenciesShort", fmt
, &USD_2
, 1, "USD2.00");
1882 fmt
= MeasureFormat(en
, UMEASFMT_WIDTH_NARROW
, status
);
1883 if (!assertSuccess("Error creating format object", status
)) {
1886 verifyFormat("TestCurrenciesNarrow", fmt
, &USD_NEG_1
, 1, "-$1.00");
1887 verifyFormat("TestCurrenciesNarrow", fmt
, &USD_1
, 1, "$1.00");
1888 verifyFormat("TestCurrenciesNarrow", fmt
, &USD_2
, 1, "$2.00");
1889 fmt
= MeasureFormat(en
, UMEASFMT_WIDTH_NUMERIC
, status
);
1890 if (!assertSuccess("Error creating format object", status
)) {
1893 verifyFormat("TestCurrenciesNumeric", fmt
, &USD_NEG_1
, 1, "-$1.00");
1894 verifyFormat("TestCurrenciesNumeric", fmt
, &USD_1
, 1, "$1.00");
1895 verifyFormat("TestCurrenciesNumeric", fmt
, &USD_2
, 1, "$2.00");
1898 void MeasureFormatTest::TestDisplayNames() {
1899 UErrorCode status
= U_ZERO_ERROR
;
1900 helperTestDisplayName( MeasureUnit::createYear(status
), "en", UMEASFMT_WIDTH_WIDE
, "years" );
1901 helperTestDisplayName( MeasureUnit::createYear(status
), "ja", UMEASFMT_WIDTH_WIDE
, "\\u5E74" );
1902 helperTestDisplayName( MeasureUnit::createYear(status
), "es", UMEASFMT_WIDTH_WIDE
, "a\\u00F1os" );
1903 helperTestDisplayName( MeasureUnit::createYear(status
), "pt", UMEASFMT_WIDTH_WIDE
, "anos" );
1904 helperTestDisplayName( MeasureUnit::createYear(status
), "pt-PT", UMEASFMT_WIDTH_WIDE
, "anos" );
1905 helperTestDisplayName( MeasureUnit::createAmpere(status
), "en", UMEASFMT_WIDTH_WIDE
, "amperes" );
1906 helperTestDisplayName( MeasureUnit::createAmpere(status
), "ja", UMEASFMT_WIDTH_WIDE
, "\\u30A2\\u30F3\\u30DA\\u30A2" );
1907 helperTestDisplayName( MeasureUnit::createAmpere(status
), "es", UMEASFMT_WIDTH_WIDE
, "amperios" );
1908 helperTestDisplayName( MeasureUnit::createAmpere(status
), "pt", UMEASFMT_WIDTH_WIDE
, "amperes" );
1909 helperTestDisplayName( MeasureUnit::createAmpere(status
), "pt-PT", UMEASFMT_WIDTH_WIDE
, "amperes" );
1910 helperTestDisplayName( MeasureUnit::createMeterPerSecondSquared(status
), "pt", UMEASFMT_WIDTH_WIDE
, "metros por segundo ao quadrado" );
1911 helperTestDisplayName( MeasureUnit::createMeterPerSecondSquared(status
), "pt-PT", UMEASFMT_WIDTH_WIDE
, "metros por segundo quadrado" );
1912 helperTestDisplayName( MeasureUnit::createSquareKilometer(status
), "pt", UMEASFMT_WIDTH_NARROW
, "km\\u00B2" );
1913 helperTestDisplayName( MeasureUnit::createSquareKilometer(status
), "pt", UMEASFMT_WIDTH_SHORT
, "km\\u00B2" );
1914 helperTestDisplayName( MeasureUnit::createSquareKilometer(status
), "pt", UMEASFMT_WIDTH_WIDE
, "quil\\u00F4metros quadrados" );
1915 helperTestDisplayName( MeasureUnit::createSecond(status
), "pt-PT", UMEASFMT_WIDTH_NARROW
, "s" );
1916 helperTestDisplayName( MeasureUnit::createSecond(status
), "pt-PT", UMEASFMT_WIDTH_SHORT
, "s" );
1917 helperTestDisplayName( MeasureUnit::createSecond(status
), "pt-PT", UMEASFMT_WIDTH_WIDE
, "segundos" );
1918 helperTestDisplayName( MeasureUnit::createSecond(status
), "pt", UMEASFMT_WIDTH_NARROW
, "seg" );
1919 helperTestDisplayName( MeasureUnit::createSecond(status
), "pt", UMEASFMT_WIDTH_SHORT
, "segs" );
1920 helperTestDisplayName( MeasureUnit::createSecond(status
), "pt", UMEASFMT_WIDTH_WIDE
, "segundos" );
1921 assertSuccess("Error creating measure units", status
);
1924 void MeasureFormatTest::helperTestDisplayName(const MeasureUnit
*unit
,
1925 const char *localeID
,
1926 UMeasureFormatWidth width
,
1927 const char *expected
) {
1928 UErrorCode status
= U_ZERO_ERROR
;
1929 MeasureFormat
fmt(Locale(localeID
), width
, status
);
1930 if (U_FAILURE(status
)) {
1931 errln("Could not create MeasureFormat for locale %s, width %d, status: %s",
1932 localeID
, (int)width
, u_errorName(status
));
1936 UnicodeString dnam
= fmt
.getUnitDisplayName(*unit
, status
);
1937 if (U_FAILURE(status
)) {
1938 errln("MeasureFormat::getUnitDisplayName failed for unit %s-%s, locale %s, width %d, status: %s",
1939 unit
->getType(), unit
->getSubtype(), localeID
, (int)width
, u_errorName(status
));
1943 UnicodeString
expStr(UnicodeString(expected
).unescape());
1944 if (dnam
!= expStr
) {
1945 errln("MeasureFormat::getUnitDisplayName for unit %s-%s, locale %s, width %d: expected \"%s\", got \"%s\"",
1946 unit
->getType(), unit
->getSubtype(), localeID
, (int)width
, CStr(expStr
)(), CStr(dnam
)());
1949 // Delete the measure unit
1953 void MeasureFormatTest::TestFieldPosition() {
1954 UErrorCode status
= U_ZERO_ERROR
;
1955 MeasureFormat
fmt("en", UMEASFMT_WIDTH_SHORT
, status
);
1956 if (!assertSuccess("Error creating format object", status
)) {
1959 Measure
measure(43.5, MeasureUnit::createFoot(status
), status
);
1960 if (!assertSuccess("Error creating measure object 1", status
)) {
1963 UnicodeString
prefix("123456: ");
1964 verifyFieldPosition(
1970 NumberFormat::kDecimalSeparatorField
,
1973 measure
= Measure(43.0, MeasureUnit::createFoot(status
), status
);
1974 if (!assertSuccess("Error creating measure object 2", status
)) {
1977 verifyFieldPosition(
1983 NumberFormat::kDecimalSeparatorField
,
1988 void MeasureFormatTest::TestFieldPositionMultiple() {
1989 UErrorCode status
= U_ZERO_ERROR
;
1990 MeasureFormat
fmt("en", UMEASFMT_WIDTH_SHORT
, status
);
1991 if (!assertSuccess("Error creating format object", status
)) {
1995 Measure((double)354, MeasureUnit::createMeter(status
), status
),
1996 Measure((double)23, MeasureUnit::createCentimeter(status
), status
)};
1997 Measure second
[] = {
1998 Measure((double)354, MeasureUnit::createMeter(status
), status
),
1999 Measure((double)23, MeasureUnit::createCentimeter(status
), status
),
2000 Measure((double)5.4, MeasureUnit::createMillimeter(status
), status
)};
2002 Measure((double)3, MeasureUnit::createMeter(status
), status
),
2003 Measure((double)23, MeasureUnit::createCentimeter(status
), status
),
2004 Measure((double)5, MeasureUnit::createMillimeter(status
), status
)};
2005 if (!assertSuccess("Error creating measure objects", status
)) {
2008 UnicodeString
prefix("123456: ");
2009 verifyFieldPosition(
2014 UPRV_LENGTHOF(first
),
2015 NumberFormat::kIntegerField
,
2018 verifyFieldPosition(
2019 "Decimal separator",
2023 UPRV_LENGTHOF(second
),
2024 NumberFormat::kDecimalSeparatorField
,
2027 verifyFieldPosition(
2028 "no decimal separator",
2032 UPRV_LENGTHOF(third
),
2033 NumberFormat::kDecimalSeparatorField
,
2038 void MeasureFormatTest::TestBadArg() {
2039 UErrorCode status
= U_ZERO_ERROR
;
2040 MeasureFormat
fmt("en", UMEASFMT_WIDTH_SHORT
, status
);
2041 if (!assertSuccess("Error creating format object", status
)) {
2044 FieldPosition
pos(FieldPosition::DONT_CARE
);
2045 UnicodeString buffer
;
2051 if (status
!= U_ILLEGAL_ARGUMENT_ERROR
) {
2052 errln("Expected ILLEGAL_ARGUMENT_ERROR");
2056 void MeasureFormatTest::TestEquality() {
2057 UErrorCode status
= U_ZERO_ERROR
;
2058 NumberFormat
* nfeq
= NumberFormat::createInstance("en", status
);
2059 NumberFormat
* nfne
= NumberFormat::createInstance("fr", status
);
2060 MeasureFormat
fmt("en", UMEASFMT_WIDTH_SHORT
, status
);
2061 MeasureFormat
fmtEq2("en", UMEASFMT_WIDTH_SHORT
, nfeq
, status
);
2062 MeasureFormat
fmtne1("en", UMEASFMT_WIDTH_WIDE
, status
);
2063 MeasureFormat
fmtne2("fr", UMEASFMT_WIDTH_SHORT
, status
);
2064 MeasureFormat
fmtne3("en", UMEASFMT_WIDTH_SHORT
, nfne
, status
);
2065 if (U_FAILURE(status
)) {
2066 dataerrln("Error creating MeasureFormats - %s", u_errorName(status
));
2069 MeasureFormat
fmtEq(fmt
);
2070 assertTrue("Equal", fmt
== fmtEq
);
2071 assertTrue("Equal2", fmt
== fmtEq2
);
2072 assertFalse("Equal Neg", fmt
!= fmtEq
);
2073 assertTrue("Not Equal 1", fmt
!= fmtne1
);
2074 assertFalse("Not Equal Neg 1", fmt
== fmtne1
);
2075 assertTrue("Not Equal 2", fmt
!= fmtne2
);
2076 assertTrue("Not Equal 3", fmt
!= fmtne3
);
2079 void MeasureFormatTest::TestGroupingSeparator() {
2080 UErrorCode status
= U_ZERO_ERROR
;
2082 MeasureFormat
fmt(en
, UMEASFMT_WIDTH_SHORT
, status
);
2083 if (!assertSuccess("Error creating format object", status
)) {
2087 Measure((int32_t)INT32_MAX
, MeasureUnit::createYear(status
), status
),
2088 Measure((int32_t)INT32_MIN
, MeasureUnit::createMonth(status
), status
),
2089 Measure(-987.0, MeasureUnit::createDay(status
), status
),
2090 Measure(1362.0, MeasureUnit::createHour(status
), status
),
2091 Measure(987.0, MeasureUnit::createMinute(status
), status
)};
2092 FieldPosition
pos(NumberFormat::kGroupingSeparatorField
);
2093 UnicodeString appendTo
;
2094 fmt
.formatMeasures(ms
, 5, appendTo
, pos
, status
);
2095 if (!assertSuccess("Error formatting", status
)) {
2099 "grouping separator",
2100 "2,147,483,647 yrs, -2,147,483,648 mths, -987 days, 1,362 hr, 987 min",
2102 assertEquals("begin index", 9, pos
.getBeginIndex());
2103 assertEquals("end index", 10, pos
.getEndIndex());
2106 void MeasureFormatTest::TestDoubleZero() {
2107 UErrorCode status
= U_ZERO_ERROR
;
2108 Measure measures
[] = {
2109 Measure(4.7, MeasureUnit::createHour(status
), status
),
2110 Measure(23.0, MeasureUnit::createMinute(status
), status
),
2111 Measure(16.0, MeasureUnit::createSecond(status
), status
)};
2113 NumberFormat
*nf
= NumberFormat::createInstance(en
, status
);
2114 MeasureFormat
fmt("en", UMEASFMT_WIDTH_WIDE
, nf
, status
);
2115 UnicodeString appendTo
;
2116 FieldPosition
pos(FieldPosition::DONT_CARE
);
2117 if (U_FAILURE(status
)) {
2118 dataerrln("Error creating formatter - %s", u_errorName(status
));
2121 nf
->setMinimumFractionDigits(2);
2122 nf
->setMaximumFractionDigits(2);
2123 fmt
.formatMeasures(measures
, UPRV_LENGTHOF(measures
), appendTo
, pos
, status
);
2124 if (!assertSuccess("Error formatting", status
)) {
2129 UnicodeString("4 hours, 23 minutes, 16.00 seconds"),
2131 measures
[0] = Measure(-4.7, MeasureUnit::createHour(status
), status
);
2133 fmt
.formatMeasures(measures
, UPRV_LENGTHOF(measures
), appendTo
, pos
, status
);
2134 if (!assertSuccess("Error formatting", status
)) {
2139 UnicodeString("-4 hours, 23 minutes, 16.00 seconds"),
2143 void MeasureFormatTest::TestUnitPerUnitResolution() {
2144 UErrorCode status
= U_ZERO_ERROR
;
2146 MeasureFormat
fmt("en", UMEASFMT_WIDTH_SHORT
, status
);
2147 Measure
measure(50.0, MeasureUnit::createPound(status
), status
);
2148 LocalPointer
<MeasureUnit
> sqInch(MeasureUnit::createSquareInch(status
));
2149 if (!assertSuccess("Create of format unit and per unit", status
)) {
2152 FieldPosition
pos(FieldPosition::DONT_CARE
);
2153 UnicodeString actual
;
2154 fmt
.formatMeasurePerUnit(
2160 assertEquals("", "50 psi", actual
);
2163 void MeasureFormatTest::TestIndividualPluralFallback() {
2164 // See ticket #11986 "incomplete fallback in MeasureFormat".
2165 // In CLDR 28, fr_CA temperature-generic/short has only the "one" form,
2166 // and falls back to fr for the "other" form.
2167 IcuTestErrorCode
errorCode(*this, "TestIndividualPluralFallback");
2168 MeasureFormat
mf("fr_CA", UMEASFMT_WIDTH_SHORT
, errorCode
);
2169 LocalPointer
<Measure
> twoDeg(
2170 new Measure(2.0, MeasureUnit::createGenericTemperature(errorCode
), errorCode
), errorCode
);
2171 UnicodeString expected
= UNICODE_STRING_SIMPLE("2\\u00B0").unescape();
2172 UnicodeString actual
;
2173 assertEquals("2 deg temp in fr_CA", expected
, mf
.format(twoDeg
.orphan(), actual
, errorCode
), TRUE
);
2176 void MeasureFormatTest::verifyFieldPosition(
2177 const char *description
,
2178 const MeasureFormat
&fmt
,
2179 const UnicodeString
&prefix
,
2180 const Measure
*measures
,
2181 int32_t measureCount
,
2182 NumberFormat::EAlignmentFields field
,
2186 UnicodeString
result(prefix
);
2187 FieldPosition
pos(field
);
2188 UErrorCode status
= U_ZERO_ERROR
;
2190 const char *descPrefix
= ch
.append(description
, status
)
2191 .append(": ", status
).data();
2192 CharString beginIndex
;
2193 beginIndex
.append(descPrefix
, status
).append("beginIndex", status
);
2194 CharString endIndex
;
2195 endIndex
.append(descPrefix
, status
).append("endIndex", status
);
2196 fmt
.formatMeasures(measures
, measureCount
, result
, pos
, status
);
2197 if (!assertSuccess("Error formatting", status
)) {
2200 assertEquals(beginIndex
.data(), start
, pos
.getBeginIndex());
2201 assertEquals(endIndex
.data(), end
, pos
.getEndIndex());
2204 void MeasureFormatTest::verifyFormat(
2205 const char *description
,
2206 const MeasureFormat
&fmt
,
2207 const Measure
*measures
,
2208 int32_t measureCount
,
2209 const char *expected
) {
2210 verifyFormatWithPrefix(
2219 void MeasureFormatTest::verifyFormatWithPrefix(
2220 const char *description
,
2221 const MeasureFormat
&fmt
,
2222 const UnicodeString
&prefix
,
2223 const Measure
*measures
,
2224 int32_t measureCount
,
2225 const char *expected
) {
2226 UnicodeString
result(prefix
);
2227 FieldPosition
pos(FieldPosition::DONT_CARE
);
2228 UErrorCode status
= U_ZERO_ERROR
;
2229 fmt
.formatMeasures(measures
, measureCount
, result
, pos
, status
);
2230 if (!assertSuccess("Error formatting", status
)) {
2233 assertEquals(description
, ctou(expected
), result
);
2236 void MeasureFormatTest::verifyFormat(
2237 const char *description
,
2238 const MeasureFormat
&fmt
,
2239 const ExpectedResult
*expectedResults
,
2241 for (int32_t i
= 0; i
< count
; ++i
) {
2242 verifyFormat(description
, fmt
, expectedResults
[i
].measures
, expectedResults
[i
].count
, expectedResults
[i
].expected
);
2246 extern IntlTest
*createMeasureFormatTest() {
2247 return new MeasureFormatTest();