1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3 /*
4 *******************************************************************************
5 * Copyright (C) 2014-2016, International Business Machines Corporation and *
6 * others. All Rights Reserved. *
7 *******************************************************************************
8 *
9 * File MEASFMTTEST.CPP
10 *
11 *******************************************************************************
12 */
13 #include <stdio.h>
14 #include <stdlib.h>
15
16 #include "intltest.h"
17
18 #if !UCONFIG_NO_FORMATTING
19
20 #include "charstr.h"
21 #include "cstr.h"
22 #include "measunit_impl.h"
23 #include "unicode/decimfmt.h"
24 #include "unicode/measfmt.h"
25 #include "unicode/measure.h"
26 #include "unicode/measunit.h"
27 #include "unicode/strenum.h"
28 #include "unicode/tmunit.h"
29 #include "unicode/plurrule.h"
30 #include "unicode/ustring.h"
31 #include "unicode/reldatefmt.h"
32 #include "unicode/rbnf.h"
33
34 struct ExpectedResult {
35 const Measure *measures;
36 int32_t count;
37 const char *expected;
38 };
39
40 class MeasureFormatTest : public IntlTest {
41 public:
MeasureFormatTest()42 MeasureFormatTest() {
43 }
44
45 void runIndexedTest(int32_t index, UBool exec, const char *&name, char *par=0);
46 private:
47 void TestBasic();
48 void TestCompatible53();
49 void TestCompatible54();
50 void TestCompatible55();
51 void TestCompatible56();
52 void TestCompatible57();
53 void TestCompatible58();
54 void TestCompatible59();
55 void TestCompatible63();
56 void TestCompatible64();
57 void TestCompatible65();
58 void TestCompatible68();
59 void TestGetAvailable();
60 void TestExamplesInDocs();
61 void TestFormatPeriodEn();
62 void Test10219FractionalPlurals();
63 void TestGreek();
64 void TestFormatSingleArg();
65 void TestFormatMeasuresZeroArg();
66 void TestSimplePer();
67 void TestNumeratorPlurals();
68 void TestMultiples();
69 void TestManyLocaleDurations();
70 void TestGram();
71 void TestCurrencies();
72 void TestDisplayNames();
73 void TestFieldPosition();
74 void TestFieldPositionMultiple();
75 void TestBadArg();
76 void TestEquality();
77 void TestGroupingSeparator();
78 void TestDoubleZero();
79 void TestUnitPerUnitResolution();
80 void TestIndividualPluralFallback();
81 void Test20332_PersonUnits();
82 void TestNumericTime();
83 void TestNumericTimeSomeSpecialFormats();
84 void TestIdentifiers();
85 void TestInvalidIdentifiers();
86 void TestParseToBuiltIn();
87 void TestKilogramIdentifier();
88 void TestCompoundUnitOperations();
89 void TestDimensionlessBehaviour();
90 void Test21060_AddressSanitizerProblem();
91 void Test21223_FrenchDuration();
92 void TestInternalMeasureUnitImpl();
93
94 void verifyFormat(
95 const char *description,
96 const MeasureFormat &fmt,
97 const Measure *measures,
98 int32_t measureCount,
99 const char *expected);
100 void verifyFormatWithPrefix(
101 const char *description,
102 const MeasureFormat &fmt,
103 const UnicodeString &prefix,
104 const Measure *measures,
105 int32_t measureCount,
106 const char *expected);
107 void verifyFormat(
108 const char *description,
109 const MeasureFormat &fmt,
110 const ExpectedResult *expectedResults,
111 int32_t count);
112 void helperTestSimplePer(
113 const Locale &locale,
114 UMeasureFormatWidth width,
115 double value,
116 const MeasureUnit &unit,
117 const MeasureUnit &perUnit,
118 const char *expected);
119 void helperTestSimplePer(
120 const Locale &locale,
121 UMeasureFormatWidth width,
122 double value,
123 const MeasureUnit &unit,
124 const MeasureUnit &perUnit,
125 const char *expected,
126 int32_t field,
127 int32_t expected_start,
128 int32_t expected_end);
129 void helperTestMultiples(
130 const Locale &locale,
131 UMeasureFormatWidth width,
132 const char *expected);
133 void helperTestManyLocaleDurations(
134 const char *localeID,
135 UMeasureFormatWidth width,
136 const Measure *measures,
137 int32_t measureCount,
138 const char *expected);
139 void helperTestDisplayName(
140 const MeasureUnit *unit,
141 const char *localeID,
142 UMeasureFormatWidth width,
143 const char *expected);
144 void verifyFieldPosition(
145 const char *description,
146 const MeasureFormat &fmt,
147 const UnicodeString &prefix,
148 const Measure *measures,
149 int32_t measureCount,
150 NumberFormat::EAlignmentFields field,
151 int32_t start,
152 int32_t end);
153 void verifySingleUnit(
154 const MeasureUnit& unit,
155 UMeasureSIPrefix siPrefix,
156 int8_t power,
157 const char* identifier);
158 void verifyCompoundUnit(
159 const MeasureUnit& unit,
160 const char* identifier,
161 const char** subIdentifiers,
162 int32_t subIdentifierCount);
163 void verifyMixedUnit(
164 const MeasureUnit& unit,
165 const char* identifier,
166 const char** subIdentifiers,
167 int32_t subIdentifierCount);
168 };
169
runIndexedTest(int32_t index,UBool exec,const char * & name,char *)170 void MeasureFormatTest::runIndexedTest(
171 int32_t index, UBool exec, const char *&name, char *) {
172 if (exec) {
173 logln("TestSuite MeasureFormatTest: ");
174 }
175 TESTCASE_AUTO_BEGIN;
176 TESTCASE_AUTO(TestBasic);
177 TESTCASE_AUTO(TestCompatible53);
178 TESTCASE_AUTO(TestCompatible54);
179 TESTCASE_AUTO(TestCompatible55);
180 TESTCASE_AUTO(TestCompatible56);
181 TESTCASE_AUTO(TestCompatible57);
182 TESTCASE_AUTO(TestCompatible58);
183 TESTCASE_AUTO(TestCompatible59);
184 TESTCASE_AUTO(TestCompatible63);
185 TESTCASE_AUTO(TestCompatible64);
186 TESTCASE_AUTO(TestCompatible65);
187 TESTCASE_AUTO(TestCompatible68);
188 TESTCASE_AUTO(TestGetAvailable);
189 TESTCASE_AUTO(TestExamplesInDocs);
190 TESTCASE_AUTO(TestFormatPeriodEn);
191 TESTCASE_AUTO(Test10219FractionalPlurals);
192 TESTCASE_AUTO(TestGreek);
193 TESTCASE_AUTO(TestFormatSingleArg);
194 TESTCASE_AUTO(TestFormatMeasuresZeroArg);
195 TESTCASE_AUTO(TestSimplePer);
196 TESTCASE_AUTO(TestNumeratorPlurals);
197 TESTCASE_AUTO(TestMultiples);
198 TESTCASE_AUTO(TestManyLocaleDurations);
199 TESTCASE_AUTO(TestGram);
200 TESTCASE_AUTO(TestCurrencies);
201 TESTCASE_AUTO(TestDisplayNames);
202 TESTCASE_AUTO(TestFieldPosition);
203 TESTCASE_AUTO(TestFieldPositionMultiple);
204 TESTCASE_AUTO(TestBadArg);
205 TESTCASE_AUTO(TestEquality);
206 TESTCASE_AUTO(TestGroupingSeparator);
207 TESTCASE_AUTO(TestDoubleZero);
208 TESTCASE_AUTO(TestUnitPerUnitResolution);
209 TESTCASE_AUTO(TestIndividualPluralFallback);
210 TESTCASE_AUTO(Test20332_PersonUnits);
211 TESTCASE_AUTO(TestNumericTime);
212 TESTCASE_AUTO(TestNumericTimeSomeSpecialFormats);
213 TESTCASE_AUTO(TestIdentifiers);
214 TESTCASE_AUTO(TestInvalidIdentifiers);
215 TESTCASE_AUTO(TestParseToBuiltIn);
216 TESTCASE_AUTO(TestKilogramIdentifier);
217 TESTCASE_AUTO(TestCompoundUnitOperations);
218 TESTCASE_AUTO(TestDimensionlessBehaviour);
219 TESTCASE_AUTO(Test21060_AddressSanitizerProblem);
220 TESTCASE_AUTO(Test21223_FrenchDuration);
221 TESTCASE_AUTO(TestInternalMeasureUnitImpl);
222 TESTCASE_AUTO_END;
223 }
224
TestCompatible53()225 void MeasureFormatTest::TestCompatible53() {
226 UErrorCode status = U_ZERO_ERROR;
227 LocalPointer<MeasureUnit> measureUnit;
228 measureUnit.adoptInstead(MeasureUnit::createGForce(status));
229 measureUnit.adoptInstead(MeasureUnit::createArcMinute(status));
230 measureUnit.adoptInstead(MeasureUnit::createArcSecond(status));
231 measureUnit.adoptInstead(MeasureUnit::createDegree(status));
232 measureUnit.adoptInstead(MeasureUnit::createAcre(status));
233 measureUnit.adoptInstead(MeasureUnit::createHectare(status));
234 measureUnit.adoptInstead(MeasureUnit::createSquareFoot(status));
235 measureUnit.adoptInstead(MeasureUnit::createSquareKilometer(status));
236 measureUnit.adoptInstead(MeasureUnit::createSquareMeter(status));
237 measureUnit.adoptInstead(MeasureUnit::createSquareMile(status));
238 measureUnit.adoptInstead(MeasureUnit::createDay(status));
239 measureUnit.adoptInstead(MeasureUnit::createHour(status));
240 measureUnit.adoptInstead(MeasureUnit::createMillisecond(status));
241 measureUnit.adoptInstead(MeasureUnit::createMinute(status));
242 measureUnit.adoptInstead(MeasureUnit::createMonth(status));
243 measureUnit.adoptInstead(MeasureUnit::createSecond(status));
244 measureUnit.adoptInstead(MeasureUnit::createWeek(status));
245 measureUnit.adoptInstead(MeasureUnit::createYear(status));
246 measureUnit.adoptInstead(MeasureUnit::createCentimeter(status));
247 measureUnit.adoptInstead(MeasureUnit::createFoot(status));
248 measureUnit.adoptInstead(MeasureUnit::createInch(status));
249 measureUnit.adoptInstead(MeasureUnit::createKilometer(status));
250 measureUnit.adoptInstead(MeasureUnit::createLightYear(status));
251 measureUnit.adoptInstead(MeasureUnit::createMeter(status));
252 measureUnit.adoptInstead(MeasureUnit::createMile(status));
253 measureUnit.adoptInstead(MeasureUnit::createMillimeter(status));
254 measureUnit.adoptInstead(MeasureUnit::createPicometer(status));
255 measureUnit.adoptInstead(MeasureUnit::createYard(status));
256 measureUnit.adoptInstead(MeasureUnit::createGram(status));
257 measureUnit.adoptInstead(MeasureUnit::createKilogram(status));
258 measureUnit.adoptInstead(MeasureUnit::createOunce(status));
259 measureUnit.adoptInstead(MeasureUnit::createPound(status));
260 measureUnit.adoptInstead(MeasureUnit::createHorsepower(status));
261 measureUnit.adoptInstead(MeasureUnit::createKilowatt(status));
262 measureUnit.adoptInstead(MeasureUnit::createWatt(status));
263 measureUnit.adoptInstead(MeasureUnit::createHectopascal(status));
264 measureUnit.adoptInstead(MeasureUnit::createInchHg(status));
265 measureUnit.adoptInstead(MeasureUnit::createMillibar(status));
266 measureUnit.adoptInstead(MeasureUnit::createKilometerPerHour(status));
267 measureUnit.adoptInstead(MeasureUnit::createMeterPerSecond(status));
268 measureUnit.adoptInstead(MeasureUnit::createMilePerHour(status));
269 measureUnit.adoptInstead(MeasureUnit::createCelsius(status));
270 measureUnit.adoptInstead(MeasureUnit::createFahrenheit(status));
271 measureUnit.adoptInstead(MeasureUnit::createCubicKilometer(status));
272 measureUnit.adoptInstead(MeasureUnit::createCubicMile(status));
273 measureUnit.adoptInstead(MeasureUnit::createLiter(status));
274 assertSuccess("", status);
275 }
276
TestCompatible54()277 void MeasureFormatTest::TestCompatible54() {
278 UErrorCode status = U_ZERO_ERROR;
279 LocalPointer<MeasureUnit> measureUnit;
280 measureUnit.adoptInstead(MeasureUnit::createGForce(status));
281 measureUnit.adoptInstead(MeasureUnit::createMeterPerSecondSquared(status));
282 measureUnit.adoptInstead(MeasureUnit::createArcMinute(status));
283 measureUnit.adoptInstead(MeasureUnit::createArcSecond(status));
284 measureUnit.adoptInstead(MeasureUnit::createDegree(status));
285 measureUnit.adoptInstead(MeasureUnit::createRadian(status));
286 measureUnit.adoptInstead(MeasureUnit::createAcre(status));
287 measureUnit.adoptInstead(MeasureUnit::createHectare(status));
288 measureUnit.adoptInstead(MeasureUnit::createSquareCentimeter(status));
289 measureUnit.adoptInstead(MeasureUnit::createSquareFoot(status));
290 measureUnit.adoptInstead(MeasureUnit::createSquareInch(status));
291 measureUnit.adoptInstead(MeasureUnit::createSquareKilometer(status));
292 measureUnit.adoptInstead(MeasureUnit::createSquareMeter(status));
293 measureUnit.adoptInstead(MeasureUnit::createSquareMile(status));
294 measureUnit.adoptInstead(MeasureUnit::createSquareYard(status));
295 measureUnit.adoptInstead(MeasureUnit::createLiterPerKilometer(status));
296 measureUnit.adoptInstead(MeasureUnit::createMilePerGallon(status));
297 measureUnit.adoptInstead(MeasureUnit::createBit(status));
298 measureUnit.adoptInstead(MeasureUnit::createByte(status));
299 measureUnit.adoptInstead(MeasureUnit::createGigabit(status));
300 measureUnit.adoptInstead(MeasureUnit::createGigabyte(status));
301 measureUnit.adoptInstead(MeasureUnit::createKilobit(status));
302 measureUnit.adoptInstead(MeasureUnit::createKilobyte(status));
303 measureUnit.adoptInstead(MeasureUnit::createMegabit(status));
304 measureUnit.adoptInstead(MeasureUnit::createMegabyte(status));
305 measureUnit.adoptInstead(MeasureUnit::createTerabit(status));
306 measureUnit.adoptInstead(MeasureUnit::createTerabyte(status));
307 measureUnit.adoptInstead(MeasureUnit::createDay(status));
308 measureUnit.adoptInstead(MeasureUnit::createHour(status));
309 measureUnit.adoptInstead(MeasureUnit::createMicrosecond(status));
310 measureUnit.adoptInstead(MeasureUnit::createMillisecond(status));
311 measureUnit.adoptInstead(MeasureUnit::createMinute(status));
312 measureUnit.adoptInstead(MeasureUnit::createMonth(status));
313 measureUnit.adoptInstead(MeasureUnit::createNanosecond(status));
314 measureUnit.adoptInstead(MeasureUnit::createSecond(status));
315 measureUnit.adoptInstead(MeasureUnit::createWeek(status));
316 measureUnit.adoptInstead(MeasureUnit::createYear(status));
317 measureUnit.adoptInstead(MeasureUnit::createAmpere(status));
318 measureUnit.adoptInstead(MeasureUnit::createMilliampere(status));
319 measureUnit.adoptInstead(MeasureUnit::createOhm(status));
320 measureUnit.adoptInstead(MeasureUnit::createVolt(status));
321 measureUnit.adoptInstead(MeasureUnit::createCalorie(status));
322 measureUnit.adoptInstead(MeasureUnit::createFoodcalorie(status));
323 measureUnit.adoptInstead(MeasureUnit::createJoule(status));
324 measureUnit.adoptInstead(MeasureUnit::createKilocalorie(status));
325 measureUnit.adoptInstead(MeasureUnit::createKilojoule(status));
326 measureUnit.adoptInstead(MeasureUnit::createKilowattHour(status));
327 measureUnit.adoptInstead(MeasureUnit::createGigahertz(status));
328 measureUnit.adoptInstead(MeasureUnit::createHertz(status));
329 measureUnit.adoptInstead(MeasureUnit::createKilohertz(status));
330 measureUnit.adoptInstead(MeasureUnit::createMegahertz(status));
331 measureUnit.adoptInstead(MeasureUnit::createAstronomicalUnit(status));
332 measureUnit.adoptInstead(MeasureUnit::createCentimeter(status));
333 measureUnit.adoptInstead(MeasureUnit::createDecimeter(status));
334 measureUnit.adoptInstead(MeasureUnit::createFathom(status));
335 measureUnit.adoptInstead(MeasureUnit::createFoot(status));
336 measureUnit.adoptInstead(MeasureUnit::createFurlong(status));
337 measureUnit.adoptInstead(MeasureUnit::createInch(status));
338 measureUnit.adoptInstead(MeasureUnit::createKilometer(status));
339 measureUnit.adoptInstead(MeasureUnit::createLightYear(status));
340 measureUnit.adoptInstead(MeasureUnit::createMeter(status));
341 measureUnit.adoptInstead(MeasureUnit::createMicrometer(status));
342 measureUnit.adoptInstead(MeasureUnit::createMile(status));
343 measureUnit.adoptInstead(MeasureUnit::createMillimeter(status));
344 measureUnit.adoptInstead(MeasureUnit::createNanometer(status));
345 measureUnit.adoptInstead(MeasureUnit::createNauticalMile(status));
346 measureUnit.adoptInstead(MeasureUnit::createParsec(status));
347 measureUnit.adoptInstead(MeasureUnit::createPicometer(status));
348 measureUnit.adoptInstead(MeasureUnit::createYard(status));
349 measureUnit.adoptInstead(MeasureUnit::createLux(status));
350 measureUnit.adoptInstead(MeasureUnit::createCarat(status));
351 measureUnit.adoptInstead(MeasureUnit::createGram(status));
352 measureUnit.adoptInstead(MeasureUnit::createKilogram(status));
353 measureUnit.adoptInstead(MeasureUnit::createMetricTon(status));
354 measureUnit.adoptInstead(MeasureUnit::createMicrogram(status));
355 measureUnit.adoptInstead(MeasureUnit::createMilligram(status));
356 measureUnit.adoptInstead(MeasureUnit::createOunce(status));
357 measureUnit.adoptInstead(MeasureUnit::createOunceTroy(status));
358 measureUnit.adoptInstead(MeasureUnit::createPound(status));
359 measureUnit.adoptInstead(MeasureUnit::createStone(status));
360 measureUnit.adoptInstead(MeasureUnit::createTon(status));
361 measureUnit.adoptInstead(MeasureUnit::createGigawatt(status));
362 measureUnit.adoptInstead(MeasureUnit::createHorsepower(status));
363 measureUnit.adoptInstead(MeasureUnit::createKilowatt(status));
364 measureUnit.adoptInstead(MeasureUnit::createMegawatt(status));
365 measureUnit.adoptInstead(MeasureUnit::createMilliwatt(status));
366 measureUnit.adoptInstead(MeasureUnit::createWatt(status));
367 measureUnit.adoptInstead(MeasureUnit::createHectopascal(status));
368 measureUnit.adoptInstead(MeasureUnit::createInchHg(status));
369 measureUnit.adoptInstead(MeasureUnit::createMillibar(status));
370 measureUnit.adoptInstead(MeasureUnit::createMillimeterOfMercury(status));
371 measureUnit.adoptInstead(MeasureUnit::createPoundPerSquareInch(status));
372 measureUnit.adoptInstead(MeasureUnit::createKarat(status));
373 measureUnit.adoptInstead(MeasureUnit::createKilometerPerHour(status));
374 measureUnit.adoptInstead(MeasureUnit::createMeterPerSecond(status));
375 measureUnit.adoptInstead(MeasureUnit::createMilePerHour(status));
376 measureUnit.adoptInstead(MeasureUnit::createCelsius(status));
377 measureUnit.adoptInstead(MeasureUnit::createFahrenheit(status));
378 measureUnit.adoptInstead(MeasureUnit::createKelvin(status));
379 measureUnit.adoptInstead(MeasureUnit::createAcreFoot(status));
380 measureUnit.adoptInstead(MeasureUnit::createBushel(status));
381 measureUnit.adoptInstead(MeasureUnit::createCentiliter(status));
382 measureUnit.adoptInstead(MeasureUnit::createCubicCentimeter(status));
383 measureUnit.adoptInstead(MeasureUnit::createCubicFoot(status));
384 measureUnit.adoptInstead(MeasureUnit::createCubicInch(status));
385 measureUnit.adoptInstead(MeasureUnit::createCubicKilometer(status));
386 measureUnit.adoptInstead(MeasureUnit::createCubicMeter(status));
387 measureUnit.adoptInstead(MeasureUnit::createCubicMile(status));
388 measureUnit.adoptInstead(MeasureUnit::createCubicYard(status));
389 measureUnit.adoptInstead(MeasureUnit::createCup(status));
390 measureUnit.adoptInstead(MeasureUnit::createDeciliter(status));
391 measureUnit.adoptInstead(MeasureUnit::createFluidOunce(status));
392 measureUnit.adoptInstead(MeasureUnit::createGallon(status));
393 measureUnit.adoptInstead(MeasureUnit::createHectoliter(status));
394 measureUnit.adoptInstead(MeasureUnit::createLiter(status));
395 measureUnit.adoptInstead(MeasureUnit::createMegaliter(status));
396 measureUnit.adoptInstead(MeasureUnit::createMilliliter(status));
397 measureUnit.adoptInstead(MeasureUnit::createPint(status));
398 measureUnit.adoptInstead(MeasureUnit::createQuart(status));
399 measureUnit.adoptInstead(MeasureUnit::createTablespoon(status));
400 measureUnit.adoptInstead(MeasureUnit::createTeaspoon(status));
401 assertSuccess("", status);
402 }
403
TestCompatible55()404 void MeasureFormatTest::TestCompatible55() {
405 UErrorCode status = U_ZERO_ERROR;
406 LocalPointer<MeasureUnit> measureUnit;
407 measureUnit.adoptInstead(MeasureUnit::createGForce(status));
408 measureUnit.adoptInstead(MeasureUnit::createMeterPerSecondSquared(status));
409 measureUnit.adoptInstead(MeasureUnit::createArcMinute(status));
410 measureUnit.adoptInstead(MeasureUnit::createArcSecond(status));
411 measureUnit.adoptInstead(MeasureUnit::createDegree(status));
412 measureUnit.adoptInstead(MeasureUnit::createRadian(status));
413 measureUnit.adoptInstead(MeasureUnit::createAcre(status));
414 measureUnit.adoptInstead(MeasureUnit::createHectare(status));
415 measureUnit.adoptInstead(MeasureUnit::createSquareCentimeter(status));
416 measureUnit.adoptInstead(MeasureUnit::createSquareFoot(status));
417 measureUnit.adoptInstead(MeasureUnit::createSquareInch(status));
418 measureUnit.adoptInstead(MeasureUnit::createSquareKilometer(status));
419 measureUnit.adoptInstead(MeasureUnit::createSquareMeter(status));
420 measureUnit.adoptInstead(MeasureUnit::createSquareMile(status));
421 measureUnit.adoptInstead(MeasureUnit::createSquareYard(status));
422 measureUnit.adoptInstead(MeasureUnit::createLiterPerKilometer(status));
423 measureUnit.adoptInstead(MeasureUnit::createMilePerGallon(status));
424 measureUnit.adoptInstead(MeasureUnit::createBit(status));
425 measureUnit.adoptInstead(MeasureUnit::createByte(status));
426 measureUnit.adoptInstead(MeasureUnit::createGigabit(status));
427 measureUnit.adoptInstead(MeasureUnit::createGigabyte(status));
428 measureUnit.adoptInstead(MeasureUnit::createKilobit(status));
429 measureUnit.adoptInstead(MeasureUnit::createKilobyte(status));
430 measureUnit.adoptInstead(MeasureUnit::createMegabit(status));
431 measureUnit.adoptInstead(MeasureUnit::createMegabyte(status));
432 measureUnit.adoptInstead(MeasureUnit::createTerabit(status));
433 measureUnit.adoptInstead(MeasureUnit::createTerabyte(status));
434 measureUnit.adoptInstead(MeasureUnit::createDay(status));
435 measureUnit.adoptInstead(MeasureUnit::createHour(status));
436 measureUnit.adoptInstead(MeasureUnit::createMicrosecond(status));
437 measureUnit.adoptInstead(MeasureUnit::createMillisecond(status));
438 measureUnit.adoptInstead(MeasureUnit::createMinute(status));
439 measureUnit.adoptInstead(MeasureUnit::createMonth(status));
440 measureUnit.adoptInstead(MeasureUnit::createNanosecond(status));
441 measureUnit.adoptInstead(MeasureUnit::createSecond(status));
442 measureUnit.adoptInstead(MeasureUnit::createWeek(status));
443 measureUnit.adoptInstead(MeasureUnit::createYear(status));
444 measureUnit.adoptInstead(MeasureUnit::createAmpere(status));
445 measureUnit.adoptInstead(MeasureUnit::createMilliampere(status));
446 measureUnit.adoptInstead(MeasureUnit::createOhm(status));
447 measureUnit.adoptInstead(MeasureUnit::createVolt(status));
448 measureUnit.adoptInstead(MeasureUnit::createCalorie(status));
449 measureUnit.adoptInstead(MeasureUnit::createFoodcalorie(status));
450 measureUnit.adoptInstead(MeasureUnit::createJoule(status));
451 measureUnit.adoptInstead(MeasureUnit::createKilocalorie(status));
452 measureUnit.adoptInstead(MeasureUnit::createKilojoule(status));
453 measureUnit.adoptInstead(MeasureUnit::createKilowattHour(status));
454 measureUnit.adoptInstead(MeasureUnit::createGigahertz(status));
455 measureUnit.adoptInstead(MeasureUnit::createHertz(status));
456 measureUnit.adoptInstead(MeasureUnit::createKilohertz(status));
457 measureUnit.adoptInstead(MeasureUnit::createMegahertz(status));
458 measureUnit.adoptInstead(MeasureUnit::createAstronomicalUnit(status));
459 measureUnit.adoptInstead(MeasureUnit::createCentimeter(status));
460 measureUnit.adoptInstead(MeasureUnit::createDecimeter(status));
461 measureUnit.adoptInstead(MeasureUnit::createFathom(status));
462 measureUnit.adoptInstead(MeasureUnit::createFoot(status));
463 measureUnit.adoptInstead(MeasureUnit::createFurlong(status));
464 measureUnit.adoptInstead(MeasureUnit::createInch(status));
465 measureUnit.adoptInstead(MeasureUnit::createKilometer(status));
466 measureUnit.adoptInstead(MeasureUnit::createLightYear(status));
467 measureUnit.adoptInstead(MeasureUnit::createMeter(status));
468 measureUnit.adoptInstead(MeasureUnit::createMicrometer(status));
469 measureUnit.adoptInstead(MeasureUnit::createMile(status));
470 measureUnit.adoptInstead(MeasureUnit::createMillimeter(status));
471 measureUnit.adoptInstead(MeasureUnit::createNanometer(status));
472 measureUnit.adoptInstead(MeasureUnit::createNauticalMile(status));
473 measureUnit.adoptInstead(MeasureUnit::createParsec(status));
474 measureUnit.adoptInstead(MeasureUnit::createPicometer(status));
475 measureUnit.adoptInstead(MeasureUnit::createYard(status));
476 measureUnit.adoptInstead(MeasureUnit::createLux(status));
477 measureUnit.adoptInstead(MeasureUnit::createCarat(status));
478 measureUnit.adoptInstead(MeasureUnit::createGram(status));
479 measureUnit.adoptInstead(MeasureUnit::createKilogram(status));
480 measureUnit.adoptInstead(MeasureUnit::createMetricTon(status));
481 measureUnit.adoptInstead(MeasureUnit::createMicrogram(status));
482 measureUnit.adoptInstead(MeasureUnit::createMilligram(status));
483 measureUnit.adoptInstead(MeasureUnit::createOunce(status));
484 measureUnit.adoptInstead(MeasureUnit::createOunceTroy(status));
485 measureUnit.adoptInstead(MeasureUnit::createPound(status));
486 measureUnit.adoptInstead(MeasureUnit::createStone(status));
487 measureUnit.adoptInstead(MeasureUnit::createTon(status));
488 measureUnit.adoptInstead(MeasureUnit::createGigawatt(status));
489 measureUnit.adoptInstead(MeasureUnit::createHorsepower(status));
490 measureUnit.adoptInstead(MeasureUnit::createKilowatt(status));
491 measureUnit.adoptInstead(MeasureUnit::createMegawatt(status));
492 measureUnit.adoptInstead(MeasureUnit::createMilliwatt(status));
493 measureUnit.adoptInstead(MeasureUnit::createWatt(status));
494 measureUnit.adoptInstead(MeasureUnit::createHectopascal(status));
495 measureUnit.adoptInstead(MeasureUnit::createInchHg(status));
496 measureUnit.adoptInstead(MeasureUnit::createMillibar(status));
497 measureUnit.adoptInstead(MeasureUnit::createMillimeterOfMercury(status));
498 measureUnit.adoptInstead(MeasureUnit::createPoundPerSquareInch(status));
499 measureUnit.adoptInstead(MeasureUnit::createKarat(status));
500 measureUnit.adoptInstead(MeasureUnit::createKilometerPerHour(status));
501 measureUnit.adoptInstead(MeasureUnit::createMeterPerSecond(status));
502 measureUnit.adoptInstead(MeasureUnit::createMilePerHour(status));
503 measureUnit.adoptInstead(MeasureUnit::createCelsius(status));
504 measureUnit.adoptInstead(MeasureUnit::createFahrenheit(status));
505 measureUnit.adoptInstead(MeasureUnit::createGenericTemperature(status));
506 measureUnit.adoptInstead(MeasureUnit::createKelvin(status));
507 measureUnit.adoptInstead(MeasureUnit::createAcreFoot(status));
508 measureUnit.adoptInstead(MeasureUnit::createBushel(status));
509 measureUnit.adoptInstead(MeasureUnit::createCentiliter(status));
510 measureUnit.adoptInstead(MeasureUnit::createCubicCentimeter(status));
511 measureUnit.adoptInstead(MeasureUnit::createCubicFoot(status));
512 measureUnit.adoptInstead(MeasureUnit::createCubicInch(status));
513 measureUnit.adoptInstead(MeasureUnit::createCubicKilometer(status));
514 measureUnit.adoptInstead(MeasureUnit::createCubicMeter(status));
515 measureUnit.adoptInstead(MeasureUnit::createCubicMile(status));
516 measureUnit.adoptInstead(MeasureUnit::createCubicYard(status));
517 measureUnit.adoptInstead(MeasureUnit::createCup(status));
518 measureUnit.adoptInstead(MeasureUnit::createDeciliter(status));
519 measureUnit.adoptInstead(MeasureUnit::createFluidOunce(status));
520 measureUnit.adoptInstead(MeasureUnit::createGallon(status));
521 measureUnit.adoptInstead(MeasureUnit::createHectoliter(status));
522 measureUnit.adoptInstead(MeasureUnit::createLiter(status));
523 measureUnit.adoptInstead(MeasureUnit::createMegaliter(status));
524 measureUnit.adoptInstead(MeasureUnit::createMilliliter(status));
525 measureUnit.adoptInstead(MeasureUnit::createPint(status));
526 measureUnit.adoptInstead(MeasureUnit::createQuart(status));
527 measureUnit.adoptInstead(MeasureUnit::createTablespoon(status));
528 measureUnit.adoptInstead(MeasureUnit::createTeaspoon(status));
529 assertSuccess("", status);
530 }
531
TestCompatible56()532 void MeasureFormatTest::TestCompatible56() {
533 UErrorCode status = U_ZERO_ERROR;
534 LocalPointer<MeasureUnit> measureUnit;
535 measureUnit.adoptInstead(MeasureUnit::createGForce(status));
536 measureUnit.adoptInstead(MeasureUnit::createMeterPerSecondSquared(status));
537 measureUnit.adoptInstead(MeasureUnit::createArcMinute(status));
538 measureUnit.adoptInstead(MeasureUnit::createArcSecond(status));
539 measureUnit.adoptInstead(MeasureUnit::createDegree(status));
540 measureUnit.adoptInstead(MeasureUnit::createRadian(status));
541 measureUnit.adoptInstead(MeasureUnit::createRevolutionAngle(status));
542 measureUnit.adoptInstead(MeasureUnit::createAcre(status));
543 measureUnit.adoptInstead(MeasureUnit::createHectare(status));
544 measureUnit.adoptInstead(MeasureUnit::createSquareCentimeter(status));
545 measureUnit.adoptInstead(MeasureUnit::createSquareFoot(status));
546 measureUnit.adoptInstead(MeasureUnit::createSquareInch(status));
547 measureUnit.adoptInstead(MeasureUnit::createSquareKilometer(status));
548 measureUnit.adoptInstead(MeasureUnit::createSquareMeter(status));
549 measureUnit.adoptInstead(MeasureUnit::createSquareMile(status));
550 measureUnit.adoptInstead(MeasureUnit::createSquareYard(status));
551 measureUnit.adoptInstead(MeasureUnit::createLiterPer100Kilometers(status));
552 measureUnit.adoptInstead(MeasureUnit::createLiterPerKilometer(status));
553 measureUnit.adoptInstead(MeasureUnit::createMilePerGallon(status));
554 measureUnit.adoptInstead(MeasureUnit::createBit(status));
555 measureUnit.adoptInstead(MeasureUnit::createByte(status));
556 measureUnit.adoptInstead(MeasureUnit::createGigabit(status));
557 measureUnit.adoptInstead(MeasureUnit::createGigabyte(status));
558 measureUnit.adoptInstead(MeasureUnit::createKilobit(status));
559 measureUnit.adoptInstead(MeasureUnit::createKilobyte(status));
560 measureUnit.adoptInstead(MeasureUnit::createMegabit(status));
561 measureUnit.adoptInstead(MeasureUnit::createMegabyte(status));
562 measureUnit.adoptInstead(MeasureUnit::createTerabit(status));
563 measureUnit.adoptInstead(MeasureUnit::createTerabyte(status));
564 measureUnit.adoptInstead(MeasureUnit::createCentury(status));
565 measureUnit.adoptInstead(MeasureUnit::createDay(status));
566 measureUnit.adoptInstead(MeasureUnit::createHour(status));
567 measureUnit.adoptInstead(MeasureUnit::createMicrosecond(status));
568 measureUnit.adoptInstead(MeasureUnit::createMillisecond(status));
569 measureUnit.adoptInstead(MeasureUnit::createMinute(status));
570 measureUnit.adoptInstead(MeasureUnit::createMonth(status));
571 measureUnit.adoptInstead(MeasureUnit::createNanosecond(status));
572 measureUnit.adoptInstead(MeasureUnit::createSecond(status));
573 measureUnit.adoptInstead(MeasureUnit::createWeek(status));
574 measureUnit.adoptInstead(MeasureUnit::createYear(status));
575 measureUnit.adoptInstead(MeasureUnit::createAmpere(status));
576 measureUnit.adoptInstead(MeasureUnit::createMilliampere(status));
577 measureUnit.adoptInstead(MeasureUnit::createOhm(status));
578 measureUnit.adoptInstead(MeasureUnit::createVolt(status));
579 measureUnit.adoptInstead(MeasureUnit::createCalorie(status));
580 measureUnit.adoptInstead(MeasureUnit::createFoodcalorie(status));
581 measureUnit.adoptInstead(MeasureUnit::createJoule(status));
582 measureUnit.adoptInstead(MeasureUnit::createKilocalorie(status));
583 measureUnit.adoptInstead(MeasureUnit::createKilojoule(status));
584 measureUnit.adoptInstead(MeasureUnit::createKilowattHour(status));
585 measureUnit.adoptInstead(MeasureUnit::createGigahertz(status));
586 measureUnit.adoptInstead(MeasureUnit::createHertz(status));
587 measureUnit.adoptInstead(MeasureUnit::createKilohertz(status));
588 measureUnit.adoptInstead(MeasureUnit::createMegahertz(status));
589 measureUnit.adoptInstead(MeasureUnit::createAstronomicalUnit(status));
590 measureUnit.adoptInstead(MeasureUnit::createCentimeter(status));
591 measureUnit.adoptInstead(MeasureUnit::createDecimeter(status));
592 measureUnit.adoptInstead(MeasureUnit::createFathom(status));
593 measureUnit.adoptInstead(MeasureUnit::createFoot(status));
594 measureUnit.adoptInstead(MeasureUnit::createFurlong(status));
595 measureUnit.adoptInstead(MeasureUnit::createInch(status));
596 measureUnit.adoptInstead(MeasureUnit::createKilometer(status));
597 measureUnit.adoptInstead(MeasureUnit::createLightYear(status));
598 measureUnit.adoptInstead(MeasureUnit::createMeter(status));
599 measureUnit.adoptInstead(MeasureUnit::createMicrometer(status));
600 measureUnit.adoptInstead(MeasureUnit::createMile(status));
601 measureUnit.adoptInstead(MeasureUnit::createMileScandinavian(status));
602 measureUnit.adoptInstead(MeasureUnit::createMillimeter(status));
603 measureUnit.adoptInstead(MeasureUnit::createNanometer(status));
604 measureUnit.adoptInstead(MeasureUnit::createNauticalMile(status));
605 measureUnit.adoptInstead(MeasureUnit::createParsec(status));
606 measureUnit.adoptInstead(MeasureUnit::createPicometer(status));
607 measureUnit.adoptInstead(MeasureUnit::createYard(status));
608 measureUnit.adoptInstead(MeasureUnit::createLux(status));
609 measureUnit.adoptInstead(MeasureUnit::createCarat(status));
610 measureUnit.adoptInstead(MeasureUnit::createGram(status));
611 measureUnit.adoptInstead(MeasureUnit::createKilogram(status));
612 measureUnit.adoptInstead(MeasureUnit::createMetricTon(status));
613 measureUnit.adoptInstead(MeasureUnit::createMicrogram(status));
614 measureUnit.adoptInstead(MeasureUnit::createMilligram(status));
615 measureUnit.adoptInstead(MeasureUnit::createOunce(status));
616 measureUnit.adoptInstead(MeasureUnit::createOunceTroy(status));
617 measureUnit.adoptInstead(MeasureUnit::createPound(status));
618 measureUnit.adoptInstead(MeasureUnit::createStone(status));
619 measureUnit.adoptInstead(MeasureUnit::createTon(status));
620 measureUnit.adoptInstead(MeasureUnit::createGigawatt(status));
621 measureUnit.adoptInstead(MeasureUnit::createHorsepower(status));
622 measureUnit.adoptInstead(MeasureUnit::createKilowatt(status));
623 measureUnit.adoptInstead(MeasureUnit::createMegawatt(status));
624 measureUnit.adoptInstead(MeasureUnit::createMilliwatt(status));
625 measureUnit.adoptInstead(MeasureUnit::createWatt(status));
626 measureUnit.adoptInstead(MeasureUnit::createHectopascal(status));
627 measureUnit.adoptInstead(MeasureUnit::createInchHg(status));
628 measureUnit.adoptInstead(MeasureUnit::createMillibar(status));
629 measureUnit.adoptInstead(MeasureUnit::createMillimeterOfMercury(status));
630 measureUnit.adoptInstead(MeasureUnit::createPoundPerSquareInch(status));
631 measureUnit.adoptInstead(MeasureUnit::createKarat(status));
632 measureUnit.adoptInstead(MeasureUnit::createKilometerPerHour(status));
633 measureUnit.adoptInstead(MeasureUnit::createKnot(status));
634 measureUnit.adoptInstead(MeasureUnit::createMeterPerSecond(status));
635 measureUnit.adoptInstead(MeasureUnit::createMilePerHour(status));
636 measureUnit.adoptInstead(MeasureUnit::createCelsius(status));
637 measureUnit.adoptInstead(MeasureUnit::createFahrenheit(status));
638 measureUnit.adoptInstead(MeasureUnit::createGenericTemperature(status));
639 measureUnit.adoptInstead(MeasureUnit::createKelvin(status));
640 measureUnit.adoptInstead(MeasureUnit::createAcreFoot(status));
641 measureUnit.adoptInstead(MeasureUnit::createBushel(status));
642 measureUnit.adoptInstead(MeasureUnit::createCentiliter(status));
643 measureUnit.adoptInstead(MeasureUnit::createCubicCentimeter(status));
644 measureUnit.adoptInstead(MeasureUnit::createCubicFoot(status));
645 measureUnit.adoptInstead(MeasureUnit::createCubicInch(status));
646 measureUnit.adoptInstead(MeasureUnit::createCubicKilometer(status));
647 measureUnit.adoptInstead(MeasureUnit::createCubicMeter(status));
648 measureUnit.adoptInstead(MeasureUnit::createCubicMile(status));
649 measureUnit.adoptInstead(MeasureUnit::createCubicYard(status));
650 measureUnit.adoptInstead(MeasureUnit::createCup(status));
651 measureUnit.adoptInstead(MeasureUnit::createCupMetric(status));
652 measureUnit.adoptInstead(MeasureUnit::createDeciliter(status));
653 measureUnit.adoptInstead(MeasureUnit::createFluidOunce(status));
654 measureUnit.adoptInstead(MeasureUnit::createGallon(status));
655 measureUnit.adoptInstead(MeasureUnit::createHectoliter(status));
656 measureUnit.adoptInstead(MeasureUnit::createLiter(status));
657 measureUnit.adoptInstead(MeasureUnit::createMegaliter(status));
658 measureUnit.adoptInstead(MeasureUnit::createMilliliter(status));
659 measureUnit.adoptInstead(MeasureUnit::createPint(status));
660 measureUnit.adoptInstead(MeasureUnit::createPintMetric(status));
661 measureUnit.adoptInstead(MeasureUnit::createQuart(status));
662 measureUnit.adoptInstead(MeasureUnit::createTablespoon(status));
663 measureUnit.adoptInstead(MeasureUnit::createTeaspoon(status));
664 assertSuccess("", status);
665 }
666
TestCompatible57()667 void MeasureFormatTest::TestCompatible57() {
668 UErrorCode status = U_ZERO_ERROR;
669 LocalPointer<MeasureUnit> measureUnit;
670 measureUnit.adoptInstead(MeasureUnit::createGForce(status));
671 measureUnit.adoptInstead(MeasureUnit::createMeterPerSecondSquared(status));
672 measureUnit.adoptInstead(MeasureUnit::createArcMinute(status));
673 measureUnit.adoptInstead(MeasureUnit::createArcSecond(status));
674 measureUnit.adoptInstead(MeasureUnit::createDegree(status));
675 measureUnit.adoptInstead(MeasureUnit::createRadian(status));
676 measureUnit.adoptInstead(MeasureUnit::createRevolutionAngle(status));
677 measureUnit.adoptInstead(MeasureUnit::createAcre(status));
678 measureUnit.adoptInstead(MeasureUnit::createHectare(status));
679 measureUnit.adoptInstead(MeasureUnit::createSquareCentimeter(status));
680 measureUnit.adoptInstead(MeasureUnit::createSquareFoot(status));
681 measureUnit.adoptInstead(MeasureUnit::createSquareInch(status));
682 measureUnit.adoptInstead(MeasureUnit::createSquareKilometer(status));
683 measureUnit.adoptInstead(MeasureUnit::createSquareMeter(status));
684 measureUnit.adoptInstead(MeasureUnit::createSquareMile(status));
685 measureUnit.adoptInstead(MeasureUnit::createSquareYard(status));
686 measureUnit.adoptInstead(MeasureUnit::createKarat(status));
687 measureUnit.adoptInstead(MeasureUnit::createMilligramPerDeciliter(status));
688 measureUnit.adoptInstead(MeasureUnit::createMillimolePerLiter(status));
689 measureUnit.adoptInstead(MeasureUnit::createPartPerMillion(status));
690 measureUnit.adoptInstead(MeasureUnit::createLiterPer100Kilometers(status));
691 measureUnit.adoptInstead(MeasureUnit::createLiterPerKilometer(status));
692 measureUnit.adoptInstead(MeasureUnit::createMilePerGallon(status));
693 measureUnit.adoptInstead(MeasureUnit::createMilePerGallonImperial(status));
694 measureUnit.adoptInstead(MeasureUnit::createBit(status));
695 measureUnit.adoptInstead(MeasureUnit::createByte(status));
696 measureUnit.adoptInstead(MeasureUnit::createGigabit(status));
697 measureUnit.adoptInstead(MeasureUnit::createGigabyte(status));
698 measureUnit.adoptInstead(MeasureUnit::createKilobit(status));
699 measureUnit.adoptInstead(MeasureUnit::createKilobyte(status));
700 measureUnit.adoptInstead(MeasureUnit::createMegabit(status));
701 measureUnit.adoptInstead(MeasureUnit::createMegabyte(status));
702 measureUnit.adoptInstead(MeasureUnit::createTerabit(status));
703 measureUnit.adoptInstead(MeasureUnit::createTerabyte(status));
704 measureUnit.adoptInstead(MeasureUnit::createCentury(status));
705 measureUnit.adoptInstead(MeasureUnit::createDay(status));
706 measureUnit.adoptInstead(MeasureUnit::createHour(status));
707 measureUnit.adoptInstead(MeasureUnit::createMicrosecond(status));
708 measureUnit.adoptInstead(MeasureUnit::createMillisecond(status));
709 measureUnit.adoptInstead(MeasureUnit::createMinute(status));
710 measureUnit.adoptInstead(MeasureUnit::createMonth(status));
711 measureUnit.adoptInstead(MeasureUnit::createNanosecond(status));
712 measureUnit.adoptInstead(MeasureUnit::createSecond(status));
713 measureUnit.adoptInstead(MeasureUnit::createWeek(status));
714 measureUnit.adoptInstead(MeasureUnit::createYear(status));
715 measureUnit.adoptInstead(MeasureUnit::createAmpere(status));
716 measureUnit.adoptInstead(MeasureUnit::createMilliampere(status));
717 measureUnit.adoptInstead(MeasureUnit::createOhm(status));
718 measureUnit.adoptInstead(MeasureUnit::createVolt(status));
719 measureUnit.adoptInstead(MeasureUnit::createCalorie(status));
720 measureUnit.adoptInstead(MeasureUnit::createFoodcalorie(status));
721 measureUnit.adoptInstead(MeasureUnit::createJoule(status));
722 measureUnit.adoptInstead(MeasureUnit::createKilocalorie(status));
723 measureUnit.adoptInstead(MeasureUnit::createKilojoule(status));
724 measureUnit.adoptInstead(MeasureUnit::createKilowattHour(status));
725 measureUnit.adoptInstead(MeasureUnit::createGigahertz(status));
726 measureUnit.adoptInstead(MeasureUnit::createHertz(status));
727 measureUnit.adoptInstead(MeasureUnit::createKilohertz(status));
728 measureUnit.adoptInstead(MeasureUnit::createMegahertz(status));
729 measureUnit.adoptInstead(MeasureUnit::createAstronomicalUnit(status));
730 measureUnit.adoptInstead(MeasureUnit::createCentimeter(status));
731 measureUnit.adoptInstead(MeasureUnit::createDecimeter(status));
732 measureUnit.adoptInstead(MeasureUnit::createFathom(status));
733 measureUnit.adoptInstead(MeasureUnit::createFoot(status));
734 measureUnit.adoptInstead(MeasureUnit::createFurlong(status));
735 measureUnit.adoptInstead(MeasureUnit::createInch(status));
736 measureUnit.adoptInstead(MeasureUnit::createKilometer(status));
737 measureUnit.adoptInstead(MeasureUnit::createLightYear(status));
738 measureUnit.adoptInstead(MeasureUnit::createMeter(status));
739 measureUnit.adoptInstead(MeasureUnit::createMicrometer(status));
740 measureUnit.adoptInstead(MeasureUnit::createMile(status));
741 measureUnit.adoptInstead(MeasureUnit::createMileScandinavian(status));
742 measureUnit.adoptInstead(MeasureUnit::createMillimeter(status));
743 measureUnit.adoptInstead(MeasureUnit::createNanometer(status));
744 measureUnit.adoptInstead(MeasureUnit::createNauticalMile(status));
745 measureUnit.adoptInstead(MeasureUnit::createParsec(status));
746 measureUnit.adoptInstead(MeasureUnit::createPicometer(status));
747 measureUnit.adoptInstead(MeasureUnit::createYard(status));
748 measureUnit.adoptInstead(MeasureUnit::createLux(status));
749 measureUnit.adoptInstead(MeasureUnit::createCarat(status));
750 measureUnit.adoptInstead(MeasureUnit::createGram(status));
751 measureUnit.adoptInstead(MeasureUnit::createKilogram(status));
752 measureUnit.adoptInstead(MeasureUnit::createMetricTon(status));
753 measureUnit.adoptInstead(MeasureUnit::createMicrogram(status));
754 measureUnit.adoptInstead(MeasureUnit::createMilligram(status));
755 measureUnit.adoptInstead(MeasureUnit::createOunce(status));
756 measureUnit.adoptInstead(MeasureUnit::createOunceTroy(status));
757 measureUnit.adoptInstead(MeasureUnit::createPound(status));
758 measureUnit.adoptInstead(MeasureUnit::createStone(status));
759 measureUnit.adoptInstead(MeasureUnit::createTon(status));
760 measureUnit.adoptInstead(MeasureUnit::createGigawatt(status));
761 measureUnit.adoptInstead(MeasureUnit::createHorsepower(status));
762 measureUnit.adoptInstead(MeasureUnit::createKilowatt(status));
763 measureUnit.adoptInstead(MeasureUnit::createMegawatt(status));
764 measureUnit.adoptInstead(MeasureUnit::createMilliwatt(status));
765 measureUnit.adoptInstead(MeasureUnit::createWatt(status));
766 measureUnit.adoptInstead(MeasureUnit::createHectopascal(status));
767 measureUnit.adoptInstead(MeasureUnit::createInchHg(status));
768 measureUnit.adoptInstead(MeasureUnit::createMillibar(status));
769 measureUnit.adoptInstead(MeasureUnit::createMillimeterOfMercury(status));
770 measureUnit.adoptInstead(MeasureUnit::createPoundPerSquareInch(status));
771 measureUnit.adoptInstead(MeasureUnit::createKilometerPerHour(status));
772 measureUnit.adoptInstead(MeasureUnit::createKnot(status));
773 measureUnit.adoptInstead(MeasureUnit::createMeterPerSecond(status));
774 measureUnit.adoptInstead(MeasureUnit::createMilePerHour(status));
775 measureUnit.adoptInstead(MeasureUnit::createCelsius(status));
776 measureUnit.adoptInstead(MeasureUnit::createFahrenheit(status));
777 measureUnit.adoptInstead(MeasureUnit::createGenericTemperature(status));
778 measureUnit.adoptInstead(MeasureUnit::createKelvin(status));
779 measureUnit.adoptInstead(MeasureUnit::createAcreFoot(status));
780 measureUnit.adoptInstead(MeasureUnit::createBushel(status));
781 measureUnit.adoptInstead(MeasureUnit::createCentiliter(status));
782 measureUnit.adoptInstead(MeasureUnit::createCubicCentimeter(status));
783 measureUnit.adoptInstead(MeasureUnit::createCubicFoot(status));
784 measureUnit.adoptInstead(MeasureUnit::createCubicInch(status));
785 measureUnit.adoptInstead(MeasureUnit::createCubicKilometer(status));
786 measureUnit.adoptInstead(MeasureUnit::createCubicMeter(status));
787 measureUnit.adoptInstead(MeasureUnit::createCubicMile(status));
788 measureUnit.adoptInstead(MeasureUnit::createCubicYard(status));
789 measureUnit.adoptInstead(MeasureUnit::createCup(status));
790 measureUnit.adoptInstead(MeasureUnit::createCupMetric(status));
791 measureUnit.adoptInstead(MeasureUnit::createDeciliter(status));
792 measureUnit.adoptInstead(MeasureUnit::createFluidOunce(status));
793 measureUnit.adoptInstead(MeasureUnit::createGallon(status));
794 measureUnit.adoptInstead(MeasureUnit::createGallonImperial(status));
795 measureUnit.adoptInstead(MeasureUnit::createHectoliter(status));
796 measureUnit.adoptInstead(MeasureUnit::createLiter(status));
797 measureUnit.adoptInstead(MeasureUnit::createMegaliter(status));
798 measureUnit.adoptInstead(MeasureUnit::createMilliliter(status));
799 measureUnit.adoptInstead(MeasureUnit::createPint(status));
800 measureUnit.adoptInstead(MeasureUnit::createPintMetric(status));
801 measureUnit.adoptInstead(MeasureUnit::createQuart(status));
802 measureUnit.adoptInstead(MeasureUnit::createTablespoon(status));
803 measureUnit.adoptInstead(MeasureUnit::createTeaspoon(status));
804 assertSuccess("", status);
805 }
806
TestCompatible58()807 void MeasureFormatTest::TestCompatible58() {
808 UErrorCode status = U_ZERO_ERROR;
809 LocalPointer<MeasureUnit> measureUnit;
810 measureUnit.adoptInstead(MeasureUnit::createGForce(status));
811 measureUnit.adoptInstead(MeasureUnit::createMeterPerSecondSquared(status));
812 measureUnit.adoptInstead(MeasureUnit::createArcMinute(status));
813 measureUnit.adoptInstead(MeasureUnit::createArcSecond(status));
814 measureUnit.adoptInstead(MeasureUnit::createDegree(status));
815 measureUnit.adoptInstead(MeasureUnit::createRadian(status));
816 measureUnit.adoptInstead(MeasureUnit::createRevolutionAngle(status));
817 measureUnit.adoptInstead(MeasureUnit::createAcre(status));
818 measureUnit.adoptInstead(MeasureUnit::createHectare(status));
819 measureUnit.adoptInstead(MeasureUnit::createSquareCentimeter(status));
820 measureUnit.adoptInstead(MeasureUnit::createSquareFoot(status));
821 measureUnit.adoptInstead(MeasureUnit::createSquareInch(status));
822 measureUnit.adoptInstead(MeasureUnit::createSquareKilometer(status));
823 measureUnit.adoptInstead(MeasureUnit::createSquareMeter(status));
824 measureUnit.adoptInstead(MeasureUnit::createSquareMile(status));
825 measureUnit.adoptInstead(MeasureUnit::createSquareYard(status));
826 measureUnit.adoptInstead(MeasureUnit::createKarat(status));
827 measureUnit.adoptInstead(MeasureUnit::createMilligramPerDeciliter(status));
828 measureUnit.adoptInstead(MeasureUnit::createMillimolePerLiter(status));
829 measureUnit.adoptInstead(MeasureUnit::createPartPerMillion(status));
830 measureUnit.adoptInstead(MeasureUnit::createLiterPer100Kilometers(status));
831 measureUnit.adoptInstead(MeasureUnit::createLiterPerKilometer(status));
832 measureUnit.adoptInstead(MeasureUnit::createMilePerGallon(status));
833 measureUnit.adoptInstead(MeasureUnit::createMilePerGallonImperial(status));
834 // measureUnit.adoptInstead(MeasureUnit::createEast(status));
835 // measureUnit.adoptInstead(MeasureUnit::createNorth(status));
836 // measureUnit.adoptInstead(MeasureUnit::createSouth(status));
837 // measureUnit.adoptInstead(MeasureUnit::createWest(status));
838 measureUnit.adoptInstead(MeasureUnit::createBit(status));
839 measureUnit.adoptInstead(MeasureUnit::createByte(status));
840 measureUnit.adoptInstead(MeasureUnit::createGigabit(status));
841 measureUnit.adoptInstead(MeasureUnit::createGigabyte(status));
842 measureUnit.adoptInstead(MeasureUnit::createKilobit(status));
843 measureUnit.adoptInstead(MeasureUnit::createKilobyte(status));
844 measureUnit.adoptInstead(MeasureUnit::createMegabit(status));
845 measureUnit.adoptInstead(MeasureUnit::createMegabyte(status));
846 measureUnit.adoptInstead(MeasureUnit::createTerabit(status));
847 measureUnit.adoptInstead(MeasureUnit::createTerabyte(status));
848 measureUnit.adoptInstead(MeasureUnit::createCentury(status));
849 measureUnit.adoptInstead(MeasureUnit::createDay(status));
850 measureUnit.adoptInstead(MeasureUnit::createHour(status));
851 measureUnit.adoptInstead(MeasureUnit::createMicrosecond(status));
852 measureUnit.adoptInstead(MeasureUnit::createMillisecond(status));
853 measureUnit.adoptInstead(MeasureUnit::createMinute(status));
854 measureUnit.adoptInstead(MeasureUnit::createMonth(status));
855 measureUnit.adoptInstead(MeasureUnit::createNanosecond(status));
856 measureUnit.adoptInstead(MeasureUnit::createSecond(status));
857 measureUnit.adoptInstead(MeasureUnit::createWeek(status));
858 measureUnit.adoptInstead(MeasureUnit::createYear(status));
859 measureUnit.adoptInstead(MeasureUnit::createAmpere(status));
860 measureUnit.adoptInstead(MeasureUnit::createMilliampere(status));
861 measureUnit.adoptInstead(MeasureUnit::createOhm(status));
862 measureUnit.adoptInstead(MeasureUnit::createVolt(status));
863 measureUnit.adoptInstead(MeasureUnit::createCalorie(status));
864 measureUnit.adoptInstead(MeasureUnit::createFoodcalorie(status));
865 measureUnit.adoptInstead(MeasureUnit::createJoule(status));
866 measureUnit.adoptInstead(MeasureUnit::createKilocalorie(status));
867 measureUnit.adoptInstead(MeasureUnit::createKilojoule(status));
868 measureUnit.adoptInstead(MeasureUnit::createKilowattHour(status));
869 measureUnit.adoptInstead(MeasureUnit::createGigahertz(status));
870 measureUnit.adoptInstead(MeasureUnit::createHertz(status));
871 measureUnit.adoptInstead(MeasureUnit::createKilohertz(status));
872 measureUnit.adoptInstead(MeasureUnit::createMegahertz(status));
873 measureUnit.adoptInstead(MeasureUnit::createAstronomicalUnit(status));
874 measureUnit.adoptInstead(MeasureUnit::createCentimeter(status));
875 measureUnit.adoptInstead(MeasureUnit::createDecimeter(status));
876 measureUnit.adoptInstead(MeasureUnit::createFathom(status));
877 measureUnit.adoptInstead(MeasureUnit::createFoot(status));
878 measureUnit.adoptInstead(MeasureUnit::createFurlong(status));
879 measureUnit.adoptInstead(MeasureUnit::createInch(status));
880 measureUnit.adoptInstead(MeasureUnit::createKilometer(status));
881 measureUnit.adoptInstead(MeasureUnit::createLightYear(status));
882 measureUnit.adoptInstead(MeasureUnit::createMeter(status));
883 measureUnit.adoptInstead(MeasureUnit::createMicrometer(status));
884 measureUnit.adoptInstead(MeasureUnit::createMile(status));
885 measureUnit.adoptInstead(MeasureUnit::createMileScandinavian(status));
886 measureUnit.adoptInstead(MeasureUnit::createMillimeter(status));
887 measureUnit.adoptInstead(MeasureUnit::createNanometer(status));
888 measureUnit.adoptInstead(MeasureUnit::createNauticalMile(status));
889 measureUnit.adoptInstead(MeasureUnit::createParsec(status));
890 measureUnit.adoptInstead(MeasureUnit::createPicometer(status));
891 measureUnit.adoptInstead(MeasureUnit::createYard(status));
892 measureUnit.adoptInstead(MeasureUnit::createLux(status));
893 measureUnit.adoptInstead(MeasureUnit::createCarat(status));
894 measureUnit.adoptInstead(MeasureUnit::createGram(status));
895 measureUnit.adoptInstead(MeasureUnit::createKilogram(status));
896 measureUnit.adoptInstead(MeasureUnit::createMetricTon(status));
897 measureUnit.adoptInstead(MeasureUnit::createMicrogram(status));
898 measureUnit.adoptInstead(MeasureUnit::createMilligram(status));
899 measureUnit.adoptInstead(MeasureUnit::createOunce(status));
900 measureUnit.adoptInstead(MeasureUnit::createOunceTroy(status));
901 measureUnit.adoptInstead(MeasureUnit::createPound(status));
902 measureUnit.adoptInstead(MeasureUnit::createStone(status));
903 measureUnit.adoptInstead(MeasureUnit::createTon(status));
904 measureUnit.adoptInstead(MeasureUnit::createGigawatt(status));
905 measureUnit.adoptInstead(MeasureUnit::createHorsepower(status));
906 measureUnit.adoptInstead(MeasureUnit::createKilowatt(status));
907 measureUnit.adoptInstead(MeasureUnit::createMegawatt(status));
908 measureUnit.adoptInstead(MeasureUnit::createMilliwatt(status));
909 measureUnit.adoptInstead(MeasureUnit::createWatt(status));
910 measureUnit.adoptInstead(MeasureUnit::createHectopascal(status));
911 measureUnit.adoptInstead(MeasureUnit::createInchHg(status));
912 measureUnit.adoptInstead(MeasureUnit::createMillibar(status));
913 measureUnit.adoptInstead(MeasureUnit::createMillimeterOfMercury(status));
914 measureUnit.adoptInstead(MeasureUnit::createPoundPerSquareInch(status));
915 measureUnit.adoptInstead(MeasureUnit::createKilometerPerHour(status));
916 measureUnit.adoptInstead(MeasureUnit::createKnot(status));
917 measureUnit.adoptInstead(MeasureUnit::createMeterPerSecond(status));
918 measureUnit.adoptInstead(MeasureUnit::createMilePerHour(status));
919 measureUnit.adoptInstead(MeasureUnit::createCelsius(status));
920 measureUnit.adoptInstead(MeasureUnit::createFahrenheit(status));
921 measureUnit.adoptInstead(MeasureUnit::createGenericTemperature(status));
922 measureUnit.adoptInstead(MeasureUnit::createKelvin(status));
923 measureUnit.adoptInstead(MeasureUnit::createAcreFoot(status));
924 measureUnit.adoptInstead(MeasureUnit::createBushel(status));
925 measureUnit.adoptInstead(MeasureUnit::createCentiliter(status));
926 measureUnit.adoptInstead(MeasureUnit::createCubicCentimeter(status));
927 measureUnit.adoptInstead(MeasureUnit::createCubicFoot(status));
928 measureUnit.adoptInstead(MeasureUnit::createCubicInch(status));
929 measureUnit.adoptInstead(MeasureUnit::createCubicKilometer(status));
930 measureUnit.adoptInstead(MeasureUnit::createCubicMeter(status));
931 measureUnit.adoptInstead(MeasureUnit::createCubicMile(status));
932 measureUnit.adoptInstead(MeasureUnit::createCubicYard(status));
933 measureUnit.adoptInstead(MeasureUnit::createCup(status));
934 measureUnit.adoptInstead(MeasureUnit::createCupMetric(status));
935 measureUnit.adoptInstead(MeasureUnit::createDeciliter(status));
936 measureUnit.adoptInstead(MeasureUnit::createFluidOunce(status));
937 measureUnit.adoptInstead(MeasureUnit::createGallon(status));
938 measureUnit.adoptInstead(MeasureUnit::createGallonImperial(status));
939 measureUnit.adoptInstead(MeasureUnit::createHectoliter(status));
940 measureUnit.adoptInstead(MeasureUnit::createLiter(status));
941 measureUnit.adoptInstead(MeasureUnit::createMegaliter(status));
942 measureUnit.adoptInstead(MeasureUnit::createMilliliter(status));
943 measureUnit.adoptInstead(MeasureUnit::createPint(status));
944 measureUnit.adoptInstead(MeasureUnit::createPintMetric(status));
945 measureUnit.adoptInstead(MeasureUnit::createQuart(status));
946 measureUnit.adoptInstead(MeasureUnit::createTablespoon(status));
947 measureUnit.adoptInstead(MeasureUnit::createTeaspoon(status));
948 assertSuccess("", status);
949 }
950
TestCompatible59()951 void MeasureFormatTest::TestCompatible59() {
952 UErrorCode status = U_ZERO_ERROR;
953 LocalPointer<MeasureUnit> measureUnit;
954 measureUnit.adoptInstead(MeasureUnit::createGForce(status));
955 measureUnit.adoptInstead(MeasureUnit::createMeterPerSecondSquared(status));
956 measureUnit.adoptInstead(MeasureUnit::createArcMinute(status));
957 measureUnit.adoptInstead(MeasureUnit::createArcSecond(status));
958 measureUnit.adoptInstead(MeasureUnit::createDegree(status));
959 measureUnit.adoptInstead(MeasureUnit::createRadian(status));
960 measureUnit.adoptInstead(MeasureUnit::createRevolutionAngle(status));
961 measureUnit.adoptInstead(MeasureUnit::createAcre(status));
962 measureUnit.adoptInstead(MeasureUnit::createHectare(status));
963 measureUnit.adoptInstead(MeasureUnit::createSquareCentimeter(status));
964 measureUnit.adoptInstead(MeasureUnit::createSquareFoot(status));
965 measureUnit.adoptInstead(MeasureUnit::createSquareInch(status));
966 measureUnit.adoptInstead(MeasureUnit::createSquareKilometer(status));
967 measureUnit.adoptInstead(MeasureUnit::createSquareMeter(status));
968 measureUnit.adoptInstead(MeasureUnit::createSquareMile(status));
969 measureUnit.adoptInstead(MeasureUnit::createSquareYard(status));
970 measureUnit.adoptInstead(MeasureUnit::createKarat(status));
971 measureUnit.adoptInstead(MeasureUnit::createMilligramPerDeciliter(status));
972 measureUnit.adoptInstead(MeasureUnit::createMillimolePerLiter(status));
973 measureUnit.adoptInstead(MeasureUnit::createPartPerMillion(status));
974 measureUnit.adoptInstead(MeasureUnit::createLiterPer100Kilometers(status));
975 measureUnit.adoptInstead(MeasureUnit::createLiterPerKilometer(status));
976 measureUnit.adoptInstead(MeasureUnit::createMilePerGallon(status));
977 measureUnit.adoptInstead(MeasureUnit::createMilePerGallonImperial(status));
978 measureUnit.adoptInstead(MeasureUnit::createBit(status));
979 measureUnit.adoptInstead(MeasureUnit::createByte(status));
980 measureUnit.adoptInstead(MeasureUnit::createGigabit(status));
981 measureUnit.adoptInstead(MeasureUnit::createGigabyte(status));
982 measureUnit.adoptInstead(MeasureUnit::createKilobit(status));
983 measureUnit.adoptInstead(MeasureUnit::createKilobyte(status));
984 measureUnit.adoptInstead(MeasureUnit::createMegabit(status));
985 measureUnit.adoptInstead(MeasureUnit::createMegabyte(status));
986 measureUnit.adoptInstead(MeasureUnit::createTerabit(status));
987 measureUnit.adoptInstead(MeasureUnit::createTerabyte(status));
988 measureUnit.adoptInstead(MeasureUnit::createCentury(status));
989 measureUnit.adoptInstead(MeasureUnit::createDay(status));
990 measureUnit.adoptInstead(MeasureUnit::createHour(status));
991 measureUnit.adoptInstead(MeasureUnit::createMicrosecond(status));
992 measureUnit.adoptInstead(MeasureUnit::createMillisecond(status));
993 measureUnit.adoptInstead(MeasureUnit::createMinute(status));
994 measureUnit.adoptInstead(MeasureUnit::createMonth(status));
995 measureUnit.adoptInstead(MeasureUnit::createNanosecond(status));
996 measureUnit.adoptInstead(MeasureUnit::createSecond(status));
997 measureUnit.adoptInstead(MeasureUnit::createWeek(status));
998 measureUnit.adoptInstead(MeasureUnit::createYear(status));
999 measureUnit.adoptInstead(MeasureUnit::createAmpere(status));
1000 measureUnit.adoptInstead(MeasureUnit::createMilliampere(status));
1001 measureUnit.adoptInstead(MeasureUnit::createOhm(status));
1002 measureUnit.adoptInstead(MeasureUnit::createVolt(status));
1003 measureUnit.adoptInstead(MeasureUnit::createCalorie(status));
1004 measureUnit.adoptInstead(MeasureUnit::createFoodcalorie(status));
1005 measureUnit.adoptInstead(MeasureUnit::createJoule(status));
1006 measureUnit.adoptInstead(MeasureUnit::createKilocalorie(status));
1007 measureUnit.adoptInstead(MeasureUnit::createKilojoule(status));
1008 measureUnit.adoptInstead(MeasureUnit::createKilowattHour(status));
1009 measureUnit.adoptInstead(MeasureUnit::createGigahertz(status));
1010 measureUnit.adoptInstead(MeasureUnit::createHertz(status));
1011 measureUnit.adoptInstead(MeasureUnit::createKilohertz(status));
1012 measureUnit.adoptInstead(MeasureUnit::createMegahertz(status));
1013 measureUnit.adoptInstead(MeasureUnit::createAstronomicalUnit(status));
1014 measureUnit.adoptInstead(MeasureUnit::createCentimeter(status));
1015 measureUnit.adoptInstead(MeasureUnit::createDecimeter(status));
1016 measureUnit.adoptInstead(MeasureUnit::createFathom(status));
1017 measureUnit.adoptInstead(MeasureUnit::createFoot(status));
1018 measureUnit.adoptInstead(MeasureUnit::createFurlong(status));
1019 measureUnit.adoptInstead(MeasureUnit::createInch(status));
1020 measureUnit.adoptInstead(MeasureUnit::createKilometer(status));
1021 measureUnit.adoptInstead(MeasureUnit::createLightYear(status));
1022 measureUnit.adoptInstead(MeasureUnit::createMeter(status));
1023 measureUnit.adoptInstead(MeasureUnit::createMicrometer(status));
1024 measureUnit.adoptInstead(MeasureUnit::createMile(status));
1025 measureUnit.adoptInstead(MeasureUnit::createMileScandinavian(status));
1026 measureUnit.adoptInstead(MeasureUnit::createMillimeter(status));
1027 measureUnit.adoptInstead(MeasureUnit::createNanometer(status));
1028 measureUnit.adoptInstead(MeasureUnit::createNauticalMile(status));
1029 measureUnit.adoptInstead(MeasureUnit::createParsec(status));
1030 measureUnit.adoptInstead(MeasureUnit::createPicometer(status));
1031 measureUnit.adoptInstead(MeasureUnit::createPoint(status));
1032 measureUnit.adoptInstead(MeasureUnit::createYard(status));
1033 measureUnit.adoptInstead(MeasureUnit::createLux(status));
1034 measureUnit.adoptInstead(MeasureUnit::createCarat(status));
1035 measureUnit.adoptInstead(MeasureUnit::createGram(status));
1036 measureUnit.adoptInstead(MeasureUnit::createKilogram(status));
1037 measureUnit.adoptInstead(MeasureUnit::createMetricTon(status));
1038 measureUnit.adoptInstead(MeasureUnit::createMicrogram(status));
1039 measureUnit.adoptInstead(MeasureUnit::createMilligram(status));
1040 measureUnit.adoptInstead(MeasureUnit::createOunce(status));
1041 measureUnit.adoptInstead(MeasureUnit::createOunceTroy(status));
1042 measureUnit.adoptInstead(MeasureUnit::createPound(status));
1043 measureUnit.adoptInstead(MeasureUnit::createStone(status));
1044 measureUnit.adoptInstead(MeasureUnit::createTon(status));
1045 measureUnit.adoptInstead(MeasureUnit::createGigawatt(status));
1046 measureUnit.adoptInstead(MeasureUnit::createHorsepower(status));
1047 measureUnit.adoptInstead(MeasureUnit::createKilowatt(status));
1048 measureUnit.adoptInstead(MeasureUnit::createMegawatt(status));
1049 measureUnit.adoptInstead(MeasureUnit::createMilliwatt(status));
1050 measureUnit.adoptInstead(MeasureUnit::createWatt(status));
1051 measureUnit.adoptInstead(MeasureUnit::createHectopascal(status));
1052 measureUnit.adoptInstead(MeasureUnit::createInchHg(status));
1053 measureUnit.adoptInstead(MeasureUnit::createMillibar(status));
1054 measureUnit.adoptInstead(MeasureUnit::createMillimeterOfMercury(status));
1055 measureUnit.adoptInstead(MeasureUnit::createPoundPerSquareInch(status));
1056 measureUnit.adoptInstead(MeasureUnit::createKilometerPerHour(status));
1057 measureUnit.adoptInstead(MeasureUnit::createKnot(status));
1058 measureUnit.adoptInstead(MeasureUnit::createMeterPerSecond(status));
1059 measureUnit.adoptInstead(MeasureUnit::createMilePerHour(status));
1060 measureUnit.adoptInstead(MeasureUnit::createCelsius(status));
1061 measureUnit.adoptInstead(MeasureUnit::createFahrenheit(status));
1062 measureUnit.adoptInstead(MeasureUnit::createGenericTemperature(status));
1063 measureUnit.adoptInstead(MeasureUnit::createKelvin(status));
1064 measureUnit.adoptInstead(MeasureUnit::createAcreFoot(status));
1065 measureUnit.adoptInstead(MeasureUnit::createBushel(status));
1066 measureUnit.adoptInstead(MeasureUnit::createCentiliter(status));
1067 measureUnit.adoptInstead(MeasureUnit::createCubicCentimeter(status));
1068 measureUnit.adoptInstead(MeasureUnit::createCubicFoot(status));
1069 measureUnit.adoptInstead(MeasureUnit::createCubicInch(status));
1070 measureUnit.adoptInstead(MeasureUnit::createCubicKilometer(status));
1071 measureUnit.adoptInstead(MeasureUnit::createCubicMeter(status));
1072 measureUnit.adoptInstead(MeasureUnit::createCubicMile(status));
1073 measureUnit.adoptInstead(MeasureUnit::createCubicYard(status));
1074 measureUnit.adoptInstead(MeasureUnit::createCup(status));
1075 measureUnit.adoptInstead(MeasureUnit::createCupMetric(status));
1076 measureUnit.adoptInstead(MeasureUnit::createDeciliter(status));
1077 measureUnit.adoptInstead(MeasureUnit::createFluidOunce(status));
1078 measureUnit.adoptInstead(MeasureUnit::createGallon(status));
1079 measureUnit.adoptInstead(MeasureUnit::createGallonImperial(status));
1080 measureUnit.adoptInstead(MeasureUnit::createHectoliter(status));
1081 measureUnit.adoptInstead(MeasureUnit::createLiter(status));
1082 measureUnit.adoptInstead(MeasureUnit::createMegaliter(status));
1083 measureUnit.adoptInstead(MeasureUnit::createMilliliter(status));
1084 measureUnit.adoptInstead(MeasureUnit::createPint(status));
1085 measureUnit.adoptInstead(MeasureUnit::createPintMetric(status));
1086 measureUnit.adoptInstead(MeasureUnit::createQuart(status));
1087 measureUnit.adoptInstead(MeasureUnit::createTablespoon(status));
1088 measureUnit.adoptInstead(MeasureUnit::createTeaspoon(status));
1089 assertSuccess("", status);
1090 }
1091
1092 // Note that TestCompatible60(), TestCompatible61(), TestCompatible62()
1093 // would be the same as TestCompatible59(), no need to add them.
1094
TestCompatible63()1095 void MeasureFormatTest::TestCompatible63() {
1096 UErrorCode status = U_ZERO_ERROR;
1097 LocalPointer<MeasureUnit> measureUnit;
1098 measureUnit.adoptInstead(MeasureUnit::createGForce(status));
1099 measureUnit.adoptInstead(MeasureUnit::createMeterPerSecondSquared(status));
1100 measureUnit.adoptInstead(MeasureUnit::createArcMinute(status));
1101 measureUnit.adoptInstead(MeasureUnit::createArcSecond(status));
1102 measureUnit.adoptInstead(MeasureUnit::createDegree(status));
1103 measureUnit.adoptInstead(MeasureUnit::createRadian(status));
1104 measureUnit.adoptInstead(MeasureUnit::createRevolutionAngle(status));
1105 measureUnit.adoptInstead(MeasureUnit::createAcre(status));
1106 measureUnit.adoptInstead(MeasureUnit::createHectare(status));
1107 measureUnit.adoptInstead(MeasureUnit::createSquareCentimeter(status));
1108 measureUnit.adoptInstead(MeasureUnit::createSquareFoot(status));
1109 measureUnit.adoptInstead(MeasureUnit::createSquareInch(status));
1110 measureUnit.adoptInstead(MeasureUnit::createSquareKilometer(status));
1111 measureUnit.adoptInstead(MeasureUnit::createSquareMeter(status));
1112 measureUnit.adoptInstead(MeasureUnit::createSquareMile(status));
1113 measureUnit.adoptInstead(MeasureUnit::createSquareYard(status));
1114 measureUnit.adoptInstead(MeasureUnit::createKarat(status));
1115 measureUnit.adoptInstead(MeasureUnit::createMilligramPerDeciliter(status));
1116 measureUnit.adoptInstead(MeasureUnit::createMillimolePerLiter(status));
1117 measureUnit.adoptInstead(MeasureUnit::createPartPerMillion(status));
1118 measureUnit.adoptInstead(MeasureUnit::createPercent(status));
1119 measureUnit.adoptInstead(MeasureUnit::createPermille(status));
1120 measureUnit.adoptInstead(MeasureUnit::createLiterPer100Kilometers(status));
1121 measureUnit.adoptInstead(MeasureUnit::createLiterPerKilometer(status));
1122 measureUnit.adoptInstead(MeasureUnit::createMilePerGallon(status));
1123 measureUnit.adoptInstead(MeasureUnit::createMilePerGallonImperial(status));
1124 measureUnit.adoptInstead(MeasureUnit::createBit(status));
1125 measureUnit.adoptInstead(MeasureUnit::createByte(status));
1126 measureUnit.adoptInstead(MeasureUnit::createGigabit(status));
1127 measureUnit.adoptInstead(MeasureUnit::createGigabyte(status));
1128 measureUnit.adoptInstead(MeasureUnit::createKilobit(status));
1129 measureUnit.adoptInstead(MeasureUnit::createKilobyte(status));
1130 measureUnit.adoptInstead(MeasureUnit::createMegabit(status));
1131 measureUnit.adoptInstead(MeasureUnit::createMegabyte(status));
1132 measureUnit.adoptInstead(MeasureUnit::createPetabyte(status));
1133 measureUnit.adoptInstead(MeasureUnit::createTerabit(status));
1134 measureUnit.adoptInstead(MeasureUnit::createTerabyte(status));
1135 measureUnit.adoptInstead(MeasureUnit::createCentury(status));
1136 measureUnit.adoptInstead(MeasureUnit::createDay(status));
1137 measureUnit.adoptInstead(MeasureUnit::createHour(status));
1138 measureUnit.adoptInstead(MeasureUnit::createMicrosecond(status));
1139 measureUnit.adoptInstead(MeasureUnit::createMillisecond(status));
1140 measureUnit.adoptInstead(MeasureUnit::createMinute(status));
1141 measureUnit.adoptInstead(MeasureUnit::createMonth(status));
1142 measureUnit.adoptInstead(MeasureUnit::createNanosecond(status));
1143 measureUnit.adoptInstead(MeasureUnit::createSecond(status));
1144 measureUnit.adoptInstead(MeasureUnit::createWeek(status));
1145 measureUnit.adoptInstead(MeasureUnit::createYear(status));
1146 measureUnit.adoptInstead(MeasureUnit::createAmpere(status));
1147 measureUnit.adoptInstead(MeasureUnit::createMilliampere(status));
1148 measureUnit.adoptInstead(MeasureUnit::createOhm(status));
1149 measureUnit.adoptInstead(MeasureUnit::createVolt(status));
1150 measureUnit.adoptInstead(MeasureUnit::createCalorie(status));
1151 measureUnit.adoptInstead(MeasureUnit::createFoodcalorie(status));
1152 measureUnit.adoptInstead(MeasureUnit::createJoule(status));
1153 measureUnit.adoptInstead(MeasureUnit::createKilocalorie(status));
1154 measureUnit.adoptInstead(MeasureUnit::createKilojoule(status));
1155 measureUnit.adoptInstead(MeasureUnit::createKilowattHour(status));
1156 measureUnit.adoptInstead(MeasureUnit::createGigahertz(status));
1157 measureUnit.adoptInstead(MeasureUnit::createHertz(status));
1158 measureUnit.adoptInstead(MeasureUnit::createKilohertz(status));
1159 measureUnit.adoptInstead(MeasureUnit::createMegahertz(status));
1160 measureUnit.adoptInstead(MeasureUnit::createAstronomicalUnit(status));
1161 measureUnit.adoptInstead(MeasureUnit::createCentimeter(status));
1162 measureUnit.adoptInstead(MeasureUnit::createDecimeter(status));
1163 measureUnit.adoptInstead(MeasureUnit::createFathom(status));
1164 measureUnit.adoptInstead(MeasureUnit::createFoot(status));
1165 measureUnit.adoptInstead(MeasureUnit::createFurlong(status));
1166 measureUnit.adoptInstead(MeasureUnit::createInch(status));
1167 measureUnit.adoptInstead(MeasureUnit::createKilometer(status));
1168 measureUnit.adoptInstead(MeasureUnit::createLightYear(status));
1169 measureUnit.adoptInstead(MeasureUnit::createMeter(status));
1170 measureUnit.adoptInstead(MeasureUnit::createMicrometer(status));
1171 measureUnit.adoptInstead(MeasureUnit::createMile(status));
1172 measureUnit.adoptInstead(MeasureUnit::createMileScandinavian(status));
1173 measureUnit.adoptInstead(MeasureUnit::createMillimeter(status));
1174 measureUnit.adoptInstead(MeasureUnit::createNanometer(status));
1175 measureUnit.adoptInstead(MeasureUnit::createNauticalMile(status));
1176 measureUnit.adoptInstead(MeasureUnit::createParsec(status));
1177 measureUnit.adoptInstead(MeasureUnit::createPicometer(status));
1178 measureUnit.adoptInstead(MeasureUnit::createPoint(status));
1179 measureUnit.adoptInstead(MeasureUnit::createYard(status));
1180 measureUnit.adoptInstead(MeasureUnit::createLux(status));
1181 measureUnit.adoptInstead(MeasureUnit::createCarat(status));
1182 measureUnit.adoptInstead(MeasureUnit::createGram(status));
1183 measureUnit.adoptInstead(MeasureUnit::createKilogram(status));
1184 measureUnit.adoptInstead(MeasureUnit::createMetricTon(status));
1185 measureUnit.adoptInstead(MeasureUnit::createMicrogram(status));
1186 measureUnit.adoptInstead(MeasureUnit::createMilligram(status));
1187 measureUnit.adoptInstead(MeasureUnit::createOunce(status));
1188 measureUnit.adoptInstead(MeasureUnit::createOunceTroy(status));
1189 measureUnit.adoptInstead(MeasureUnit::createPound(status));
1190 measureUnit.adoptInstead(MeasureUnit::createStone(status));
1191 measureUnit.adoptInstead(MeasureUnit::createTon(status));
1192 measureUnit.adoptInstead(MeasureUnit::createGigawatt(status));
1193 measureUnit.adoptInstead(MeasureUnit::createHorsepower(status));
1194 measureUnit.adoptInstead(MeasureUnit::createKilowatt(status));
1195 measureUnit.adoptInstead(MeasureUnit::createMegawatt(status));
1196 measureUnit.adoptInstead(MeasureUnit::createMilliwatt(status));
1197 measureUnit.adoptInstead(MeasureUnit::createWatt(status));
1198 measureUnit.adoptInstead(MeasureUnit::createAtmosphere(status));
1199 measureUnit.adoptInstead(MeasureUnit::createHectopascal(status));
1200 measureUnit.adoptInstead(MeasureUnit::createInchHg(status));
1201 measureUnit.adoptInstead(MeasureUnit::createMillibar(status));
1202 measureUnit.adoptInstead(MeasureUnit::createMillimeterOfMercury(status));
1203 measureUnit.adoptInstead(MeasureUnit::createPoundPerSquareInch(status));
1204 measureUnit.adoptInstead(MeasureUnit::createKilometerPerHour(status));
1205 measureUnit.adoptInstead(MeasureUnit::createKnot(status));
1206 measureUnit.adoptInstead(MeasureUnit::createMeterPerSecond(status));
1207 measureUnit.adoptInstead(MeasureUnit::createMilePerHour(status));
1208 measureUnit.adoptInstead(MeasureUnit::createCelsius(status));
1209 measureUnit.adoptInstead(MeasureUnit::createFahrenheit(status));
1210 measureUnit.adoptInstead(MeasureUnit::createGenericTemperature(status));
1211 measureUnit.adoptInstead(MeasureUnit::createKelvin(status));
1212 measureUnit.adoptInstead(MeasureUnit::createAcreFoot(status));
1213 measureUnit.adoptInstead(MeasureUnit::createBushel(status));
1214 measureUnit.adoptInstead(MeasureUnit::createCentiliter(status));
1215 measureUnit.adoptInstead(MeasureUnit::createCubicCentimeter(status));
1216 measureUnit.adoptInstead(MeasureUnit::createCubicFoot(status));
1217 measureUnit.adoptInstead(MeasureUnit::createCubicInch(status));
1218 measureUnit.adoptInstead(MeasureUnit::createCubicKilometer(status));
1219 measureUnit.adoptInstead(MeasureUnit::createCubicMeter(status));
1220 measureUnit.adoptInstead(MeasureUnit::createCubicMile(status));
1221 measureUnit.adoptInstead(MeasureUnit::createCubicYard(status));
1222 measureUnit.adoptInstead(MeasureUnit::createCup(status));
1223 measureUnit.adoptInstead(MeasureUnit::createCupMetric(status));
1224 measureUnit.adoptInstead(MeasureUnit::createDeciliter(status));
1225 measureUnit.adoptInstead(MeasureUnit::createFluidOunce(status));
1226 measureUnit.adoptInstead(MeasureUnit::createGallon(status));
1227 measureUnit.adoptInstead(MeasureUnit::createGallonImperial(status));
1228 measureUnit.adoptInstead(MeasureUnit::createHectoliter(status));
1229 measureUnit.adoptInstead(MeasureUnit::createLiter(status));
1230 measureUnit.adoptInstead(MeasureUnit::createMegaliter(status));
1231 measureUnit.adoptInstead(MeasureUnit::createMilliliter(status));
1232 measureUnit.adoptInstead(MeasureUnit::createPint(status));
1233 measureUnit.adoptInstead(MeasureUnit::createPintMetric(status));
1234 measureUnit.adoptInstead(MeasureUnit::createQuart(status));
1235 measureUnit.adoptInstead(MeasureUnit::createTablespoon(status));
1236 measureUnit.adoptInstead(MeasureUnit::createTeaspoon(status));
1237 assertSuccess("", status);
1238 }
1239
TestCompatible64()1240 void MeasureFormatTest::TestCompatible64() {
1241 UErrorCode status = U_ZERO_ERROR;
1242 LocalPointer<MeasureUnit> measureUnit;
1243 MeasureUnit measureUnitValue;
1244 measureUnit.adoptInstead(MeasureUnit::createGForce(status));
1245 measureUnitValue = MeasureUnit::getGForce();
1246 measureUnit.adoptInstead(MeasureUnit::createMeterPerSecondSquared(status));
1247 measureUnitValue = MeasureUnit::getMeterPerSecondSquared();
1248 measureUnit.adoptInstead(MeasureUnit::createArcMinute(status));
1249 measureUnitValue = MeasureUnit::getArcMinute();
1250 measureUnit.adoptInstead(MeasureUnit::createArcSecond(status));
1251 measureUnitValue = MeasureUnit::getArcSecond();
1252 measureUnit.adoptInstead(MeasureUnit::createDegree(status));
1253 measureUnitValue = MeasureUnit::getDegree();
1254 measureUnit.adoptInstead(MeasureUnit::createRadian(status));
1255 measureUnitValue = MeasureUnit::getRadian();
1256 measureUnit.adoptInstead(MeasureUnit::createRevolutionAngle(status));
1257 measureUnitValue = MeasureUnit::getRevolutionAngle();
1258 measureUnit.adoptInstead(MeasureUnit::createAcre(status));
1259 measureUnitValue = MeasureUnit::getAcre();
1260 measureUnit.adoptInstead(MeasureUnit::createDunam(status));
1261 measureUnitValue = MeasureUnit::getDunam();
1262 measureUnit.adoptInstead(MeasureUnit::createHectare(status));
1263 measureUnitValue = MeasureUnit::getHectare();
1264 measureUnit.adoptInstead(MeasureUnit::createSquareCentimeter(status));
1265 measureUnitValue = MeasureUnit::getSquareCentimeter();
1266 measureUnit.adoptInstead(MeasureUnit::createSquareFoot(status));
1267 measureUnitValue = MeasureUnit::getSquareFoot();
1268 measureUnit.adoptInstead(MeasureUnit::createSquareInch(status));
1269 measureUnitValue = MeasureUnit::getSquareInch();
1270 measureUnit.adoptInstead(MeasureUnit::createSquareKilometer(status));
1271 measureUnitValue = MeasureUnit::getSquareKilometer();
1272 measureUnit.adoptInstead(MeasureUnit::createSquareMeter(status));
1273 measureUnitValue = MeasureUnit::getSquareMeter();
1274 measureUnit.adoptInstead(MeasureUnit::createSquareMile(status));
1275 measureUnitValue = MeasureUnit::getSquareMile();
1276 measureUnit.adoptInstead(MeasureUnit::createSquareYard(status));
1277 measureUnitValue = MeasureUnit::getSquareYard();
1278 measureUnit.adoptInstead(MeasureUnit::createKarat(status));
1279 measureUnitValue = MeasureUnit::getKarat();
1280 measureUnit.adoptInstead(MeasureUnit::createMilligramPerDeciliter(status));
1281 measureUnitValue = MeasureUnit::getMilligramPerDeciliter();
1282 measureUnit.adoptInstead(MeasureUnit::createMillimolePerLiter(status));
1283 measureUnitValue = MeasureUnit::getMillimolePerLiter();
1284 measureUnit.adoptInstead(MeasureUnit::createMole(status));
1285 measureUnitValue = MeasureUnit::getMole();
1286 measureUnit.adoptInstead(MeasureUnit::createPartPerMillion(status));
1287 measureUnitValue = MeasureUnit::getPartPerMillion();
1288 measureUnit.adoptInstead(MeasureUnit::createPercent(status));
1289 measureUnitValue = MeasureUnit::getPercent();
1290 measureUnit.adoptInstead(MeasureUnit::createPermille(status));
1291 measureUnitValue = MeasureUnit::getPermille();
1292 measureUnit.adoptInstead(MeasureUnit::createPermyriad(status));
1293 measureUnitValue = MeasureUnit::getPermyriad();
1294 measureUnit.adoptInstead(MeasureUnit::createLiterPer100Kilometers(status));
1295 measureUnitValue = MeasureUnit::getLiterPer100Kilometers();
1296 measureUnit.adoptInstead(MeasureUnit::createLiterPerKilometer(status));
1297 measureUnitValue = MeasureUnit::getLiterPerKilometer();
1298 measureUnit.adoptInstead(MeasureUnit::createMilePerGallon(status));
1299 measureUnitValue = MeasureUnit::getMilePerGallon();
1300 measureUnit.adoptInstead(MeasureUnit::createMilePerGallonImperial(status));
1301 measureUnitValue = MeasureUnit::getMilePerGallonImperial();
1302 measureUnit.adoptInstead(MeasureUnit::createBit(status));
1303 measureUnitValue = MeasureUnit::getBit();
1304 measureUnit.adoptInstead(MeasureUnit::createByte(status));
1305 measureUnitValue = MeasureUnit::getByte();
1306 measureUnit.adoptInstead(MeasureUnit::createGigabit(status));
1307 measureUnitValue = MeasureUnit::getGigabit();
1308 measureUnit.adoptInstead(MeasureUnit::createGigabyte(status));
1309 measureUnitValue = MeasureUnit::getGigabyte();
1310 measureUnit.adoptInstead(MeasureUnit::createKilobit(status));
1311 measureUnitValue = MeasureUnit::getKilobit();
1312 measureUnit.adoptInstead(MeasureUnit::createKilobyte(status));
1313 measureUnitValue = MeasureUnit::getKilobyte();
1314 measureUnit.adoptInstead(MeasureUnit::createMegabit(status));
1315 measureUnitValue = MeasureUnit::getMegabit();
1316 measureUnit.adoptInstead(MeasureUnit::createMegabyte(status));
1317 measureUnitValue = MeasureUnit::getMegabyte();
1318 measureUnit.adoptInstead(MeasureUnit::createPetabyte(status));
1319 measureUnitValue = MeasureUnit::getPetabyte();
1320 measureUnit.adoptInstead(MeasureUnit::createTerabit(status));
1321 measureUnitValue = MeasureUnit::getTerabit();
1322 measureUnit.adoptInstead(MeasureUnit::createTerabyte(status));
1323 measureUnitValue = MeasureUnit::getTerabyte();
1324 measureUnit.adoptInstead(MeasureUnit::createCentury(status));
1325 measureUnitValue = MeasureUnit::getCentury();
1326 measureUnit.adoptInstead(MeasureUnit::createDay(status));
1327 measureUnitValue = MeasureUnit::getDay();
1328 measureUnit.adoptInstead(MeasureUnit::createDayPerson(status));
1329 measureUnitValue = MeasureUnit::getDayPerson();
1330 measureUnit.adoptInstead(MeasureUnit::createHour(status));
1331 measureUnitValue = MeasureUnit::getHour();
1332 measureUnit.adoptInstead(MeasureUnit::createMicrosecond(status));
1333 measureUnitValue = MeasureUnit::getMicrosecond();
1334 measureUnit.adoptInstead(MeasureUnit::createMillisecond(status));
1335 measureUnitValue = MeasureUnit::getMillisecond();
1336 measureUnit.adoptInstead(MeasureUnit::createMinute(status));
1337 measureUnitValue = MeasureUnit::getMinute();
1338 measureUnit.adoptInstead(MeasureUnit::createMonth(status));
1339 measureUnitValue = MeasureUnit::getMonth();
1340 measureUnit.adoptInstead(MeasureUnit::createMonthPerson(status));
1341 measureUnitValue = MeasureUnit::getMonthPerson();
1342 measureUnit.adoptInstead(MeasureUnit::createNanosecond(status));
1343 measureUnitValue = MeasureUnit::getNanosecond();
1344 measureUnit.adoptInstead(MeasureUnit::createSecond(status));
1345 measureUnitValue = MeasureUnit::getSecond();
1346 measureUnit.adoptInstead(MeasureUnit::createWeek(status));
1347 measureUnitValue = MeasureUnit::getWeek();
1348 measureUnit.adoptInstead(MeasureUnit::createWeekPerson(status));
1349 measureUnitValue = MeasureUnit::getWeekPerson();
1350 measureUnit.adoptInstead(MeasureUnit::createYear(status));
1351 measureUnitValue = MeasureUnit::getYear();
1352 measureUnit.adoptInstead(MeasureUnit::createYearPerson(status));
1353 measureUnitValue = MeasureUnit::getYearPerson();
1354 measureUnit.adoptInstead(MeasureUnit::createAmpere(status));
1355 measureUnitValue = MeasureUnit::getAmpere();
1356 measureUnit.adoptInstead(MeasureUnit::createMilliampere(status));
1357 measureUnitValue = MeasureUnit::getMilliampere();
1358 measureUnit.adoptInstead(MeasureUnit::createOhm(status));
1359 measureUnitValue = MeasureUnit::getOhm();
1360 measureUnit.adoptInstead(MeasureUnit::createVolt(status));
1361 measureUnitValue = MeasureUnit::getVolt();
1362 measureUnit.adoptInstead(MeasureUnit::createBritishThermalUnit(status));
1363 measureUnitValue = MeasureUnit::getBritishThermalUnit();
1364 measureUnit.adoptInstead(MeasureUnit::createCalorie(status));
1365 measureUnitValue = MeasureUnit::getCalorie();
1366 measureUnit.adoptInstead(MeasureUnit::createElectronvolt(status));
1367 measureUnitValue = MeasureUnit::getElectronvolt();
1368 measureUnit.adoptInstead(MeasureUnit::createFoodcalorie(status));
1369 measureUnitValue = MeasureUnit::getFoodcalorie();
1370 measureUnit.adoptInstead(MeasureUnit::createJoule(status));
1371 measureUnitValue = MeasureUnit::getJoule();
1372 measureUnit.adoptInstead(MeasureUnit::createKilocalorie(status));
1373 measureUnitValue = MeasureUnit::getKilocalorie();
1374 measureUnit.adoptInstead(MeasureUnit::createKilojoule(status));
1375 measureUnitValue = MeasureUnit::getKilojoule();
1376 measureUnit.adoptInstead(MeasureUnit::createKilowattHour(status));
1377 measureUnitValue = MeasureUnit::getKilowattHour();
1378 measureUnit.adoptInstead(MeasureUnit::createNewton(status));
1379 measureUnitValue = MeasureUnit::getNewton();
1380 measureUnit.adoptInstead(MeasureUnit::createPoundForce(status));
1381 measureUnitValue = MeasureUnit::getPoundForce();
1382 measureUnit.adoptInstead(MeasureUnit::createGigahertz(status));
1383 measureUnitValue = MeasureUnit::getGigahertz();
1384 measureUnit.adoptInstead(MeasureUnit::createHertz(status));
1385 measureUnitValue = MeasureUnit::getHertz();
1386 measureUnit.adoptInstead(MeasureUnit::createKilohertz(status));
1387 measureUnitValue = MeasureUnit::getKilohertz();
1388 measureUnit.adoptInstead(MeasureUnit::createMegahertz(status));
1389 measureUnitValue = MeasureUnit::getMegahertz();
1390 measureUnit.adoptInstead(MeasureUnit::createAstronomicalUnit(status));
1391 measureUnitValue = MeasureUnit::getAstronomicalUnit();
1392 measureUnit.adoptInstead(MeasureUnit::createCentimeter(status));
1393 measureUnitValue = MeasureUnit::getCentimeter();
1394 measureUnit.adoptInstead(MeasureUnit::createDecimeter(status));
1395 measureUnitValue = MeasureUnit::getDecimeter();
1396 measureUnit.adoptInstead(MeasureUnit::createFathom(status));
1397 measureUnitValue = MeasureUnit::getFathom();
1398 measureUnit.adoptInstead(MeasureUnit::createFoot(status));
1399 measureUnitValue = MeasureUnit::getFoot();
1400 measureUnit.adoptInstead(MeasureUnit::createFurlong(status));
1401 measureUnitValue = MeasureUnit::getFurlong();
1402 measureUnit.adoptInstead(MeasureUnit::createInch(status));
1403 measureUnitValue = MeasureUnit::getInch();
1404 measureUnit.adoptInstead(MeasureUnit::createKilometer(status));
1405 measureUnitValue = MeasureUnit::getKilometer();
1406 measureUnit.adoptInstead(MeasureUnit::createLightYear(status));
1407 measureUnitValue = MeasureUnit::getLightYear();
1408 measureUnit.adoptInstead(MeasureUnit::createMeter(status));
1409 measureUnitValue = MeasureUnit::getMeter();
1410 measureUnit.adoptInstead(MeasureUnit::createMicrometer(status));
1411 measureUnitValue = MeasureUnit::getMicrometer();
1412 measureUnit.adoptInstead(MeasureUnit::createMile(status));
1413 measureUnitValue = MeasureUnit::getMile();
1414 measureUnit.adoptInstead(MeasureUnit::createMileScandinavian(status));
1415 measureUnitValue = MeasureUnit::getMileScandinavian();
1416 measureUnit.adoptInstead(MeasureUnit::createMillimeter(status));
1417 measureUnitValue = MeasureUnit::getMillimeter();
1418 measureUnit.adoptInstead(MeasureUnit::createNanometer(status));
1419 measureUnitValue = MeasureUnit::getNanometer();
1420 measureUnit.adoptInstead(MeasureUnit::createNauticalMile(status));
1421 measureUnitValue = MeasureUnit::getNauticalMile();
1422 measureUnit.adoptInstead(MeasureUnit::createParsec(status));
1423 measureUnitValue = MeasureUnit::getParsec();
1424 measureUnit.adoptInstead(MeasureUnit::createPicometer(status));
1425 measureUnitValue = MeasureUnit::getPicometer();
1426 measureUnit.adoptInstead(MeasureUnit::createPoint(status));
1427 measureUnitValue = MeasureUnit::getPoint();
1428 measureUnit.adoptInstead(MeasureUnit::createSolarRadius(status));
1429 measureUnitValue = MeasureUnit::getSolarRadius();
1430 measureUnit.adoptInstead(MeasureUnit::createYard(status));
1431 measureUnitValue = MeasureUnit::getYard();
1432 measureUnit.adoptInstead(MeasureUnit::createLux(status));
1433 measureUnitValue = MeasureUnit::getLux();
1434 measureUnit.adoptInstead(MeasureUnit::createSolarLuminosity(status));
1435 measureUnitValue = MeasureUnit::getSolarLuminosity();
1436 measureUnit.adoptInstead(MeasureUnit::createCarat(status));
1437 measureUnitValue = MeasureUnit::getCarat();
1438 measureUnit.adoptInstead(MeasureUnit::createDalton(status));
1439 measureUnitValue = MeasureUnit::getDalton();
1440 measureUnit.adoptInstead(MeasureUnit::createEarthMass(status));
1441 measureUnitValue = MeasureUnit::getEarthMass();
1442 measureUnit.adoptInstead(MeasureUnit::createGram(status));
1443 measureUnitValue = MeasureUnit::getGram();
1444 measureUnit.adoptInstead(MeasureUnit::createKilogram(status));
1445 measureUnitValue = MeasureUnit::getKilogram();
1446 measureUnit.adoptInstead(MeasureUnit::createMetricTon(status));
1447 measureUnitValue = MeasureUnit::getMetricTon();
1448 measureUnit.adoptInstead(MeasureUnit::createMicrogram(status));
1449 measureUnitValue = MeasureUnit::getMicrogram();
1450 measureUnit.adoptInstead(MeasureUnit::createMilligram(status));
1451 measureUnitValue = MeasureUnit::getMilligram();
1452 measureUnit.adoptInstead(MeasureUnit::createOunce(status));
1453 measureUnitValue = MeasureUnit::getOunce();
1454 measureUnit.adoptInstead(MeasureUnit::createOunceTroy(status));
1455 measureUnitValue = MeasureUnit::getOunceTroy();
1456 measureUnit.adoptInstead(MeasureUnit::createPound(status));
1457 measureUnitValue = MeasureUnit::getPound();
1458 measureUnit.adoptInstead(MeasureUnit::createSolarMass(status));
1459 measureUnitValue = MeasureUnit::getSolarMass();
1460 measureUnit.adoptInstead(MeasureUnit::createStone(status));
1461 measureUnitValue = MeasureUnit::getStone();
1462 measureUnit.adoptInstead(MeasureUnit::createTon(status));
1463 measureUnitValue = MeasureUnit::getTon();
1464 measureUnit.adoptInstead(MeasureUnit::createGigawatt(status));
1465 measureUnitValue = MeasureUnit::getGigawatt();
1466 measureUnit.adoptInstead(MeasureUnit::createHorsepower(status));
1467 measureUnitValue = MeasureUnit::getHorsepower();
1468 measureUnit.adoptInstead(MeasureUnit::createKilowatt(status));
1469 measureUnitValue = MeasureUnit::getKilowatt();
1470 measureUnit.adoptInstead(MeasureUnit::createMegawatt(status));
1471 measureUnitValue = MeasureUnit::getMegawatt();
1472 measureUnit.adoptInstead(MeasureUnit::createMilliwatt(status));
1473 measureUnitValue = MeasureUnit::getMilliwatt();
1474 measureUnit.adoptInstead(MeasureUnit::createWatt(status));
1475 measureUnitValue = MeasureUnit::getWatt();
1476 measureUnit.adoptInstead(MeasureUnit::createAtmosphere(status));
1477 measureUnitValue = MeasureUnit::getAtmosphere();
1478 measureUnit.adoptInstead(MeasureUnit::createHectopascal(status));
1479 measureUnitValue = MeasureUnit::getHectopascal();
1480 measureUnit.adoptInstead(MeasureUnit::createInchHg(status));
1481 measureUnitValue = MeasureUnit::getInchHg();
1482 measureUnit.adoptInstead(MeasureUnit::createKilopascal(status));
1483 measureUnitValue = MeasureUnit::getKilopascal();
1484 measureUnit.adoptInstead(MeasureUnit::createMegapascal(status));
1485 measureUnitValue = MeasureUnit::getMegapascal();
1486 measureUnit.adoptInstead(MeasureUnit::createMillibar(status));
1487 measureUnitValue = MeasureUnit::getMillibar();
1488 measureUnit.adoptInstead(MeasureUnit::createMillimeterOfMercury(status));
1489 measureUnitValue = MeasureUnit::getMillimeterOfMercury();
1490 measureUnit.adoptInstead(MeasureUnit::createPoundPerSquareInch(status));
1491 measureUnitValue = MeasureUnit::getPoundPerSquareInch();
1492 measureUnit.adoptInstead(MeasureUnit::createKilometerPerHour(status));
1493 measureUnitValue = MeasureUnit::getKilometerPerHour();
1494 measureUnit.adoptInstead(MeasureUnit::createKnot(status));
1495 measureUnitValue = MeasureUnit::getKnot();
1496 measureUnit.adoptInstead(MeasureUnit::createMeterPerSecond(status));
1497 measureUnitValue = MeasureUnit::getMeterPerSecond();
1498 measureUnit.adoptInstead(MeasureUnit::createMilePerHour(status));
1499 measureUnitValue = MeasureUnit::getMilePerHour();
1500 measureUnit.adoptInstead(MeasureUnit::createCelsius(status));
1501 measureUnitValue = MeasureUnit::getCelsius();
1502 measureUnit.adoptInstead(MeasureUnit::createFahrenheit(status));
1503 measureUnitValue = MeasureUnit::getFahrenheit();
1504 measureUnit.adoptInstead(MeasureUnit::createGenericTemperature(status));
1505 measureUnitValue = MeasureUnit::getGenericTemperature();
1506 measureUnit.adoptInstead(MeasureUnit::createKelvin(status));
1507 measureUnitValue = MeasureUnit::getKelvin();
1508 measureUnit.adoptInstead(MeasureUnit::createNewtonMeter(status));
1509 measureUnitValue = MeasureUnit::getNewtonMeter();
1510 measureUnit.adoptInstead(MeasureUnit::createPoundFoot(status));
1511 measureUnitValue = MeasureUnit::getPoundFoot();
1512 measureUnit.adoptInstead(MeasureUnit::createAcreFoot(status));
1513 measureUnitValue = MeasureUnit::getAcreFoot();
1514 measureUnit.adoptInstead(MeasureUnit::createBarrel(status));
1515 measureUnitValue = MeasureUnit::getBarrel();
1516 measureUnit.adoptInstead(MeasureUnit::createBushel(status));
1517 measureUnitValue = MeasureUnit::getBushel();
1518 measureUnit.adoptInstead(MeasureUnit::createCentiliter(status));
1519 measureUnitValue = MeasureUnit::getCentiliter();
1520 measureUnit.adoptInstead(MeasureUnit::createCubicCentimeter(status));
1521 measureUnitValue = MeasureUnit::getCubicCentimeter();
1522 measureUnit.adoptInstead(MeasureUnit::createCubicFoot(status));
1523 measureUnitValue = MeasureUnit::getCubicFoot();
1524 measureUnit.adoptInstead(MeasureUnit::createCubicInch(status));
1525 measureUnitValue = MeasureUnit::getCubicInch();
1526 measureUnit.adoptInstead(MeasureUnit::createCubicKilometer(status));
1527 measureUnitValue = MeasureUnit::getCubicKilometer();
1528 measureUnit.adoptInstead(MeasureUnit::createCubicMeter(status));
1529 measureUnitValue = MeasureUnit::getCubicMeter();
1530 measureUnit.adoptInstead(MeasureUnit::createCubicMile(status));
1531 measureUnitValue = MeasureUnit::getCubicMile();
1532 measureUnit.adoptInstead(MeasureUnit::createCubicYard(status));
1533 measureUnitValue = MeasureUnit::getCubicYard();
1534 measureUnit.adoptInstead(MeasureUnit::createCup(status));
1535 measureUnitValue = MeasureUnit::getCup();
1536 measureUnit.adoptInstead(MeasureUnit::createCupMetric(status));
1537 measureUnitValue = MeasureUnit::getCupMetric();
1538 measureUnit.adoptInstead(MeasureUnit::createDeciliter(status));
1539 measureUnitValue = MeasureUnit::getDeciliter();
1540 measureUnit.adoptInstead(MeasureUnit::createFluidOunce(status));
1541 measureUnitValue = MeasureUnit::getFluidOunce();
1542 measureUnit.adoptInstead(MeasureUnit::createFluidOunceImperial(status));
1543 measureUnitValue = MeasureUnit::getFluidOunceImperial();
1544 measureUnit.adoptInstead(MeasureUnit::createGallon(status));
1545 measureUnitValue = MeasureUnit::getGallon();
1546 measureUnit.adoptInstead(MeasureUnit::createGallonImperial(status));
1547 measureUnitValue = MeasureUnit::getGallonImperial();
1548 measureUnit.adoptInstead(MeasureUnit::createHectoliter(status));
1549 measureUnitValue = MeasureUnit::getHectoliter();
1550 measureUnit.adoptInstead(MeasureUnit::createLiter(status));
1551 measureUnitValue = MeasureUnit::getLiter();
1552 measureUnit.adoptInstead(MeasureUnit::createMegaliter(status));
1553 measureUnitValue = MeasureUnit::getMegaliter();
1554 measureUnit.adoptInstead(MeasureUnit::createMilliliter(status));
1555 measureUnitValue = MeasureUnit::getMilliliter();
1556 measureUnit.adoptInstead(MeasureUnit::createPint(status));
1557 measureUnitValue = MeasureUnit::getPint();
1558 measureUnit.adoptInstead(MeasureUnit::createPintMetric(status));
1559 measureUnitValue = MeasureUnit::getPintMetric();
1560 measureUnit.adoptInstead(MeasureUnit::createQuart(status));
1561 measureUnitValue = MeasureUnit::getQuart();
1562 measureUnit.adoptInstead(MeasureUnit::createTablespoon(status));
1563 measureUnitValue = MeasureUnit::getTablespoon();
1564 measureUnit.adoptInstead(MeasureUnit::createTeaspoon(status));
1565 measureUnitValue = MeasureUnit::getTeaspoon();
1566 assertSuccess("", status);
1567 }
1568
TestCompatible65()1569 void MeasureFormatTest::TestCompatible65() {
1570 UErrorCode status = U_ZERO_ERROR;
1571 LocalPointer<MeasureUnit> measureUnit;
1572 MeasureUnit measureUnitValue;
1573 measureUnit.adoptInstead(MeasureUnit::createGForce(status));
1574 measureUnitValue = MeasureUnit::getGForce();
1575 measureUnit.adoptInstead(MeasureUnit::createMeterPerSecondSquared(status));
1576 measureUnitValue = MeasureUnit::getMeterPerSecondSquared();
1577 measureUnit.adoptInstead(MeasureUnit::createArcMinute(status));
1578 measureUnitValue = MeasureUnit::getArcMinute();
1579 measureUnit.adoptInstead(MeasureUnit::createArcSecond(status));
1580 measureUnitValue = MeasureUnit::getArcSecond();
1581 measureUnit.adoptInstead(MeasureUnit::createDegree(status));
1582 measureUnitValue = MeasureUnit::getDegree();
1583 measureUnit.adoptInstead(MeasureUnit::createRadian(status));
1584 measureUnitValue = MeasureUnit::getRadian();
1585 measureUnit.adoptInstead(MeasureUnit::createRevolutionAngle(status));
1586 measureUnitValue = MeasureUnit::getRevolutionAngle();
1587 measureUnit.adoptInstead(MeasureUnit::createAcre(status));
1588 measureUnitValue = MeasureUnit::getAcre();
1589 measureUnit.adoptInstead(MeasureUnit::createDunam(status));
1590 measureUnitValue = MeasureUnit::getDunam();
1591 measureUnit.adoptInstead(MeasureUnit::createHectare(status));
1592 measureUnitValue = MeasureUnit::getHectare();
1593 measureUnit.adoptInstead(MeasureUnit::createSquareCentimeter(status));
1594 measureUnitValue = MeasureUnit::getSquareCentimeter();
1595 measureUnit.adoptInstead(MeasureUnit::createSquareFoot(status));
1596 measureUnitValue = MeasureUnit::getSquareFoot();
1597 measureUnit.adoptInstead(MeasureUnit::createSquareInch(status));
1598 measureUnitValue = MeasureUnit::getSquareInch();
1599 measureUnit.adoptInstead(MeasureUnit::createSquareKilometer(status));
1600 measureUnitValue = MeasureUnit::getSquareKilometer();
1601 measureUnit.adoptInstead(MeasureUnit::createSquareMeter(status));
1602 measureUnitValue = MeasureUnit::getSquareMeter();
1603 measureUnit.adoptInstead(MeasureUnit::createSquareMile(status));
1604 measureUnitValue = MeasureUnit::getSquareMile();
1605 measureUnit.adoptInstead(MeasureUnit::createSquareYard(status));
1606 measureUnitValue = MeasureUnit::getSquareYard();
1607 measureUnit.adoptInstead(MeasureUnit::createKarat(status));
1608 measureUnitValue = MeasureUnit::getKarat();
1609 measureUnit.adoptInstead(MeasureUnit::createMilligramPerDeciliter(status));
1610 measureUnitValue = MeasureUnit::getMilligramPerDeciliter();
1611 measureUnit.adoptInstead(MeasureUnit::createMillimolePerLiter(status));
1612 measureUnitValue = MeasureUnit::getMillimolePerLiter();
1613 measureUnit.adoptInstead(MeasureUnit::createMole(status));
1614 measureUnitValue = MeasureUnit::getMole();
1615 measureUnit.adoptInstead(MeasureUnit::createPartPerMillion(status));
1616 measureUnitValue = MeasureUnit::getPartPerMillion();
1617 measureUnit.adoptInstead(MeasureUnit::createPercent(status));
1618 measureUnitValue = MeasureUnit::getPercent();
1619 measureUnit.adoptInstead(MeasureUnit::createPermille(status));
1620 measureUnitValue = MeasureUnit::getPermille();
1621 measureUnit.adoptInstead(MeasureUnit::createPermyriad(status));
1622 measureUnitValue = MeasureUnit::getPermyriad();
1623 measureUnit.adoptInstead(MeasureUnit::createLiterPer100Kilometers(status));
1624 measureUnitValue = MeasureUnit::getLiterPer100Kilometers();
1625 measureUnit.adoptInstead(MeasureUnit::createLiterPerKilometer(status));
1626 measureUnitValue = MeasureUnit::getLiterPerKilometer();
1627 measureUnit.adoptInstead(MeasureUnit::createMilePerGallon(status));
1628 measureUnitValue = MeasureUnit::getMilePerGallon();
1629 measureUnit.adoptInstead(MeasureUnit::createMilePerGallonImperial(status));
1630 measureUnitValue = MeasureUnit::getMilePerGallonImperial();
1631 measureUnit.adoptInstead(MeasureUnit::createBit(status));
1632 measureUnitValue = MeasureUnit::getBit();
1633 measureUnit.adoptInstead(MeasureUnit::createByte(status));
1634 measureUnitValue = MeasureUnit::getByte();
1635 measureUnit.adoptInstead(MeasureUnit::createGigabit(status));
1636 measureUnitValue = MeasureUnit::getGigabit();
1637 measureUnit.adoptInstead(MeasureUnit::createGigabyte(status));
1638 measureUnitValue = MeasureUnit::getGigabyte();
1639 measureUnit.adoptInstead(MeasureUnit::createKilobit(status));
1640 measureUnitValue = MeasureUnit::getKilobit();
1641 measureUnit.adoptInstead(MeasureUnit::createKilobyte(status));
1642 measureUnitValue = MeasureUnit::getKilobyte();
1643 measureUnit.adoptInstead(MeasureUnit::createMegabit(status));
1644 measureUnitValue = MeasureUnit::getMegabit();
1645 measureUnit.adoptInstead(MeasureUnit::createMegabyte(status));
1646 measureUnitValue = MeasureUnit::getMegabyte();
1647 measureUnit.adoptInstead(MeasureUnit::createPetabyte(status));
1648 measureUnitValue = MeasureUnit::getPetabyte();
1649 measureUnit.adoptInstead(MeasureUnit::createTerabit(status));
1650 measureUnitValue = MeasureUnit::getTerabit();
1651 measureUnit.adoptInstead(MeasureUnit::createTerabyte(status));
1652 measureUnitValue = MeasureUnit::getTerabyte();
1653 measureUnit.adoptInstead(MeasureUnit::createCentury(status));
1654 measureUnitValue = MeasureUnit::getCentury();
1655 measureUnit.adoptInstead(MeasureUnit::createDay(status));
1656 measureUnitValue = MeasureUnit::getDay();
1657 measureUnit.adoptInstead(MeasureUnit::createDayPerson(status));
1658 measureUnitValue = MeasureUnit::getDayPerson();
1659 measureUnit.adoptInstead(MeasureUnit::createDecade(status));
1660 measureUnitValue = MeasureUnit::getDecade();
1661 measureUnit.adoptInstead(MeasureUnit::createHour(status));
1662 measureUnitValue = MeasureUnit::getHour();
1663 measureUnit.adoptInstead(MeasureUnit::createMicrosecond(status));
1664 measureUnitValue = MeasureUnit::getMicrosecond();
1665 measureUnit.adoptInstead(MeasureUnit::createMillisecond(status));
1666 measureUnitValue = MeasureUnit::getMillisecond();
1667 measureUnit.adoptInstead(MeasureUnit::createMinute(status));
1668 measureUnitValue = MeasureUnit::getMinute();
1669 measureUnit.adoptInstead(MeasureUnit::createMonth(status));
1670 measureUnitValue = MeasureUnit::getMonth();
1671 measureUnit.adoptInstead(MeasureUnit::createMonthPerson(status));
1672 measureUnitValue = MeasureUnit::getMonthPerson();
1673 measureUnit.adoptInstead(MeasureUnit::createNanosecond(status));
1674 measureUnitValue = MeasureUnit::getNanosecond();
1675 measureUnit.adoptInstead(MeasureUnit::createSecond(status));
1676 measureUnitValue = MeasureUnit::getSecond();
1677 measureUnit.adoptInstead(MeasureUnit::createWeek(status));
1678 measureUnitValue = MeasureUnit::getWeek();
1679 measureUnit.adoptInstead(MeasureUnit::createWeekPerson(status));
1680 measureUnitValue = MeasureUnit::getWeekPerson();
1681 measureUnit.adoptInstead(MeasureUnit::createYear(status));
1682 measureUnitValue = MeasureUnit::getYear();
1683 measureUnit.adoptInstead(MeasureUnit::createYearPerson(status));
1684 measureUnitValue = MeasureUnit::getYearPerson();
1685 measureUnit.adoptInstead(MeasureUnit::createAmpere(status));
1686 measureUnitValue = MeasureUnit::getAmpere();
1687 measureUnit.adoptInstead(MeasureUnit::createMilliampere(status));
1688 measureUnitValue = MeasureUnit::getMilliampere();
1689 measureUnit.adoptInstead(MeasureUnit::createOhm(status));
1690 measureUnitValue = MeasureUnit::getOhm();
1691 measureUnit.adoptInstead(MeasureUnit::createVolt(status));
1692 measureUnitValue = MeasureUnit::getVolt();
1693 measureUnit.adoptInstead(MeasureUnit::createBritishThermalUnit(status));
1694 measureUnitValue = MeasureUnit::getBritishThermalUnit();
1695 measureUnit.adoptInstead(MeasureUnit::createCalorie(status));
1696 measureUnitValue = MeasureUnit::getCalorie();
1697 measureUnit.adoptInstead(MeasureUnit::createElectronvolt(status));
1698 measureUnitValue = MeasureUnit::getElectronvolt();
1699 measureUnit.adoptInstead(MeasureUnit::createFoodcalorie(status));
1700 measureUnitValue = MeasureUnit::getFoodcalorie();
1701 measureUnit.adoptInstead(MeasureUnit::createJoule(status));
1702 measureUnitValue = MeasureUnit::getJoule();
1703 measureUnit.adoptInstead(MeasureUnit::createKilocalorie(status));
1704 measureUnitValue = MeasureUnit::getKilocalorie();
1705 measureUnit.adoptInstead(MeasureUnit::createKilojoule(status));
1706 measureUnitValue = MeasureUnit::getKilojoule();
1707 measureUnit.adoptInstead(MeasureUnit::createKilowattHour(status));
1708 measureUnitValue = MeasureUnit::getKilowattHour();
1709 measureUnit.adoptInstead(MeasureUnit::createThermUs(status));
1710 measureUnitValue = MeasureUnit::getThermUs();
1711 measureUnit.adoptInstead(MeasureUnit::createNewton(status));
1712 measureUnitValue = MeasureUnit::getNewton();
1713 measureUnit.adoptInstead(MeasureUnit::createPoundForce(status));
1714 measureUnitValue = MeasureUnit::getPoundForce();
1715 measureUnit.adoptInstead(MeasureUnit::createGigahertz(status));
1716 measureUnitValue = MeasureUnit::getGigahertz();
1717 measureUnit.adoptInstead(MeasureUnit::createHertz(status));
1718 measureUnitValue = MeasureUnit::getHertz();
1719 measureUnit.adoptInstead(MeasureUnit::createKilohertz(status));
1720 measureUnitValue = MeasureUnit::getKilohertz();
1721 measureUnit.adoptInstead(MeasureUnit::createMegahertz(status));
1722 measureUnitValue = MeasureUnit::getMegahertz();
1723 measureUnit.adoptInstead(MeasureUnit::createDotPerCentimeter(status));
1724 measureUnitValue = MeasureUnit::getDotPerCentimeter();
1725 measureUnit.adoptInstead(MeasureUnit::createDotPerInch(status));
1726 measureUnitValue = MeasureUnit::getDotPerInch();
1727 measureUnit.adoptInstead(MeasureUnit::createEm(status));
1728 measureUnitValue = MeasureUnit::getEm();
1729 measureUnit.adoptInstead(MeasureUnit::createMegapixel(status));
1730 measureUnitValue = MeasureUnit::getMegapixel();
1731 measureUnit.adoptInstead(MeasureUnit::createPixel(status));
1732 measureUnitValue = MeasureUnit::getPixel();
1733 measureUnit.adoptInstead(MeasureUnit::createPixelPerCentimeter(status));
1734 measureUnitValue = MeasureUnit::getPixelPerCentimeter();
1735 measureUnit.adoptInstead(MeasureUnit::createPixelPerInch(status));
1736 measureUnitValue = MeasureUnit::getPixelPerInch();
1737 measureUnit.adoptInstead(MeasureUnit::createAstronomicalUnit(status));
1738 measureUnitValue = MeasureUnit::getAstronomicalUnit();
1739 measureUnit.adoptInstead(MeasureUnit::createCentimeter(status));
1740 measureUnitValue = MeasureUnit::getCentimeter();
1741 measureUnit.adoptInstead(MeasureUnit::createDecimeter(status));
1742 measureUnitValue = MeasureUnit::getDecimeter();
1743 measureUnit.adoptInstead(MeasureUnit::createFathom(status));
1744 measureUnitValue = MeasureUnit::getFathom();
1745 measureUnit.adoptInstead(MeasureUnit::createFoot(status));
1746 measureUnitValue = MeasureUnit::getFoot();
1747 measureUnit.adoptInstead(MeasureUnit::createFurlong(status));
1748 measureUnitValue = MeasureUnit::getFurlong();
1749 measureUnit.adoptInstead(MeasureUnit::createInch(status));
1750 measureUnitValue = MeasureUnit::getInch();
1751 measureUnit.adoptInstead(MeasureUnit::createKilometer(status));
1752 measureUnitValue = MeasureUnit::getKilometer();
1753 measureUnit.adoptInstead(MeasureUnit::createLightYear(status));
1754 measureUnitValue = MeasureUnit::getLightYear();
1755 measureUnit.adoptInstead(MeasureUnit::createMeter(status));
1756 measureUnitValue = MeasureUnit::getMeter();
1757 measureUnit.adoptInstead(MeasureUnit::createMicrometer(status));
1758 measureUnitValue = MeasureUnit::getMicrometer();
1759 measureUnit.adoptInstead(MeasureUnit::createMile(status));
1760 measureUnitValue = MeasureUnit::getMile();
1761 measureUnit.adoptInstead(MeasureUnit::createMileScandinavian(status));
1762 measureUnitValue = MeasureUnit::getMileScandinavian();
1763 measureUnit.adoptInstead(MeasureUnit::createMillimeter(status));
1764 measureUnitValue = MeasureUnit::getMillimeter();
1765 measureUnit.adoptInstead(MeasureUnit::createNanometer(status));
1766 measureUnitValue = MeasureUnit::getNanometer();
1767 measureUnit.adoptInstead(MeasureUnit::createNauticalMile(status));
1768 measureUnitValue = MeasureUnit::getNauticalMile();
1769 measureUnit.adoptInstead(MeasureUnit::createParsec(status));
1770 measureUnitValue = MeasureUnit::getParsec();
1771 measureUnit.adoptInstead(MeasureUnit::createPicometer(status));
1772 measureUnitValue = MeasureUnit::getPicometer();
1773 measureUnit.adoptInstead(MeasureUnit::createPoint(status));
1774 measureUnitValue = MeasureUnit::getPoint();
1775 measureUnit.adoptInstead(MeasureUnit::createSolarRadius(status));
1776 measureUnitValue = MeasureUnit::getSolarRadius();
1777 measureUnit.adoptInstead(MeasureUnit::createYard(status));
1778 measureUnitValue = MeasureUnit::getYard();
1779 measureUnit.adoptInstead(MeasureUnit::createLux(status));
1780 measureUnitValue = MeasureUnit::getLux();
1781 measureUnit.adoptInstead(MeasureUnit::createSolarLuminosity(status));
1782 measureUnitValue = MeasureUnit::getSolarLuminosity();
1783 measureUnit.adoptInstead(MeasureUnit::createCarat(status));
1784 measureUnitValue = MeasureUnit::getCarat();
1785 measureUnit.adoptInstead(MeasureUnit::createDalton(status));
1786 measureUnitValue = MeasureUnit::getDalton();
1787 measureUnit.adoptInstead(MeasureUnit::createEarthMass(status));
1788 measureUnitValue = MeasureUnit::getEarthMass();
1789 measureUnit.adoptInstead(MeasureUnit::createGram(status));
1790 measureUnitValue = MeasureUnit::getGram();
1791 measureUnit.adoptInstead(MeasureUnit::createKilogram(status));
1792 measureUnitValue = MeasureUnit::getKilogram();
1793 measureUnit.adoptInstead(MeasureUnit::createMetricTon(status));
1794 measureUnitValue = MeasureUnit::getMetricTon();
1795 measureUnit.adoptInstead(MeasureUnit::createMicrogram(status));
1796 measureUnitValue = MeasureUnit::getMicrogram();
1797 measureUnit.adoptInstead(MeasureUnit::createMilligram(status));
1798 measureUnitValue = MeasureUnit::getMilligram();
1799 measureUnit.adoptInstead(MeasureUnit::createOunce(status));
1800 measureUnitValue = MeasureUnit::getOunce();
1801 measureUnit.adoptInstead(MeasureUnit::createOunceTroy(status));
1802 measureUnitValue = MeasureUnit::getOunceTroy();
1803 measureUnit.adoptInstead(MeasureUnit::createPound(status));
1804 measureUnitValue = MeasureUnit::getPound();
1805 measureUnit.adoptInstead(MeasureUnit::createSolarMass(status));
1806 measureUnitValue = MeasureUnit::getSolarMass();
1807 measureUnit.adoptInstead(MeasureUnit::createStone(status));
1808 measureUnitValue = MeasureUnit::getStone();
1809 measureUnit.adoptInstead(MeasureUnit::createTon(status));
1810 measureUnitValue = MeasureUnit::getTon();
1811 measureUnit.adoptInstead(MeasureUnit::createGigawatt(status));
1812 measureUnitValue = MeasureUnit::getGigawatt();
1813 measureUnit.adoptInstead(MeasureUnit::createHorsepower(status));
1814 measureUnitValue = MeasureUnit::getHorsepower();
1815 measureUnit.adoptInstead(MeasureUnit::createKilowatt(status));
1816 measureUnitValue = MeasureUnit::getKilowatt();
1817 measureUnit.adoptInstead(MeasureUnit::createMegawatt(status));
1818 measureUnitValue = MeasureUnit::getMegawatt();
1819 measureUnit.adoptInstead(MeasureUnit::createMilliwatt(status));
1820 measureUnitValue = MeasureUnit::getMilliwatt();
1821 measureUnit.adoptInstead(MeasureUnit::createWatt(status));
1822 measureUnitValue = MeasureUnit::getWatt();
1823 measureUnit.adoptInstead(MeasureUnit::createAtmosphere(status));
1824 measureUnitValue = MeasureUnit::getAtmosphere();
1825 measureUnit.adoptInstead(MeasureUnit::createBar(status));
1826 measureUnitValue = MeasureUnit::getBar();
1827 measureUnit.adoptInstead(MeasureUnit::createHectopascal(status));
1828 measureUnitValue = MeasureUnit::getHectopascal();
1829 measureUnit.adoptInstead(MeasureUnit::createInchHg(status));
1830 measureUnitValue = MeasureUnit::getInchHg();
1831 measureUnit.adoptInstead(MeasureUnit::createKilopascal(status));
1832 measureUnitValue = MeasureUnit::getKilopascal();
1833 measureUnit.adoptInstead(MeasureUnit::createMegapascal(status));
1834 measureUnitValue = MeasureUnit::getMegapascal();
1835 measureUnit.adoptInstead(MeasureUnit::createMillibar(status));
1836 measureUnitValue = MeasureUnit::getMillibar();
1837 measureUnit.adoptInstead(MeasureUnit::createMillimeterOfMercury(status));
1838 measureUnitValue = MeasureUnit::getMillimeterOfMercury();
1839 measureUnit.adoptInstead(MeasureUnit::createPascal(status));
1840 measureUnitValue = MeasureUnit::getPascal();
1841 measureUnit.adoptInstead(MeasureUnit::createPoundPerSquareInch(status));
1842 measureUnitValue = MeasureUnit::getPoundPerSquareInch();
1843 measureUnit.adoptInstead(MeasureUnit::createKilometerPerHour(status));
1844 measureUnitValue = MeasureUnit::getKilometerPerHour();
1845 measureUnit.adoptInstead(MeasureUnit::createKnot(status));
1846 measureUnitValue = MeasureUnit::getKnot();
1847 measureUnit.adoptInstead(MeasureUnit::createMeterPerSecond(status));
1848 measureUnitValue = MeasureUnit::getMeterPerSecond();
1849 measureUnit.adoptInstead(MeasureUnit::createMilePerHour(status));
1850 measureUnitValue = MeasureUnit::getMilePerHour();
1851 measureUnit.adoptInstead(MeasureUnit::createCelsius(status));
1852 measureUnitValue = MeasureUnit::getCelsius();
1853 measureUnit.adoptInstead(MeasureUnit::createFahrenheit(status));
1854 measureUnitValue = MeasureUnit::getFahrenheit();
1855 measureUnit.adoptInstead(MeasureUnit::createGenericTemperature(status));
1856 measureUnitValue = MeasureUnit::getGenericTemperature();
1857 measureUnit.adoptInstead(MeasureUnit::createKelvin(status));
1858 measureUnitValue = MeasureUnit::getKelvin();
1859 measureUnit.adoptInstead(MeasureUnit::createNewtonMeter(status));
1860 measureUnitValue = MeasureUnit::getNewtonMeter();
1861 measureUnit.adoptInstead(MeasureUnit::createPoundFoot(status));
1862 measureUnitValue = MeasureUnit::getPoundFoot();
1863 measureUnit.adoptInstead(MeasureUnit::createAcreFoot(status));
1864 measureUnitValue = MeasureUnit::getAcreFoot();
1865 measureUnit.adoptInstead(MeasureUnit::createBarrel(status));
1866 measureUnitValue = MeasureUnit::getBarrel();
1867 measureUnit.adoptInstead(MeasureUnit::createBushel(status));
1868 measureUnitValue = MeasureUnit::getBushel();
1869 measureUnit.adoptInstead(MeasureUnit::createCentiliter(status));
1870 measureUnitValue = MeasureUnit::getCentiliter();
1871 measureUnit.adoptInstead(MeasureUnit::createCubicCentimeter(status));
1872 measureUnitValue = MeasureUnit::getCubicCentimeter();
1873 measureUnit.adoptInstead(MeasureUnit::createCubicFoot(status));
1874 measureUnitValue = MeasureUnit::getCubicFoot();
1875 measureUnit.adoptInstead(MeasureUnit::createCubicInch(status));
1876 measureUnitValue = MeasureUnit::getCubicInch();
1877 measureUnit.adoptInstead(MeasureUnit::createCubicKilometer(status));
1878 measureUnitValue = MeasureUnit::getCubicKilometer();
1879 measureUnit.adoptInstead(MeasureUnit::createCubicMeter(status));
1880 measureUnitValue = MeasureUnit::getCubicMeter();
1881 measureUnit.adoptInstead(MeasureUnit::createCubicMile(status));
1882 measureUnitValue = MeasureUnit::getCubicMile();
1883 measureUnit.adoptInstead(MeasureUnit::createCubicYard(status));
1884 measureUnitValue = MeasureUnit::getCubicYard();
1885 measureUnit.adoptInstead(MeasureUnit::createCup(status));
1886 measureUnitValue = MeasureUnit::getCup();
1887 measureUnit.adoptInstead(MeasureUnit::createCupMetric(status));
1888 measureUnitValue = MeasureUnit::getCupMetric();
1889 measureUnit.adoptInstead(MeasureUnit::createDeciliter(status));
1890 measureUnitValue = MeasureUnit::getDeciliter();
1891 measureUnit.adoptInstead(MeasureUnit::createFluidOunce(status));
1892 measureUnitValue = MeasureUnit::getFluidOunce();
1893 measureUnit.adoptInstead(MeasureUnit::createFluidOunceImperial(status));
1894 measureUnitValue = MeasureUnit::getFluidOunceImperial();
1895 measureUnit.adoptInstead(MeasureUnit::createGallon(status));
1896 measureUnitValue = MeasureUnit::getGallon();
1897 measureUnit.adoptInstead(MeasureUnit::createGallonImperial(status));
1898 measureUnitValue = MeasureUnit::getGallonImperial();
1899 measureUnit.adoptInstead(MeasureUnit::createHectoliter(status));
1900 measureUnitValue = MeasureUnit::getHectoliter();
1901 measureUnit.adoptInstead(MeasureUnit::createLiter(status));
1902 measureUnitValue = MeasureUnit::getLiter();
1903 measureUnit.adoptInstead(MeasureUnit::createMegaliter(status));
1904 measureUnitValue = MeasureUnit::getMegaliter();
1905 measureUnit.adoptInstead(MeasureUnit::createMilliliter(status));
1906 measureUnitValue = MeasureUnit::getMilliliter();
1907 measureUnit.adoptInstead(MeasureUnit::createPint(status));
1908 measureUnitValue = MeasureUnit::getPint();
1909 measureUnit.adoptInstead(MeasureUnit::createPintMetric(status));
1910 measureUnitValue = MeasureUnit::getPintMetric();
1911 measureUnit.adoptInstead(MeasureUnit::createQuart(status));
1912 measureUnitValue = MeasureUnit::getQuart();
1913 measureUnit.adoptInstead(MeasureUnit::createTablespoon(status));
1914 measureUnitValue = MeasureUnit::getTablespoon();
1915 measureUnit.adoptInstead(MeasureUnit::createTeaspoon(status));
1916 measureUnitValue = MeasureUnit::getTeaspoon();
1917 assertSuccess("", status);
1918 }
1919
1920 // Note that TestCompatible66(), TestCompatible67()
1921 // would be the same as TestCompatible65(), no need to add them.
1922
TestCompatible68()1923 void MeasureFormatTest::TestCompatible68() {
1924 UErrorCode status = U_ZERO_ERROR;
1925 LocalPointer<MeasureUnit> measureUnit;
1926 MeasureUnit measureUnitValue;
1927 measureUnit.adoptInstead(MeasureUnit::createGForce(status));
1928 measureUnitValue = MeasureUnit::getGForce();
1929 measureUnit.adoptInstead(MeasureUnit::createMeterPerSecondSquared(status));
1930 measureUnitValue = MeasureUnit::getMeterPerSecondSquared();
1931 measureUnit.adoptInstead(MeasureUnit::createArcMinute(status));
1932 measureUnitValue = MeasureUnit::getArcMinute();
1933 measureUnit.adoptInstead(MeasureUnit::createArcSecond(status));
1934 measureUnitValue = MeasureUnit::getArcSecond();
1935 measureUnit.adoptInstead(MeasureUnit::createDegree(status));
1936 measureUnitValue = MeasureUnit::getDegree();
1937 measureUnit.adoptInstead(MeasureUnit::createRadian(status));
1938 measureUnitValue = MeasureUnit::getRadian();
1939 measureUnit.adoptInstead(MeasureUnit::createRevolutionAngle(status));
1940 measureUnitValue = MeasureUnit::getRevolutionAngle();
1941 measureUnit.adoptInstead(MeasureUnit::createAcre(status));
1942 measureUnitValue = MeasureUnit::getAcre();
1943 measureUnit.adoptInstead(MeasureUnit::createDunam(status));
1944 measureUnitValue = MeasureUnit::getDunam();
1945 measureUnit.adoptInstead(MeasureUnit::createHectare(status));
1946 measureUnitValue = MeasureUnit::getHectare();
1947 measureUnit.adoptInstead(MeasureUnit::createSquareCentimeter(status));
1948 measureUnitValue = MeasureUnit::getSquareCentimeter();
1949 measureUnit.adoptInstead(MeasureUnit::createSquareFoot(status));
1950 measureUnitValue = MeasureUnit::getSquareFoot();
1951 measureUnit.adoptInstead(MeasureUnit::createSquareInch(status));
1952 measureUnitValue = MeasureUnit::getSquareInch();
1953 measureUnit.adoptInstead(MeasureUnit::createSquareKilometer(status));
1954 measureUnitValue = MeasureUnit::getSquareKilometer();
1955 measureUnit.adoptInstead(MeasureUnit::createSquareMeter(status));
1956 measureUnitValue = MeasureUnit::getSquareMeter();
1957 measureUnit.adoptInstead(MeasureUnit::createSquareMile(status));
1958 measureUnitValue = MeasureUnit::getSquareMile();
1959 measureUnit.adoptInstead(MeasureUnit::createSquareYard(status));
1960 measureUnitValue = MeasureUnit::getSquareYard();
1961 measureUnit.adoptInstead(MeasureUnit::createKarat(status));
1962 measureUnitValue = MeasureUnit::getKarat();
1963 measureUnit.adoptInstead(MeasureUnit::createMilligramPerDeciliter(status));
1964 measureUnitValue = MeasureUnit::getMilligramPerDeciliter();
1965 measureUnit.adoptInstead(MeasureUnit::createMillimolePerLiter(status));
1966 measureUnitValue = MeasureUnit::getMillimolePerLiter();
1967 measureUnit.adoptInstead(MeasureUnit::createMole(status));
1968 measureUnitValue = MeasureUnit::getMole();
1969 measureUnit.adoptInstead(MeasureUnit::createPercent(status));
1970 measureUnitValue = MeasureUnit::getPercent();
1971 measureUnit.adoptInstead(MeasureUnit::createPermille(status));
1972 measureUnitValue = MeasureUnit::getPermille();
1973 measureUnit.adoptInstead(MeasureUnit::createPartPerMillion(status));
1974 measureUnitValue = MeasureUnit::getPartPerMillion();
1975 measureUnit.adoptInstead(MeasureUnit::createPermyriad(status));
1976 measureUnitValue = MeasureUnit::getPermyriad();
1977 measureUnit.adoptInstead(MeasureUnit::createLiterPer100Kilometers(status));
1978 measureUnitValue = MeasureUnit::getLiterPer100Kilometers();
1979 measureUnit.adoptInstead(MeasureUnit::createLiterPerKilometer(status));
1980 measureUnitValue = MeasureUnit::getLiterPerKilometer();
1981 measureUnit.adoptInstead(MeasureUnit::createMilePerGallon(status));
1982 measureUnitValue = MeasureUnit::getMilePerGallon();
1983 measureUnit.adoptInstead(MeasureUnit::createMilePerGallonImperial(status));
1984 measureUnitValue = MeasureUnit::getMilePerGallonImperial();
1985 measureUnit.adoptInstead(MeasureUnit::createBit(status));
1986 measureUnitValue = MeasureUnit::getBit();
1987 measureUnit.adoptInstead(MeasureUnit::createByte(status));
1988 measureUnitValue = MeasureUnit::getByte();
1989 measureUnit.adoptInstead(MeasureUnit::createGigabit(status));
1990 measureUnitValue = MeasureUnit::getGigabit();
1991 measureUnit.adoptInstead(MeasureUnit::createGigabyte(status));
1992 measureUnitValue = MeasureUnit::getGigabyte();
1993 measureUnit.adoptInstead(MeasureUnit::createKilobit(status));
1994 measureUnitValue = MeasureUnit::getKilobit();
1995 measureUnit.adoptInstead(MeasureUnit::createKilobyte(status));
1996 measureUnitValue = MeasureUnit::getKilobyte();
1997 measureUnit.adoptInstead(MeasureUnit::createMegabit(status));
1998 measureUnitValue = MeasureUnit::getMegabit();
1999 measureUnit.adoptInstead(MeasureUnit::createMegabyte(status));
2000 measureUnitValue = MeasureUnit::getMegabyte();
2001 measureUnit.adoptInstead(MeasureUnit::createPetabyte(status));
2002 measureUnitValue = MeasureUnit::getPetabyte();
2003 measureUnit.adoptInstead(MeasureUnit::createTerabit(status));
2004 measureUnitValue = MeasureUnit::getTerabit();
2005 measureUnit.adoptInstead(MeasureUnit::createTerabyte(status));
2006 measureUnitValue = MeasureUnit::getTerabyte();
2007 measureUnit.adoptInstead(MeasureUnit::createCentury(status));
2008 measureUnitValue = MeasureUnit::getCentury();
2009 measureUnit.adoptInstead(MeasureUnit::createDay(status));
2010 measureUnitValue = MeasureUnit::getDay();
2011 measureUnit.adoptInstead(MeasureUnit::createDayPerson(status));
2012 measureUnitValue = MeasureUnit::getDayPerson();
2013 measureUnit.adoptInstead(MeasureUnit::createDecade(status));
2014 measureUnitValue = MeasureUnit::getDecade();
2015 measureUnit.adoptInstead(MeasureUnit::createHour(status));
2016 measureUnitValue = MeasureUnit::getHour();
2017 measureUnit.adoptInstead(MeasureUnit::createMicrosecond(status));
2018 measureUnitValue = MeasureUnit::getMicrosecond();
2019 measureUnit.adoptInstead(MeasureUnit::createMillisecond(status));
2020 measureUnitValue = MeasureUnit::getMillisecond();
2021 measureUnit.adoptInstead(MeasureUnit::createMinute(status));
2022 measureUnitValue = MeasureUnit::getMinute();
2023 measureUnit.adoptInstead(MeasureUnit::createMonth(status));
2024 measureUnitValue = MeasureUnit::getMonth();
2025 measureUnit.adoptInstead(MeasureUnit::createMonthPerson(status));
2026 measureUnitValue = MeasureUnit::getMonthPerson();
2027 measureUnit.adoptInstead(MeasureUnit::createNanosecond(status));
2028 measureUnitValue = MeasureUnit::getNanosecond();
2029 measureUnit.adoptInstead(MeasureUnit::createSecond(status));
2030 measureUnitValue = MeasureUnit::getSecond();
2031 measureUnit.adoptInstead(MeasureUnit::createWeek(status));
2032 measureUnitValue = MeasureUnit::getWeek();
2033 measureUnit.adoptInstead(MeasureUnit::createWeekPerson(status));
2034 measureUnitValue = MeasureUnit::getWeekPerson();
2035 measureUnit.adoptInstead(MeasureUnit::createYear(status));
2036 measureUnitValue = MeasureUnit::getYear();
2037 measureUnit.adoptInstead(MeasureUnit::createYearPerson(status));
2038 measureUnitValue = MeasureUnit::getYearPerson();
2039 measureUnit.adoptInstead(MeasureUnit::createAmpere(status));
2040 measureUnitValue = MeasureUnit::getAmpere();
2041 measureUnit.adoptInstead(MeasureUnit::createMilliampere(status));
2042 measureUnitValue = MeasureUnit::getMilliampere();
2043 measureUnit.adoptInstead(MeasureUnit::createOhm(status));
2044 measureUnitValue = MeasureUnit::getOhm();
2045 measureUnit.adoptInstead(MeasureUnit::createVolt(status));
2046 measureUnitValue = MeasureUnit::getVolt();
2047 measureUnit.adoptInstead(MeasureUnit::createBritishThermalUnit(status));
2048 measureUnitValue = MeasureUnit::getBritishThermalUnit();
2049 measureUnit.adoptInstead(MeasureUnit::createCalorie(status));
2050 measureUnitValue = MeasureUnit::getCalorie();
2051 measureUnit.adoptInstead(MeasureUnit::createElectronvolt(status));
2052 measureUnitValue = MeasureUnit::getElectronvolt();
2053 measureUnit.adoptInstead(MeasureUnit::createFoodcalorie(status));
2054 measureUnitValue = MeasureUnit::getFoodcalorie();
2055 measureUnit.adoptInstead(MeasureUnit::createJoule(status));
2056 measureUnitValue = MeasureUnit::getJoule();
2057 measureUnit.adoptInstead(MeasureUnit::createKilocalorie(status));
2058 measureUnitValue = MeasureUnit::getKilocalorie();
2059 measureUnit.adoptInstead(MeasureUnit::createKilojoule(status));
2060 measureUnitValue = MeasureUnit::getKilojoule();
2061 measureUnit.adoptInstead(MeasureUnit::createKilowattHour(status));
2062 measureUnitValue = MeasureUnit::getKilowattHour();
2063 measureUnit.adoptInstead(MeasureUnit::createThermUs(status));
2064 measureUnitValue = MeasureUnit::getThermUs();
2065 measureUnit.adoptInstead(MeasureUnit::createNewton(status));
2066 measureUnitValue = MeasureUnit::getNewton();
2067 measureUnit.adoptInstead(MeasureUnit::createPoundForce(status));
2068 measureUnitValue = MeasureUnit::getPoundForce();
2069 measureUnit.adoptInstead(MeasureUnit::createGigahertz(status));
2070 measureUnitValue = MeasureUnit::getGigahertz();
2071 measureUnit.adoptInstead(MeasureUnit::createHertz(status));
2072 measureUnitValue = MeasureUnit::getHertz();
2073 measureUnit.adoptInstead(MeasureUnit::createKilohertz(status));
2074 measureUnitValue = MeasureUnit::getKilohertz();
2075 measureUnit.adoptInstead(MeasureUnit::createMegahertz(status));
2076 measureUnitValue = MeasureUnit::getMegahertz();
2077 measureUnit.adoptInstead(MeasureUnit::createDot(status));
2078 measureUnitValue = MeasureUnit::getDot();
2079 measureUnit.adoptInstead(MeasureUnit::createDotPerCentimeter(status));
2080 measureUnitValue = MeasureUnit::getDotPerCentimeter();
2081 measureUnit.adoptInstead(MeasureUnit::createDotPerInch(status));
2082 measureUnitValue = MeasureUnit::getDotPerInch();
2083 measureUnit.adoptInstead(MeasureUnit::createEm(status));
2084 measureUnitValue = MeasureUnit::getEm();
2085 measureUnit.adoptInstead(MeasureUnit::createMegapixel(status));
2086 measureUnitValue = MeasureUnit::getMegapixel();
2087 measureUnit.adoptInstead(MeasureUnit::createPixel(status));
2088 measureUnitValue = MeasureUnit::getPixel();
2089 measureUnit.adoptInstead(MeasureUnit::createPixelPerCentimeter(status));
2090 measureUnitValue = MeasureUnit::getPixelPerCentimeter();
2091 measureUnit.adoptInstead(MeasureUnit::createPixelPerInch(status));
2092 measureUnitValue = MeasureUnit::getPixelPerInch();
2093 measureUnit.adoptInstead(MeasureUnit::createAstronomicalUnit(status));
2094 measureUnitValue = MeasureUnit::getAstronomicalUnit();
2095 measureUnit.adoptInstead(MeasureUnit::createCentimeter(status));
2096 measureUnitValue = MeasureUnit::getCentimeter();
2097 measureUnit.adoptInstead(MeasureUnit::createDecimeter(status));
2098 measureUnitValue = MeasureUnit::getDecimeter();
2099 measureUnit.adoptInstead(MeasureUnit::createEarthRadius(status));
2100 measureUnitValue = MeasureUnit::getEarthRadius();
2101 measureUnit.adoptInstead(MeasureUnit::createFathom(status));
2102 measureUnitValue = MeasureUnit::getFathom();
2103 measureUnit.adoptInstead(MeasureUnit::createFoot(status));
2104 measureUnitValue = MeasureUnit::getFoot();
2105 measureUnit.adoptInstead(MeasureUnit::createFurlong(status));
2106 measureUnitValue = MeasureUnit::getFurlong();
2107 measureUnit.adoptInstead(MeasureUnit::createInch(status));
2108 measureUnitValue = MeasureUnit::getInch();
2109 measureUnit.adoptInstead(MeasureUnit::createKilometer(status));
2110 measureUnitValue = MeasureUnit::getKilometer();
2111 measureUnit.adoptInstead(MeasureUnit::createLightYear(status));
2112 measureUnitValue = MeasureUnit::getLightYear();
2113 measureUnit.adoptInstead(MeasureUnit::createMeter(status));
2114 measureUnitValue = MeasureUnit::getMeter();
2115 measureUnit.adoptInstead(MeasureUnit::createMicrometer(status));
2116 measureUnitValue = MeasureUnit::getMicrometer();
2117 measureUnit.adoptInstead(MeasureUnit::createMile(status));
2118 measureUnitValue = MeasureUnit::getMile();
2119 measureUnit.adoptInstead(MeasureUnit::createMileScandinavian(status));
2120 measureUnitValue = MeasureUnit::getMileScandinavian();
2121 measureUnit.adoptInstead(MeasureUnit::createMillimeter(status));
2122 measureUnitValue = MeasureUnit::getMillimeter();
2123 measureUnit.adoptInstead(MeasureUnit::createNanometer(status));
2124 measureUnitValue = MeasureUnit::getNanometer();
2125 measureUnit.adoptInstead(MeasureUnit::createNauticalMile(status));
2126 measureUnitValue = MeasureUnit::getNauticalMile();
2127 measureUnit.adoptInstead(MeasureUnit::createParsec(status));
2128 measureUnitValue = MeasureUnit::getParsec();
2129 measureUnit.adoptInstead(MeasureUnit::createPicometer(status));
2130 measureUnitValue = MeasureUnit::getPicometer();
2131 measureUnit.adoptInstead(MeasureUnit::createPoint(status));
2132 measureUnitValue = MeasureUnit::getPoint();
2133 measureUnit.adoptInstead(MeasureUnit::createSolarRadius(status));
2134 measureUnitValue = MeasureUnit::getSolarRadius();
2135 measureUnit.adoptInstead(MeasureUnit::createYard(status));
2136 measureUnitValue = MeasureUnit::getYard();
2137 measureUnit.adoptInstead(MeasureUnit::createCandela(status));
2138 measureUnitValue = MeasureUnit::getCandela();
2139 measureUnit.adoptInstead(MeasureUnit::createLumen(status));
2140 measureUnitValue = MeasureUnit::getLumen();
2141 measureUnit.adoptInstead(MeasureUnit::createLux(status));
2142 measureUnitValue = MeasureUnit::getLux();
2143 measureUnit.adoptInstead(MeasureUnit::createSolarLuminosity(status));
2144 measureUnitValue = MeasureUnit::getSolarLuminosity();
2145 measureUnit.adoptInstead(MeasureUnit::createCarat(status));
2146 measureUnitValue = MeasureUnit::getCarat();
2147 measureUnit.adoptInstead(MeasureUnit::createDalton(status));
2148 measureUnitValue = MeasureUnit::getDalton();
2149 measureUnit.adoptInstead(MeasureUnit::createEarthMass(status));
2150 measureUnitValue = MeasureUnit::getEarthMass();
2151 measureUnit.adoptInstead(MeasureUnit::createGrain(status));
2152 measureUnitValue = MeasureUnit::getGrain();
2153 measureUnit.adoptInstead(MeasureUnit::createGram(status));
2154 measureUnitValue = MeasureUnit::getGram();
2155 measureUnit.adoptInstead(MeasureUnit::createKilogram(status));
2156 measureUnitValue = MeasureUnit::getKilogram();
2157 measureUnit.adoptInstead(MeasureUnit::createMetricTon(status));
2158 measureUnitValue = MeasureUnit::getMetricTon();
2159 measureUnit.adoptInstead(MeasureUnit::createMicrogram(status));
2160 measureUnitValue = MeasureUnit::getMicrogram();
2161 measureUnit.adoptInstead(MeasureUnit::createMilligram(status));
2162 measureUnitValue = MeasureUnit::getMilligram();
2163 measureUnit.adoptInstead(MeasureUnit::createOunce(status));
2164 measureUnitValue = MeasureUnit::getOunce();
2165 measureUnit.adoptInstead(MeasureUnit::createOunceTroy(status));
2166 measureUnitValue = MeasureUnit::getOunceTroy();
2167 measureUnit.adoptInstead(MeasureUnit::createPound(status));
2168 measureUnitValue = MeasureUnit::getPound();
2169 measureUnit.adoptInstead(MeasureUnit::createSolarMass(status));
2170 measureUnitValue = MeasureUnit::getSolarMass();
2171 measureUnit.adoptInstead(MeasureUnit::createStone(status));
2172 measureUnitValue = MeasureUnit::getStone();
2173 measureUnit.adoptInstead(MeasureUnit::createTon(status));
2174 measureUnitValue = MeasureUnit::getTon();
2175 measureUnit.adoptInstead(MeasureUnit::createGigawatt(status));
2176 measureUnitValue = MeasureUnit::getGigawatt();
2177 measureUnit.adoptInstead(MeasureUnit::createHorsepower(status));
2178 measureUnitValue = MeasureUnit::getHorsepower();
2179 measureUnit.adoptInstead(MeasureUnit::createKilowatt(status));
2180 measureUnitValue = MeasureUnit::getKilowatt();
2181 measureUnit.adoptInstead(MeasureUnit::createMegawatt(status));
2182 measureUnitValue = MeasureUnit::getMegawatt();
2183 measureUnit.adoptInstead(MeasureUnit::createMilliwatt(status));
2184 measureUnitValue = MeasureUnit::getMilliwatt();
2185 measureUnit.adoptInstead(MeasureUnit::createWatt(status));
2186 measureUnitValue = MeasureUnit::getWatt();
2187 measureUnit.adoptInstead(MeasureUnit::createAtmosphere(status));
2188 measureUnitValue = MeasureUnit::getAtmosphere();
2189 measureUnit.adoptInstead(MeasureUnit::createBar(status));
2190 measureUnitValue = MeasureUnit::getBar();
2191 measureUnit.adoptInstead(MeasureUnit::createHectopascal(status));
2192 measureUnitValue = MeasureUnit::getHectopascal();
2193 measureUnit.adoptInstead(MeasureUnit::createInchHg(status));
2194 measureUnitValue = MeasureUnit::getInchHg();
2195 measureUnit.adoptInstead(MeasureUnit::createKilopascal(status));
2196 measureUnitValue = MeasureUnit::getKilopascal();
2197 measureUnit.adoptInstead(MeasureUnit::createMegapascal(status));
2198 measureUnitValue = MeasureUnit::getMegapascal();
2199 measureUnit.adoptInstead(MeasureUnit::createMillibar(status));
2200 measureUnitValue = MeasureUnit::getMillibar();
2201 measureUnit.adoptInstead(MeasureUnit::createMillimeterOfMercury(status));
2202 measureUnitValue = MeasureUnit::getMillimeterOfMercury();
2203 measureUnit.adoptInstead(MeasureUnit::createPascal(status));
2204 measureUnitValue = MeasureUnit::getPascal();
2205 measureUnit.adoptInstead(MeasureUnit::createPoundPerSquareInch(status));
2206 measureUnitValue = MeasureUnit::getPoundPerSquareInch();
2207 measureUnit.adoptInstead(MeasureUnit::createKilometerPerHour(status));
2208 measureUnitValue = MeasureUnit::getKilometerPerHour();
2209 measureUnit.adoptInstead(MeasureUnit::createKnot(status));
2210 measureUnitValue = MeasureUnit::getKnot();
2211 measureUnit.adoptInstead(MeasureUnit::createMeterPerSecond(status));
2212 measureUnitValue = MeasureUnit::getMeterPerSecond();
2213 measureUnit.adoptInstead(MeasureUnit::createMilePerHour(status));
2214 measureUnitValue = MeasureUnit::getMilePerHour();
2215 measureUnit.adoptInstead(MeasureUnit::createCelsius(status));
2216 measureUnitValue = MeasureUnit::getCelsius();
2217 measureUnit.adoptInstead(MeasureUnit::createFahrenheit(status));
2218 measureUnitValue = MeasureUnit::getFahrenheit();
2219 measureUnit.adoptInstead(MeasureUnit::createGenericTemperature(status));
2220 measureUnitValue = MeasureUnit::getGenericTemperature();
2221 measureUnit.adoptInstead(MeasureUnit::createKelvin(status));
2222 measureUnitValue = MeasureUnit::getKelvin();
2223 measureUnit.adoptInstead(MeasureUnit::createNewtonMeter(status));
2224 measureUnitValue = MeasureUnit::getNewtonMeter();
2225 measureUnit.adoptInstead(MeasureUnit::createPoundFoot(status));
2226 measureUnitValue = MeasureUnit::getPoundFoot();
2227 measureUnit.adoptInstead(MeasureUnit::createAcreFoot(status));
2228 measureUnitValue = MeasureUnit::getAcreFoot();
2229 measureUnit.adoptInstead(MeasureUnit::createBarrel(status));
2230 measureUnitValue = MeasureUnit::getBarrel();
2231 measureUnit.adoptInstead(MeasureUnit::createBushel(status));
2232 measureUnitValue = MeasureUnit::getBushel();
2233 measureUnit.adoptInstead(MeasureUnit::createCentiliter(status));
2234 measureUnitValue = MeasureUnit::getCentiliter();
2235 measureUnit.adoptInstead(MeasureUnit::createCubicCentimeter(status));
2236 measureUnitValue = MeasureUnit::getCubicCentimeter();
2237 measureUnit.adoptInstead(MeasureUnit::createCubicFoot(status));
2238 measureUnitValue = MeasureUnit::getCubicFoot();
2239 measureUnit.adoptInstead(MeasureUnit::createCubicInch(status));
2240 measureUnitValue = MeasureUnit::getCubicInch();
2241 measureUnit.adoptInstead(MeasureUnit::createCubicKilometer(status));
2242 measureUnitValue = MeasureUnit::getCubicKilometer();
2243 measureUnit.adoptInstead(MeasureUnit::createCubicMeter(status));
2244 measureUnitValue = MeasureUnit::getCubicMeter();
2245 measureUnit.adoptInstead(MeasureUnit::createCubicMile(status));
2246 measureUnitValue = MeasureUnit::getCubicMile();
2247 measureUnit.adoptInstead(MeasureUnit::createCubicYard(status));
2248 measureUnitValue = MeasureUnit::getCubicYard();
2249 measureUnit.adoptInstead(MeasureUnit::createCup(status));
2250 measureUnitValue = MeasureUnit::getCup();
2251 measureUnit.adoptInstead(MeasureUnit::createCupMetric(status));
2252 measureUnitValue = MeasureUnit::getCupMetric();
2253 measureUnit.adoptInstead(MeasureUnit::createDeciliter(status));
2254 measureUnitValue = MeasureUnit::getDeciliter();
2255 measureUnit.adoptInstead(MeasureUnit::createDessertSpoon(status));
2256 measureUnitValue = MeasureUnit::getDessertSpoon();
2257 measureUnit.adoptInstead(MeasureUnit::createDessertSpoonImperial(status));
2258 measureUnitValue = MeasureUnit::getDessertSpoonImperial();
2259 measureUnit.adoptInstead(MeasureUnit::createDram(status));
2260 measureUnitValue = MeasureUnit::getDram();
2261 measureUnit.adoptInstead(MeasureUnit::createDrop(status));
2262 measureUnitValue = MeasureUnit::getDrop();
2263 measureUnit.adoptInstead(MeasureUnit::createFluidOunce(status));
2264 measureUnitValue = MeasureUnit::getFluidOunce();
2265 measureUnit.adoptInstead(MeasureUnit::createFluidOunceImperial(status));
2266 measureUnitValue = MeasureUnit::getFluidOunceImperial();
2267 measureUnit.adoptInstead(MeasureUnit::createGallon(status));
2268 measureUnitValue = MeasureUnit::getGallon();
2269 measureUnit.adoptInstead(MeasureUnit::createGallonImperial(status));
2270 measureUnitValue = MeasureUnit::getGallonImperial();
2271 measureUnit.adoptInstead(MeasureUnit::createHectoliter(status));
2272 measureUnitValue = MeasureUnit::getHectoliter();
2273 measureUnit.adoptInstead(MeasureUnit::createJigger(status));
2274 measureUnitValue = MeasureUnit::getJigger();
2275 measureUnit.adoptInstead(MeasureUnit::createLiter(status));
2276 measureUnitValue = MeasureUnit::getLiter();
2277 measureUnit.adoptInstead(MeasureUnit::createMegaliter(status));
2278 measureUnitValue = MeasureUnit::getMegaliter();
2279 measureUnit.adoptInstead(MeasureUnit::createMilliliter(status));
2280 measureUnitValue = MeasureUnit::getMilliliter();
2281 measureUnit.adoptInstead(MeasureUnit::createPinch(status));
2282 measureUnitValue = MeasureUnit::getPinch();
2283 measureUnit.adoptInstead(MeasureUnit::createPint(status));
2284 measureUnitValue = MeasureUnit::getPint();
2285 measureUnit.adoptInstead(MeasureUnit::createPintMetric(status));
2286 measureUnitValue = MeasureUnit::getPintMetric();
2287 measureUnit.adoptInstead(MeasureUnit::createQuart(status));
2288 measureUnitValue = MeasureUnit::getQuart();
2289 measureUnit.adoptInstead(MeasureUnit::createQuartImperial(status));
2290 measureUnitValue = MeasureUnit::getQuartImperial();
2291 measureUnit.adoptInstead(MeasureUnit::createTablespoon(status));
2292 measureUnitValue = MeasureUnit::getTablespoon();
2293 measureUnit.adoptInstead(MeasureUnit::createTeaspoon(status));
2294 measureUnitValue = MeasureUnit::getTeaspoon();
2295 assertSuccess("", status);
2296 }
2297
TestBasic()2298 void MeasureFormatTest::TestBasic() {
2299 UErrorCode status = U_ZERO_ERROR;
2300 MeasureUnit *ptr1 = MeasureUnit::createArcMinute(status);
2301 MeasureUnit *ptr2 = MeasureUnit::createArcMinute(status);
2302 if (!(*ptr1 == *ptr2)) {
2303 errln("Expect == to work.");
2304 }
2305 if (*ptr1 != *ptr2) {
2306 errln("Expect != to work.");
2307 }
2308 MeasureUnit *ptr3 = MeasureUnit::createMeter(status);
2309 if (*ptr1 == *ptr3) {
2310 errln("Expect == to work.");
2311 }
2312 if (!(*ptr1 != *ptr3)) {
2313 errln("Expect != to work.");
2314 }
2315 MeasureUnit *ptr4 = ptr1->clone();
2316 if (*ptr1 != *ptr4) {
2317 errln("Expect clone to work.");
2318 }
2319 MeasureUnit stack;
2320 stack = *ptr1;
2321 if (*ptr1 != stack) {
2322 errln("Expect assignment to work.");
2323 }
2324
2325 delete ptr1;
2326 delete ptr2;
2327 delete ptr3;
2328 delete ptr4;
2329 }
2330
TestGetAvailable()2331 void MeasureFormatTest::TestGetAvailable() {
2332 MeasureUnit *units = NULL;
2333 UErrorCode status = U_ZERO_ERROR;
2334 int32_t totalCount = MeasureUnit::getAvailable(units, 0, status);
2335 while (status == U_BUFFER_OVERFLOW_ERROR) {
2336 status = U_ZERO_ERROR;
2337 delete [] units;
2338 units = new MeasureUnit[totalCount];
2339 totalCount = MeasureUnit::getAvailable(units, totalCount, status);
2340 }
2341 if (U_FAILURE(status)) {
2342 dataerrln("Failure creating format object - %s", u_errorName(status));
2343 delete [] units;
2344 return;
2345 }
2346 if (totalCount < 200) {
2347 errln("Expect at least 200 measure units including currencies.");
2348 }
2349 delete [] units;
2350 StringEnumeration *types = MeasureUnit::getAvailableTypes(status);
2351 if (U_FAILURE(status)) {
2352 dataerrln("Failure getting types - %s", u_errorName(status));
2353 delete types;
2354 return;
2355 }
2356 if (types->count(status) < 10) {
2357 errln("Expect at least 10 distinct unit types.");
2358 }
2359 units = NULL;
2360 int32_t unitCapacity = 0;
2361 int32_t unitCountSum = 0;
2362 for (
2363 const char* type = types->next(NULL, status);
2364 type != NULL;
2365 type = types->next(NULL, status)) {
2366 int32_t unitCount = MeasureUnit::getAvailable(type, units, unitCapacity, status);
2367 while (status == U_BUFFER_OVERFLOW_ERROR) {
2368 status = U_ZERO_ERROR;
2369 delete [] units;
2370 units = new MeasureUnit[unitCount];
2371 unitCapacity = unitCount;
2372 unitCount = MeasureUnit::getAvailable(type, units, unitCapacity, status);
2373 }
2374 if (U_FAILURE(status)) {
2375 dataerrln("Failure getting units - %s", u_errorName(status));
2376 delete [] units;
2377 delete types;
2378 return;
2379 }
2380 if (unitCount < 1) {
2381 errln("Expect at least one unit count per type.");
2382 }
2383 unitCountSum += unitCount;
2384 }
2385 if (unitCountSum != totalCount) {
2386 errln("Expected total unit count to equal sum of unit counts by type.");
2387 }
2388 delete [] units;
2389 delete types;
2390 }
2391
TestExamplesInDocs()2392 void MeasureFormatTest::TestExamplesInDocs() {
2393 UErrorCode status = U_ZERO_ERROR;
2394 MeasureFormat fmtFr(Locale::getFrench(), UMEASFMT_WIDTH_SHORT, status);
2395 MeasureFormat fmtFrFull(
2396 Locale::getFrench(), UMEASFMT_WIDTH_WIDE, status);
2397 MeasureFormat fmtFrNarrow(
2398 Locale::getFrench(), UMEASFMT_WIDTH_NARROW, status);
2399 MeasureFormat fmtEn(Locale::getUS(), UMEASFMT_WIDTH_WIDE, status);
2400 if (!assertSuccess("Error creating formatters", status)) {
2401 return;
2402 }
2403 Measure measureC((double)23, MeasureUnit::createCelsius(status), status);
2404 Measure measureF((double)70, MeasureUnit::createFahrenheit(status), status);
2405 Measure feetAndInches[] = {
2406 Measure((double)70, MeasureUnit::createFoot(status), status),
2407 Measure((double)5.3, MeasureUnit::createInch(status), status)};
2408 Measure footAndInch[] = {
2409 Measure((double)1, MeasureUnit::createFoot(status), status),
2410 Measure((double)1, MeasureUnit::createInch(status), status)};
2411 Measure inchAndFeet[] = {
2412 Measure((double)1, MeasureUnit::createInch(status), status),
2413 Measure((double)2, MeasureUnit::createFoot(status), status)};
2414 if (!assertSuccess("Error creating measurements.", status)) {
2415 return;
2416 }
2417 verifyFormat(
2418 "Celsius",
2419 fmtFr,
2420 &measureC,
2421 1,
2422 "23\\u202F\\u00B0C");
2423 verifyFormatWithPrefix(
2424 "Celsius",
2425 fmtFr,
2426 "Prefix: ",
2427 &measureC,
2428 1,
2429 "Prefix: 23\\u202F\\u00B0C");
2430 verifyFormat(
2431 "Fahrenheit",
2432 fmtFr,
2433 &measureF,
2434 1,
2435 "70\\u202F\\u00B0F");
2436 verifyFormat(
2437 "Feet and inches",
2438 fmtFrFull,
2439 feetAndInches,
2440 UPRV_LENGTHOF(feetAndInches),
2441 "70 pieds et 5,3\\u00A0pouces");
2442 verifyFormatWithPrefix(
2443 "Feet and inches",
2444 fmtFrFull,
2445 "Prefix: ",
2446 feetAndInches,
2447 UPRV_LENGTHOF(feetAndInches),
2448 "Prefix: 70 pieds et 5,3\\u00A0pouces");
2449 verifyFormat(
2450 "Foot and inch",
2451 fmtFrFull,
2452 footAndInch,
2453 UPRV_LENGTHOF(footAndInch),
2454 "1\\u00A0pied et 1\\u00A0pouce");
2455 verifyFormat(
2456 "Foot and inch narrow",
2457 fmtFrNarrow,
2458 footAndInch,
2459 UPRV_LENGTHOF(footAndInch),
2460 "1\\u2032 1\\u2033");
2461 verifyFormat(
2462 "Inch and feet",
2463 fmtEn,
2464 inchAndFeet,
2465 UPRV_LENGTHOF(inchAndFeet),
2466 "1 inch, 2 feet");
2467 }
2468
TestFormatPeriodEn()2469 void MeasureFormatTest::TestFormatPeriodEn() {
2470 UErrorCode status = U_ZERO_ERROR;
2471 Measure t_1y[] = {Measure((double)1, MeasureUnit::createYear(status), status)};
2472 Measure t_5M[] = {Measure((double)5, MeasureUnit::createMonth(status), status)};
2473 Measure t_4d[] = {Measure((double)4, MeasureUnit::createDay(status), status)};
2474 Measure t_2h[] = {Measure((double)2, MeasureUnit::createHour(status), status)};
2475 Measure t_19m[] = {Measure((double)19, MeasureUnit::createMinute(status), status)};
2476 Measure t_1h_23_5s[] = {
2477 Measure((double)1.0, MeasureUnit::createHour(status), status),
2478 Measure((double)23.5, MeasureUnit::createSecond(status), status)
2479 };
2480 Measure t_1h_23_5m[] = {
2481 Measure((double)1.0, MeasureUnit::createHour(status), status),
2482 Measure((double)23.5, MeasureUnit::createMinute(status), status)
2483 };
2484 Measure t_1h_0m_23s[] = {
2485 Measure(
2486 (double)1.0,
2487 TimeUnit::createInstance(
2488 TimeUnit::UTIMEUNIT_HOUR, status),
2489 status),
2490 Measure(
2491 (double)0.0,
2492 TimeUnit::createInstance(
2493 TimeUnit::UTIMEUNIT_MINUTE, status),
2494 status),
2495 Measure(
2496 (double)23.0,
2497 TimeUnit::createInstance(
2498 TimeUnit::UTIMEUNIT_SECOND, status),
2499 status)
2500 };
2501 Measure t_2y_5M_3w_4d[] = {
2502 Measure(2.0, MeasureUnit::createYear(status), status),
2503 Measure(5.0, MeasureUnit::createMonth(status), status),
2504 Measure(3.0, MeasureUnit::createWeek(status), status),
2505 Measure(4.0, MeasureUnit::createDay(status), status)
2506 };
2507 Measure t_1m_59_9996s[] = {
2508 Measure(1.0, MeasureUnit::createMinute(status), status),
2509 Measure(59.9996, MeasureUnit::createSecond(status), status)
2510 };
2511 Measure t_5h_17m[] = {
2512 Measure(5.0, MeasureUnit::createHour(status), status),
2513 Measure(17.0, MeasureUnit::createMinute(status), status)
2514 };
2515 Measure t_neg5h_17m[] = {
2516 Measure(-5.0, MeasureUnit::createHour(status), status),
2517 Measure(17.0, MeasureUnit::createMinute(status), status)
2518 };
2519 Measure t_19m_28s[] = {
2520 Measure(19.0, MeasureUnit::createMinute(status), status),
2521 Measure(28.0, MeasureUnit::createSecond(status), status)
2522 };
2523 Measure t_0h_0m_9s[] = {
2524 Measure(0.0, MeasureUnit::createHour(status), status),
2525 Measure(0.0, MeasureUnit::createMinute(status), status),
2526 Measure(9.0, MeasureUnit::createSecond(status), status)
2527 };
2528 Measure t_0h_0m_17s[] = {
2529 Measure(0.0, MeasureUnit::createHour(status), status),
2530 Measure(0.0, MeasureUnit::createMinute(status), status),
2531 Measure(17.0, MeasureUnit::createSecond(status), status)
2532 };
2533 Measure t_6h_56_92m[] = {
2534 Measure(6.0, MeasureUnit::createHour(status), status),
2535 Measure(56.92, MeasureUnit::createMinute(status), status)
2536 };
2537 Measure t_3h_4s_5m[] = {
2538 Measure(3.0, MeasureUnit::createHour(status), status),
2539 Measure(4.0, MeasureUnit::createSecond(status), status),
2540 Measure(5.0, MeasureUnit::createMinute(status), status)
2541 };
2542 Measure t_6_7h_56_92m[] = {
2543 Measure(6.7, MeasureUnit::createHour(status), status),
2544 Measure(56.92, MeasureUnit::createMinute(status), status)
2545 };
2546
2547 Measure t_3h_5h[] = {
2548 Measure(3.0, MeasureUnit::createHour(status), status),
2549 Measure(5.0, MeasureUnit::createHour(status), status)
2550 };
2551
2552 if (!assertSuccess("Error creating Measure objects", status)) {
2553 return;
2554 }
2555
2556 ExpectedResult fullData[] = {
2557 {t_1m_59_9996s, UPRV_LENGTHOF(t_1m_59_9996s), "1 minute, 59.9996 seconds"},
2558 {t_19m, UPRV_LENGTHOF(t_19m), "19 minutes"},
2559 {t_1h_23_5s, UPRV_LENGTHOF(t_1h_23_5s), "1 hour, 23.5 seconds"},
2560 {t_1h_23_5m, UPRV_LENGTHOF(t_1h_23_5m), "1 hour, 23.5 minutes"},
2561 {t_1h_0m_23s, UPRV_LENGTHOF(t_1h_0m_23s), "1 hour, 0 minutes, 23 seconds"},
2562 {t_2y_5M_3w_4d, UPRV_LENGTHOF(t_2y_5M_3w_4d), "2 years, 5 months, 3 weeks, 4 days"}};
2563
2564 ExpectedResult abbrevData[] = {
2565 {t_1m_59_9996s, UPRV_LENGTHOF(t_1m_59_9996s), "1 min, 59.9996 sec"},
2566 {t_19m, UPRV_LENGTHOF(t_19m), "19 min"},
2567 {t_1h_23_5s, UPRV_LENGTHOF(t_1h_23_5s), "1 hr, 23.5 sec"},
2568 {t_1h_23_5m, UPRV_LENGTHOF(t_1h_23_5m), "1 hr, 23.5 min"},
2569 {t_1h_0m_23s, UPRV_LENGTHOF(t_1h_0m_23s), "1 hr, 0 min, 23 sec"},
2570 {t_2y_5M_3w_4d, UPRV_LENGTHOF(t_2y_5M_3w_4d), "2 yrs, 5 mths, 3 wks, 4 days"}};
2571
2572 ExpectedResult narrowData[] = {
2573 {t_1m_59_9996s, UPRV_LENGTHOF(t_1m_59_9996s), "1m 59.9996s"},
2574 {t_19m, UPRV_LENGTHOF(t_19m), "19m"},
2575 {t_1h_23_5s, UPRV_LENGTHOF(t_1h_23_5s), "1h 23.5s"},
2576 {t_1h_23_5m, UPRV_LENGTHOF(t_1h_23_5m), "1h 23.5m"},
2577 {t_1h_0m_23s, UPRV_LENGTHOF(t_1h_0m_23s), "1h 0m 23s"},
2578 {t_2y_5M_3w_4d, UPRV_LENGTHOF(t_2y_5M_3w_4d), "2y 5m 3w 4d"}};
2579
2580 ExpectedResult numericData[] = {
2581 {t_1m_59_9996s, UPRV_LENGTHOF(t_1m_59_9996s), "1:59.9996"},
2582 {t_19m, UPRV_LENGTHOF(t_19m), "19m"},
2583 {t_1h_23_5s, UPRV_LENGTHOF(t_1h_23_5s), "1:00:23.5"},
2584 {t_1h_23_5m, UPRV_LENGTHOF(t_1h_23_5m), "1:23.5"},
2585 {t_1h_0m_23s, UPRV_LENGTHOF(t_1h_0m_23s), "1:00:23"},
2586 {t_5h_17m, UPRV_LENGTHOF(t_5h_17m), "5:17"},
2587 {t_neg5h_17m, UPRV_LENGTHOF(t_neg5h_17m), "-5h 17m"},
2588 {t_19m_28s, UPRV_LENGTHOF(t_19m_28s), "19:28"},
2589 {t_2y_5M_3w_4d, UPRV_LENGTHOF(t_2y_5M_3w_4d), "2y 5m 3w 4d"},
2590 {t_0h_0m_9s, UPRV_LENGTHOF(t_0h_0m_9s), "0:00:09"},
2591 {t_6h_56_92m, UPRV_LENGTHOF(t_6h_56_92m), "6:56.92"},
2592 {t_6_7h_56_92m, UPRV_LENGTHOF(t_6_7h_56_92m), "6:56.92"},
2593 {t_3h_4s_5m, UPRV_LENGTHOF(t_3h_4s_5m), "3h 4s 5m"},
2594 {t_3h_5h, UPRV_LENGTHOF(t_3h_5h), "3h 5h"}};
2595
2596 ExpectedResult fullDataDe[] = {
2597 {t_1m_59_9996s, UPRV_LENGTHOF(t_1m_59_9996s), "1 Minute, 59,9996 Sekunden"},
2598 {t_19m, UPRV_LENGTHOF(t_19m), "19 Minuten"},
2599 {t_1h_23_5s, UPRV_LENGTHOF(t_1h_23_5s), "1 Stunde, 23,5 Sekunden"},
2600 {t_1h_23_5m, UPRV_LENGTHOF(t_1h_23_5m), "1 Stunde, 23,5 Minuten"},
2601 {t_1h_0m_23s, UPRV_LENGTHOF(t_1h_0m_23s), "1 Stunde, 0 Minuten und 23 Sekunden"},
2602 {t_2y_5M_3w_4d, UPRV_LENGTHOF(t_2y_5M_3w_4d), "2 Jahre, 5 Monate, 3 Wochen und 4 Tage"}};
2603
2604 ExpectedResult numericDataDe[] = {
2605 {t_1m_59_9996s, UPRV_LENGTHOF(t_1m_59_9996s), "1:59,9996"},
2606 {t_19m, UPRV_LENGTHOF(t_19m), "19 Min."},
2607 {t_1h_23_5s, UPRV_LENGTHOF(t_1h_23_5s), "1:00:23,5"},
2608 {t_1h_23_5m, UPRV_LENGTHOF(t_1h_23_5m), "1:23,5"},
2609 {t_1h_0m_23s, UPRV_LENGTHOF(t_1h_0m_23s), "1:00:23"},
2610 {t_5h_17m, UPRV_LENGTHOF(t_5h_17m), "5:17"},
2611 {t_19m_28s, UPRV_LENGTHOF(t_19m_28s), "19:28"},
2612 {t_2y_5M_3w_4d, UPRV_LENGTHOF(t_2y_5M_3w_4d), "2 J, 5 M, 3 W und 4 T"},
2613 {t_0h_0m_17s, UPRV_LENGTHOF(t_0h_0m_17s), "0:00:17"},
2614 {t_6h_56_92m, UPRV_LENGTHOF(t_6h_56_92m), "6:56,92"},
2615 {t_3h_5h, UPRV_LENGTHOF(t_3h_5h), "3 Std., 5 Std."}};
2616
2617 ExpectedResult numericDataBn[] = {
2618 {t_1m_59_9996s, UPRV_LENGTHOF(t_1m_59_9996s), "\\u09E7:\\u09EB\\u09EF.\\u09EF\\u09EF\\u09EF\\u09EC"},
2619 {t_19m, UPRV_LENGTHOF(t_19m), "\\u09E7\\u09EF \\u09AE\\u09BF\\u0983"},
2620 {t_1h_23_5s, UPRV_LENGTHOF(t_1h_23_5s), "\\u09E7:\\u09E6\\u09E6:\\u09E8\\u09E9.\\u09EB"},
2621 {t_1h_0m_23s, UPRV_LENGTHOF(t_1h_0m_23s), "\\u09E7:\\u09E6\\u09E6:\\u09E8\\u09E9"},
2622 {t_1h_23_5m, UPRV_LENGTHOF(t_1h_23_5m), "\\u09E7:\\u09E8\\u09E9.\\u09EB"},
2623 {t_5h_17m, UPRV_LENGTHOF(t_5h_17m), "\\u09EB:\\u09E7\\u09ED"},
2624 {t_19m_28s, UPRV_LENGTHOF(t_19m_28s), "\\u09E7\\u09EF:\\u09E8\\u09EE"},
2625 {t_2y_5M_3w_4d, UPRV_LENGTHOF(t_2y_5M_3w_4d), "\\u09E8 \\u09AC\\u099B\\u09B0, \\u09EB \\u09AE\\u09BE\\u09B8, \\u09E9 \\u09B8\\u09AA\\u09CD\\u09A4\\u09BE\\u09B9, \\u09EA \\u09A6\\u09BF\\u09A8"},
2626 {t_0h_0m_17s, UPRV_LENGTHOF(t_0h_0m_17s), "\\u09E6:\\u09E6\\u09E6:\\u09E7\\u09ED"},
2627 {t_6h_56_92m, UPRV_LENGTHOF(t_6h_56_92m), "\\u09EC:\\u09EB\\u09EC.\\u09EF\\u09E8"},
2628 {t_3h_5h, UPRV_LENGTHOF(t_3h_5h), "\\u09E9 \\u0998\\u0983, \\u09EB \\u0998\\u0983"}};
2629
2630 ExpectedResult numericDataBnLatn[] = {
2631 {t_1m_59_9996s, UPRV_LENGTHOF(t_1m_59_9996s), "1:59.9996"},
2632 {t_19m, UPRV_LENGTHOF(t_19m), "19 \\u09AE\\u09BF\\u0983"},
2633 {t_1h_23_5s, UPRV_LENGTHOF(t_1h_23_5s), "1:00:23.5"},
2634 {t_1h_0m_23s, UPRV_LENGTHOF(t_1h_0m_23s), "1:00:23"},
2635 {t_1h_23_5m, UPRV_LENGTHOF(t_1h_23_5m), "1:23.5"},
2636 {t_5h_17m, UPRV_LENGTHOF(t_5h_17m), "5:17"},
2637 {t_19m_28s, UPRV_LENGTHOF(t_19m_28s), "19:28"},
2638 {t_2y_5M_3w_4d, UPRV_LENGTHOF(t_2y_5M_3w_4d), "2 \\u09AC\\u099B\\u09B0, 5 \\u09AE\\u09BE\\u09B8, 3 \\u09B8\\u09AA\\u09CD\\u09A4\\u09BE\\u09B9, 4 \\u09A6\\u09BF\\u09A8"},
2639 {t_0h_0m_17s, UPRV_LENGTHOF(t_0h_0m_17s), "0:00:17"},
2640 {t_6h_56_92m, UPRV_LENGTHOF(t_6h_56_92m), "6:56.92"},
2641 {t_3h_5h, UPRV_LENGTHOF(t_3h_5h), "3 \\u0998\\u0983, 5 \\u0998\\u0983"}};
2642
2643 ExpectedResult fullDataSpellout[] = {
2644 {t_1y, UPRV_LENGTHOF(t_1y), "one year"},
2645 {t_5M, UPRV_LENGTHOF(t_5M), "five months"},
2646 {t_4d, UPRV_LENGTHOF(t_4d), "four days"},
2647 {t_2h, UPRV_LENGTHOF(t_2h), "two hours"},
2648 {t_19m, UPRV_LENGTHOF(t_19m), "nineteen minutes"}};
2649
2650 ExpectedResult fullDataSpelloutFr[] = {
2651 {t_1y, UPRV_LENGTHOF(t_1y), "un\\u00A0an"},
2652 {t_5M, UPRV_LENGTHOF(t_5M), "cinq\\u00A0mois"},
2653 {t_4d, UPRV_LENGTHOF(t_4d), "quatre\\u00A0jours"},
2654 {t_2h, UPRV_LENGTHOF(t_2h), "deux\\u00A0heures"},
2655 {t_19m, UPRV_LENGTHOF(t_19m), "dix-neuf minutes"}};
2656
2657 Locale en(Locale::getEnglish());
2658 LocalPointer<NumberFormat> nf(NumberFormat::createInstance(en, status));
2659 if (U_FAILURE(status)) {
2660 dataerrln("Error creating number format en object - %s", u_errorName(status));
2661 return;
2662 }
2663 nf->setMaximumFractionDigits(4);
2664 MeasureFormat mf(en, UMEASFMT_WIDTH_WIDE, nf->clone(), status);
2665 if (!assertSuccess("Error creating measure format en WIDE", status)) {
2666 return;
2667 }
2668 verifyFormat("en WIDE", mf, fullData, UPRV_LENGTHOF(fullData));
2669
2670 // exercise copy constructor
2671 {
2672 MeasureFormat mf2(mf);
2673 verifyFormat("en WIDE copy", mf2, fullData, UPRV_LENGTHOF(fullData));
2674 }
2675 // exercise clone
2676 {
2677 MeasureFormat *mf3 = mf.clone();
2678 verifyFormat("en WIDE copy", *mf3, fullData, UPRV_LENGTHOF(fullData));
2679 delete mf3;
2680 }
2681 mf = MeasureFormat(en, UMEASFMT_WIDTH_SHORT, nf->clone(), status);
2682 if (!assertSuccess("Error creating measure format en SHORT", status)) {
2683 return;
2684 }
2685 verifyFormat("en SHORT", mf, abbrevData, UPRV_LENGTHOF(abbrevData));
2686 mf = MeasureFormat(en, UMEASFMT_WIDTH_NARROW, nf->clone(), status);
2687 if (!assertSuccess("Error creating measure format en NARROW", status)) {
2688 return;
2689 }
2690 verifyFormat("en NARROW", mf, narrowData, UPRV_LENGTHOF(narrowData));
2691 mf = MeasureFormat(en, UMEASFMT_WIDTH_NUMERIC, nf->clone(), status);
2692 if (!assertSuccess("Error creating measure format en NUMERIC", status)) {
2693 return;
2694 }
2695 verifyFormat("en NUMERIC", mf, numericData, UPRV_LENGTHOF(numericData));
2696
2697 Locale de(Locale::getGerman());
2698 nf.adoptInstead(NumberFormat::createInstance(de, status));
2699 if (!assertSuccess("Error creating number format de object", status)) {
2700 return;
2701 }
2702 nf->setMaximumFractionDigits(4);
2703 mf = MeasureFormat(de, UMEASFMT_WIDTH_WIDE, nf->clone(), status);
2704 if (!assertSuccess("Error creating measure format de WIDE", status)) {
2705 return;
2706 }
2707 verifyFormat("de WIDE", mf, fullDataDe, UPRV_LENGTHOF(fullDataDe));
2708 mf = MeasureFormat(de, UMEASFMT_WIDTH_NUMERIC, nf->clone(), status);
2709 if (!assertSuccess("Error creating measure format de NUMERIC", status)) {
2710 return;
2711 }
2712 verifyFormat("de NUMERIC", mf, numericDataDe, UPRV_LENGTHOF(numericDataDe));
2713
2714 Locale bengali("bn");
2715 nf.adoptInstead(NumberFormat::createInstance(bengali, status));
2716 if (!assertSuccess("Error creating number format de object", status)) {
2717 return;
2718 }
2719 nf->setMaximumFractionDigits(4);
2720 mf = MeasureFormat(bengali, UMEASFMT_WIDTH_NUMERIC, nf->clone(), status);
2721 if (!assertSuccess("Error creating measure format bn NUMERIC", status)) {
2722 return;
2723 }
2724 verifyFormat("bn NUMERIC", mf, numericDataBn, UPRV_LENGTHOF(numericDataBn));
2725
2726 Locale bengaliLatin("bn-u-nu-latn");
2727 nf.adoptInstead(NumberFormat::createInstance(bengaliLatin, status));
2728 if (!assertSuccess("Error creating number format de object", status)) {
2729 return;
2730 }
2731 nf->setMaximumFractionDigits(4);
2732 mf = MeasureFormat(bengaliLatin, UMEASFMT_WIDTH_NUMERIC, nf->clone(), status);
2733 if (!assertSuccess("Error creating measure format bn-u-nu-latn NUMERIC", status)) {
2734 return;
2735 }
2736 verifyFormat("bn-u-nu-latn NUMERIC", mf, numericDataBnLatn, UPRV_LENGTHOF(numericDataBnLatn));
2737
2738 status = U_ZERO_ERROR;
2739 LocalPointer<RuleBasedNumberFormat> rbnf(new RuleBasedNumberFormat(URBNF_SPELLOUT, en, status));
2740 if (U_FAILURE(status)) {
2741 dataerrln("Error creating rbnf en object - %s", u_errorName(status));
2742 return;
2743 }
2744 mf = MeasureFormat(en, UMEASFMT_WIDTH_WIDE, rbnf->clone(), status);
2745 if (!assertSuccess("Error creating measure format en WIDE with rbnf", status)) {
2746 return;
2747 }
2748 verifyFormat("en WIDE rbnf", mf, fullDataSpellout, UPRV_LENGTHOF(fullDataSpellout));
2749
2750 Locale fr(Locale::getFrench());
2751 LocalPointer<RuleBasedNumberFormat> rbnffr(new RuleBasedNumberFormat(URBNF_SPELLOUT, fr, status));
2752 if (U_FAILURE(status)) {
2753 dataerrln("Error creating rbnf fr object - %s", u_errorName(status));
2754 return;
2755 }
2756 mf = MeasureFormat(fr, UMEASFMT_WIDTH_WIDE, rbnffr->clone(), status);
2757 if (!assertSuccess("Error creating measure format fr WIDE with rbnf", status)) {
2758 return;
2759 }
2760 verifyFormat("fr WIDE rbnf", mf, fullDataSpelloutFr, UPRV_LENGTHOF(fullDataSpellout));
2761 }
2762
Test10219FractionalPlurals()2763 void MeasureFormatTest::Test10219FractionalPlurals() {
2764 Locale en(Locale::getEnglish());
2765 double values[] = {1.588, 1.011};
2766 const char *expected[2][3] = {
2767 {"1 minute", "1.5 minutes", "1.58 minutes"},
2768 {"1 minute", "1.0 minutes", "1.01 minutes"}
2769 };
2770 UErrorCode status = U_ZERO_ERROR;
2771 for (int j = 0; j < UPRV_LENGTHOF(values); j++) {
2772 for (int i = 0; i < UPRV_LENGTHOF(expected[j]); i++) {
2773 DecimalFormat *df =
2774 (DecimalFormat *) NumberFormat::createInstance(en, status);
2775 if (U_FAILURE(status)) {
2776 dataerrln("Error creating Number format - %s", u_errorName(status));
2777 return;
2778 }
2779 df->setRoundingMode(DecimalFormat::kRoundDown);
2780 df->setMinimumFractionDigits(i);
2781 df->setMaximumFractionDigits(i);
2782 MeasureFormat mf(en, UMEASFMT_WIDTH_WIDE, df, status);
2783 if (!assertSuccess("Error creating Measure format", status)) {
2784 return;
2785 }
2786 Measure measure(values[j], MeasureUnit::createMinute(status), status);
2787 if (!assertSuccess("Error creating Measure unit", status)) {
2788 return;
2789 }
2790 verifyFormat("Test10219", mf, &measure, 1, expected[j][i]);
2791 }
2792 }
2793 }
2794
toMeasureUnit(MeasureUnit * adopted)2795 static MeasureUnit toMeasureUnit(MeasureUnit *adopted) {
2796 MeasureUnit result(*adopted);
2797 delete adopted;
2798 return result;
2799 }
2800
TestGreek()2801 void MeasureFormatTest::TestGreek() {
2802 Locale locales[] = {Locale("el_GR"), Locale("el")};
2803 UErrorCode status = U_ZERO_ERROR;
2804 MeasureUnit units[] = {
2805 toMeasureUnit(MeasureUnit::createSecond(status)),
2806 toMeasureUnit(MeasureUnit::createMinute(status)),
2807 toMeasureUnit(MeasureUnit::createHour(status)),
2808 toMeasureUnit(MeasureUnit::createDay(status)),
2809 toMeasureUnit(MeasureUnit::createWeek(status)),
2810 toMeasureUnit(MeasureUnit::createMonth(status)),
2811 toMeasureUnit(MeasureUnit::createYear(status))};
2812 if (!assertSuccess("Error creating Measure units", status)) {
2813 return;
2814 }
2815 UMeasureFormatWidth styles[] = {
2816 UMEASFMT_WIDTH_WIDE,
2817 UMEASFMT_WIDTH_SHORT};
2818 int32_t numbers[] = {1, 7};
2819 const char *expected[] = {
2820 // "el_GR" 1 wide
2821 "1 \\u03B4\\u03B5\\u03C5\\u03C4\\u03B5\\u03C1\\u03CC\\u03BB\\u03B5\\u03C0\\u03C4\\u03BF",
2822 "1 \\u03BB\\u03B5\\u03C0\\u03C4\\u03CC",
2823 "1 \\u03CE\\u03C1\\u03B1",
2824 "1 \\u03B7\\u03BC\\u03AD\\u03C1\\u03B1",
2825 "1 \\u03B5\\u03B2\\u03B4\\u03BF\\u03BC\\u03AC\\u03B4\\u03B1",
2826 "1 \\u03BC\\u03AE\\u03BD\\u03B1\\u03C2",
2827 "1 \\u03AD\\u03C4\\u03BF\\u03C2",
2828 // "el_GR" 1 short
2829 "1 \\u03B4\\u03B5\\u03C5\\u03C4.",
2830 "1 \\u03BB\\u03B5\\u03C0.",
2831 "1 \\u03CE\\u03C1\\u03B1",
2832 "1 \\u03B7\\u03BC\\u03AD\\u03C1\\u03B1",
2833 "1 \\u03B5\\u03B2\\u03B4.",
2834 "1 \\u03BC\\u03AE\\u03BD.",
2835 "1 \\u03AD\\u03C4.", // year (one)
2836 // "el_GR" 7 wide
2837 "7 \\u03B4\\u03B5\\u03C5\\u03C4\\u03B5\\u03C1\\u03CC\\u03BB\\u03B5\\u03C0\\u03C4\\u03B1",
2838 "7 \\u03BB\\u03B5\\u03C0\\u03C4\\u03AC",
2839 "7 \\u03CE\\u03C1\\u03B5\\u03C2",
2840 "7 \\u03B7\\u03BC\\u03AD\\u03C1\\u03B5\\u03C2",
2841 "7 \\u03B5\\u03B2\\u03B4\\u03BF\\u03BC\\u03AC\\u03B4\\u03B5\\u03C2",
2842 "7 \\u03BC\\u03AE\\u03BD\\u03B5\\u03C2",
2843 "7 \\u03AD\\u03C4\\u03B7",
2844 // "el_GR" 7 short
2845 "7 \\u03B4\\u03B5\\u03C5\\u03C4.",
2846 "7 \\u03BB\\u03B5\\u03C0.",
2847 "7 \\u03CE\\u03C1.", // hour (other)
2848 "7 \\u03B7\\u03BC\\u03AD\\u03C1\\u03B5\\u03C2",
2849 "7 \\u03B5\\u03B2\\u03B4.",
2850 "7 \\u03BC\\u03AE\\u03BD.",
2851 "7 \\u03AD\\u03C4.", // year (other)
2852
2853 // "el" 1 wide
2854 "1 \\u03B4\\u03B5\\u03C5\\u03C4\\u03B5\\u03C1\\u03CC\\u03BB\\u03B5\\u03C0\\u03C4\\u03BF",
2855 "1 \\u03BB\\u03B5\\u03C0\\u03C4\\u03CC",
2856 "1 \\u03CE\\u03C1\\u03B1",
2857 "1 \\u03B7\\u03BC\\u03AD\\u03C1\\u03B1",
2858 "1 \\u03B5\\u03B2\\u03B4\\u03BF\\u03BC\\u03AC\\u03B4\\u03B1",
2859 "1 \\u03BC\\u03AE\\u03BD\\u03B1\\u03C2",
2860 "1 \\u03AD\\u03C4\\u03BF\\u03C2",
2861 // "el" 1 short
2862 "1 \\u03B4\\u03B5\\u03C5\\u03C4.",
2863 "1 \\u03BB\\u03B5\\u03C0.",
2864 "1 \\u03CE\\u03C1\\u03B1",
2865 "1 \\u03B7\\u03BC\\u03AD\\u03C1\\u03B1",
2866 "1 \\u03B5\\u03B2\\u03B4.",
2867 "1 \\u03BC\\u03AE\\u03BD.",
2868 "1 \\u03AD\\u03C4.", // year (one)
2869 // "el" 7 wide
2870 "7 \\u03B4\\u03B5\\u03C5\\u03C4\\u03B5\\u03C1\\u03CC\\u03BB\\u03B5\\u03C0\\u03C4\\u03B1",
2871 "7 \\u03BB\\u03B5\\u03C0\\u03C4\\u03AC",
2872 "7 \\u03CE\\u03C1\\u03B5\\u03C2",
2873 "7 \\u03B7\\u03BC\\u03AD\\u03C1\\u03B5\\u03C2",
2874 "7 \\u03B5\\u03B2\\u03B4\\u03BF\\u03BC\\u03AC\\u03B4\\u03B5\\u03C2",
2875 "7 \\u03BC\\u03AE\\u03BD\\u03B5\\u03C2",
2876 "7 \\u03AD\\u03C4\\u03B7",
2877 // "el" 7 short
2878 "7 \\u03B4\\u03B5\\u03C5\\u03C4.",
2879 "7 \\u03BB\\u03B5\\u03C0.",
2880 "7 \\u03CE\\u03C1.", // hour (other)
2881 "7 \\u03B7\\u03BC\\u03AD\\u03C1\\u03B5\\u03C2",
2882 "7 \\u03B5\\u03B2\\u03B4.",
2883 "7 \\u03BC\\u03AE\\u03BD.",
2884 "7 \\u03AD\\u03C4."}; // year (other)
2885
2886 int32_t counter = 0;
2887 for (int32_t locIndex = 0; locIndex < UPRV_LENGTHOF(locales); ++locIndex ) {
2888 for( int32_t numIndex = 0; numIndex < UPRV_LENGTHOF(numbers); ++numIndex ) {
2889 for ( int32_t styleIndex = 0; styleIndex < UPRV_LENGTHOF(styles); ++styleIndex ) {
2890 for ( int32_t unitIndex = 0; unitIndex < UPRV_LENGTHOF(units); ++unitIndex ) {
2891 Measure measure(numbers[numIndex], new MeasureUnit(units[unitIndex]), status);
2892 if (!assertSuccess("Error creating Measure", status)) {
2893 return;
2894 }
2895 MeasureFormat fmt(locales[locIndex], styles[styleIndex], status);
2896 if (!assertSuccess("Error creating Measure format", status)) {
2897 return;
2898 }
2899 verifyFormat("TestGreek", fmt, &measure, 1, expected[counter]);
2900 ++counter;
2901 }
2902 }
2903 }
2904 }
2905 }
2906
TestFormatSingleArg()2907 void MeasureFormatTest::TestFormatSingleArg() {
2908 UErrorCode status = U_ZERO_ERROR;
2909 MeasureFormat fmt("en", UMEASFMT_WIDTH_WIDE, status);
2910 if (!assertSuccess("Error creating formatter", status)) {
2911 return;
2912 }
2913 UnicodeString buffer;
2914 FieldPosition pos(FieldPosition::DONT_CARE);
2915 fmt.format(
2916 new Measure(3.5, MeasureUnit::createFoot(status), status),
2917 buffer,
2918 pos,
2919 status);
2920 if (!assertSuccess("Error formatting", status)) {
2921 return;
2922 }
2923 assertEquals(
2924 "TestFormatSingleArg",
2925 UnicodeString("3.5 feet"),
2926 buffer);
2927 }
2928
TestFormatMeasuresZeroArg()2929 void MeasureFormatTest::TestFormatMeasuresZeroArg() {
2930 UErrorCode status = U_ZERO_ERROR;
2931 MeasureFormat fmt("en", UMEASFMT_WIDTH_WIDE, status);
2932 verifyFormat("TestFormatMeasuresZeroArg", fmt, NULL, 0, "");
2933 }
2934
TestSimplePer()2935 void MeasureFormatTest::TestSimplePer() {
2936 Locale en("en");
2937 UErrorCode status = U_ZERO_ERROR;
2938 LocalPointer<MeasureUnit> second(MeasureUnit::createSecond(status));
2939 LocalPointer<MeasureUnit> minute(MeasureUnit::createMinute(status));
2940 LocalPointer<MeasureUnit> pound(MeasureUnit::createPound(status));
2941 if (!assertSuccess("", status)) {
2942 return;
2943 }
2944
2945 helperTestSimplePer(
2946 en, UMEASFMT_WIDTH_WIDE,
2947 1.0, *pound, *second, "1 pound per second");
2948 helperTestSimplePer(
2949 en, UMEASFMT_WIDTH_WIDE,
2950 2.0, *pound, *second, "2 pounds per second");
2951 helperTestSimplePer(
2952 en, UMEASFMT_WIDTH_WIDE,
2953 1.0, *pound, *minute, "1 pound per minute");
2954 helperTestSimplePer(
2955 en, UMEASFMT_WIDTH_WIDE,
2956 2.0, *pound, *minute, "2 pounds per minute");
2957
2958 helperTestSimplePer(
2959 en, UMEASFMT_WIDTH_SHORT, 1.0, *pound, *second, "1 lb/s");
2960 helperTestSimplePer(
2961 en, UMEASFMT_WIDTH_SHORT, 2.0, *pound, *second, "2 lb/s");
2962 helperTestSimplePer(
2963 en, UMEASFMT_WIDTH_SHORT, 1.0, *pound, *minute, "1 lb/min");
2964 helperTestSimplePer(
2965 en, UMEASFMT_WIDTH_SHORT, 2.0, *pound, *minute, "2 lb/min");
2966
2967 helperTestSimplePer(
2968 en, UMEASFMT_WIDTH_NARROW, 1.0, *pound, *second, "1#/s");
2969 helperTestSimplePer(
2970 en, UMEASFMT_WIDTH_NARROW, 2.0, *pound, *second, "2#/s");
2971 helperTestSimplePer(
2972 en, UMEASFMT_WIDTH_NARROW, 1.0, *pound, *minute, "1#/min");
2973 helperTestSimplePer(
2974 en, UMEASFMT_WIDTH_NARROW, 2.0, *pound, *minute, "2#/min");
2975
2976 helperTestSimplePer(
2977 en, UMEASFMT_WIDTH_SHORT,
2978 23.3, *pound, *second, "23.3 lb/s",
2979 NumberFormat::kDecimalSeparatorField,
2980 2, 3);
2981
2982 helperTestSimplePer(
2983 en, UMEASFMT_WIDTH_SHORT,
2984 23.3, *pound, *second, "23.3 lb/s",
2985 NumberFormat::kIntegerField,
2986 0, 2);
2987
2988 helperTestSimplePer(
2989 en, UMEASFMT_WIDTH_SHORT,
2990 23.3, *pound, *minute, "23.3 lb/min",
2991 NumberFormat::kDecimalSeparatorField,
2992 2, 3);
2993
2994 helperTestSimplePer(
2995 en, UMEASFMT_WIDTH_SHORT,
2996 23.3, *pound, *minute, "23.3 lb/min",
2997 NumberFormat::kIntegerField,
2998 0, 2);
2999 }
3000
TestNumeratorPlurals()3001 void MeasureFormatTest::TestNumeratorPlurals() {
3002 Locale pl("pl");
3003 UErrorCode status = U_ZERO_ERROR;
3004 LocalPointer<MeasureUnit> second(MeasureUnit::createSecond(status));
3005 LocalPointer<MeasureUnit> foot(MeasureUnit::createFoot(status));
3006 if (!assertSuccess("", status)) {
3007 return;
3008 }
3009
3010 helperTestSimplePer(
3011 pl,
3012 UMEASFMT_WIDTH_WIDE,
3013 1.0, *foot, *second, "1 stopa na sekund\\u0119");
3014 helperTestSimplePer(
3015 pl,
3016 UMEASFMT_WIDTH_WIDE,
3017 2.0, *foot, *second, "2 stopy na sekund\\u0119");
3018 helperTestSimplePer(
3019 pl,
3020 UMEASFMT_WIDTH_WIDE,
3021 5.0, *foot, *second, "5 st\\u00f3p na sekund\\u0119");
3022 helperTestSimplePer(
3023 pl, UMEASFMT_WIDTH_WIDE,
3024 1.5, *foot, *second, "1,5 stopy na sekund\\u0119");
3025 }
3026
helperTestSimplePer(const Locale & locale,UMeasureFormatWidth width,double value,const MeasureUnit & unit,const MeasureUnit & perUnit,const char * expected)3027 void MeasureFormatTest::helperTestSimplePer(
3028 const Locale &locale,
3029 UMeasureFormatWidth width,
3030 double value,
3031 const MeasureUnit &unit,
3032 const MeasureUnit &perUnit,
3033 const char *expected) {
3034 helperTestSimplePer(
3035 locale,
3036 width,
3037 value,
3038 unit,
3039 perUnit,
3040 expected,
3041 FieldPosition::DONT_CARE,
3042 0,
3043 0);
3044 }
3045
helperTestSimplePer(const Locale & locale,UMeasureFormatWidth width,double value,const MeasureUnit & unit,const MeasureUnit & perUnit,const char * expected,int32_t field,int32_t expected_start,int32_t expected_end)3046 void MeasureFormatTest::helperTestSimplePer(
3047 const Locale &locale,
3048 UMeasureFormatWidth width,
3049 double value,
3050 const MeasureUnit &unit,
3051 const MeasureUnit &perUnit,
3052 const char *expected,
3053 int32_t field,
3054 int32_t expected_start,
3055 int32_t expected_end) {
3056 UErrorCode status = U_ZERO_ERROR;
3057 FieldPosition pos(field);
3058 MeasureFormat fmt(locale, width, status);
3059 if (!assertSuccess("Error creating format object", status)) {
3060 return;
3061 }
3062 Measure measure(value, unit.clone(), status);
3063 if (!assertSuccess("Error creating measure object", status)) {
3064 return;
3065 }
3066 UnicodeString prefix("prefix: ");
3067 UnicodeString buffer(prefix);
3068 fmt.formatMeasurePerUnit(
3069 measure,
3070 perUnit,
3071 buffer,
3072 pos,
3073 status);
3074 if (!assertSuccess("Error formatting measures with per", status)) {
3075 return;
3076 }
3077 UnicodeString uexpected(expected);
3078 uexpected = prefix + uexpected;
3079 assertEquals(
3080 "TestSimplePer",
3081 uexpected.unescape(),
3082 buffer);
3083 if (field != FieldPosition::DONT_CARE) {
3084 assertEquals(
3085 "Start", expected_start, pos.getBeginIndex() - prefix.length());
3086 assertEquals(
3087 "End", expected_end, pos.getEndIndex() - prefix.length());
3088 }
3089 }
3090
TestMultiples()3091 void MeasureFormatTest::TestMultiples() {
3092 Locale ru("ru");
3093 Locale en("en");
3094 helperTestMultiples(en, UMEASFMT_WIDTH_WIDE, "2 miles, 1 foot, 2.3 inches");
3095 helperTestMultiples(en, UMEASFMT_WIDTH_SHORT, "2 mi, 1 ft, 2.3 in");
3096 helperTestMultiples(en, UMEASFMT_WIDTH_NARROW, "2mi 1\\u2032 2.3\\u2033");
3097 helperTestMultiples(ru, UMEASFMT_WIDTH_WIDE, "2 \\u043C\\u0438\\u043B\\u0438 1 \\u0444\\u0443\\u0442 2,3 \\u0434\\u044E\\u0439\\u043C\\u0430");
3098 helperTestMultiples(ru, UMEASFMT_WIDTH_SHORT, "2 \\u043C\\u0438 1 \\u0444\\u0442 2,3 \\u0434\\u044E\\u0439\\u043C.");
3099 helperTestMultiples(ru, UMEASFMT_WIDTH_NARROW, "2 \\u043C\\u0438\\u043B\\u044C 1 \\u0444\\u0442 2,3 \\u0434\\u044E\\u0439\\u043C\\u0430");
3100 }
3101
helperTestMultiples(const Locale & locale,UMeasureFormatWidth width,const char * expected)3102 void MeasureFormatTest::helperTestMultiples(
3103 const Locale &locale,
3104 UMeasureFormatWidth width,
3105 const char *expected) {
3106 UErrorCode status = U_ZERO_ERROR;
3107 FieldPosition pos(FieldPosition::DONT_CARE);
3108 MeasureFormat fmt(locale, width, status);
3109 if (!assertSuccess("Error creating format object", status)) {
3110 return;
3111 }
3112 Measure measures[] = {
3113 Measure(2.0, MeasureUnit::createMile(status), status),
3114 Measure(1.0, MeasureUnit::createFoot(status), status),
3115 Measure(2.3, MeasureUnit::createInch(status), status)};
3116 if (!assertSuccess("Error creating measures", status)) {
3117 return;
3118 }
3119 UnicodeString buffer;
3120 fmt.formatMeasures(measures, UPRV_LENGTHOF(measures), buffer, pos, status);
3121 if (!assertSuccess("Error formatting measures", status)) {
3122 return;
3123 }
3124 assertEquals("TestMultiples", UnicodeString(expected).unescape(), buffer);
3125 }
3126
TestManyLocaleDurations()3127 void MeasureFormatTest::TestManyLocaleDurations() {
3128 UErrorCode status = U_ZERO_ERROR;
3129 Measure measures[] = {
3130 Measure(5.0, MeasureUnit::createHour(status), status),
3131 Measure(37.0, MeasureUnit::createMinute(status), status)};
3132 if (!assertSuccess("Error creating measures", status)) {
3133 return;
3134 }
3135 helperTestManyLocaleDurations("da", UMEASFMT_WIDTH_NARROW, measures, UPRV_LENGTHOF(measures), "5 t og 37 m");
3136 helperTestManyLocaleDurations("da", UMEASFMT_WIDTH_NUMERIC, measures, UPRV_LENGTHOF(measures), "5.37");
3137 helperTestManyLocaleDurations("de", UMEASFMT_WIDTH_NARROW, measures, UPRV_LENGTHOF(measures), "5 Std., 37 Min.");
3138 helperTestManyLocaleDurations("de", UMEASFMT_WIDTH_NUMERIC, measures, UPRV_LENGTHOF(measures), "5:37");
3139 helperTestManyLocaleDurations("en", UMEASFMT_WIDTH_NARROW, measures, UPRV_LENGTHOF(measures), "5h 37m");
3140 helperTestManyLocaleDurations("en", UMEASFMT_WIDTH_NUMERIC, measures, UPRV_LENGTHOF(measures), "5:37");
3141 helperTestManyLocaleDurations("en_GB", UMEASFMT_WIDTH_NARROW, measures, UPRV_LENGTHOF(measures), "5h 37m");
3142 helperTestManyLocaleDurations("en_GB", UMEASFMT_WIDTH_NUMERIC, measures, UPRV_LENGTHOF(measures), "5:37");
3143 helperTestManyLocaleDurations("es", UMEASFMT_WIDTH_NARROW, measures, UPRV_LENGTHOF(measures), "5h 37min");
3144 helperTestManyLocaleDurations("es", UMEASFMT_WIDTH_NUMERIC, measures, UPRV_LENGTHOF(measures), "5:37");
3145 helperTestManyLocaleDurations("fi", UMEASFMT_WIDTH_NARROW, measures, UPRV_LENGTHOF(measures), "5t 37min");
3146 helperTestManyLocaleDurations("fi", UMEASFMT_WIDTH_NUMERIC, measures, UPRV_LENGTHOF(measures), "5.37");
3147 helperTestManyLocaleDurations("fr", UMEASFMT_WIDTH_NARROW, measures, UPRV_LENGTHOF(measures), "5h 37min");
3148 helperTestManyLocaleDurations("fr", UMEASFMT_WIDTH_NUMERIC, measures, UPRV_LENGTHOF(measures), "5:37");
3149 helperTestManyLocaleDurations("is", UMEASFMT_WIDTH_NARROW, measures, UPRV_LENGTHOF(measures), "5 klst. og 37 m\\u00EDn.");
3150 helperTestManyLocaleDurations("is", UMEASFMT_WIDTH_NUMERIC, measures, UPRV_LENGTHOF(measures), "5:37");
3151 helperTestManyLocaleDurations("ja", UMEASFMT_WIDTH_NARROW, measures, UPRV_LENGTHOF(measures), "5h37m");
3152 helperTestManyLocaleDurations("ja", UMEASFMT_WIDTH_NUMERIC, measures, UPRV_LENGTHOF(measures), "5:37");
3153 helperTestManyLocaleDurations("nb", UMEASFMT_WIDTH_NARROW, measures, UPRV_LENGTHOF(measures), "5t, 37m");
3154 helperTestManyLocaleDurations("nb", UMEASFMT_WIDTH_NUMERIC, measures, UPRV_LENGTHOF(measures), "5:37");
3155 helperTestManyLocaleDurations("nl", UMEASFMT_WIDTH_NARROW, measures, UPRV_LENGTHOF(measures), "5 u, 37 m");
3156 helperTestManyLocaleDurations("nl", UMEASFMT_WIDTH_NUMERIC, measures, UPRV_LENGTHOF(measures), "5:37");
3157 helperTestManyLocaleDurations("nn", UMEASFMT_WIDTH_NARROW, measures, UPRV_LENGTHOF(measures), "5t 37m");
3158 helperTestManyLocaleDurations("nn", UMEASFMT_WIDTH_NUMERIC, measures, UPRV_LENGTHOF(measures), "5:37");
3159 helperTestManyLocaleDurations("sv", UMEASFMT_WIDTH_NARROW, measures, UPRV_LENGTHOF(measures), "5h 37m");
3160 helperTestManyLocaleDurations("sv", UMEASFMT_WIDTH_NUMERIC, measures, UPRV_LENGTHOF(measures), "5:37");
3161 helperTestManyLocaleDurations("zh", UMEASFMT_WIDTH_NARROW, measures, UPRV_LENGTHOF(measures), "5\\u5C0F\\u65F637\\u5206\\u949F");
3162 helperTestManyLocaleDurations("zh", UMEASFMT_WIDTH_NUMERIC, measures, UPRV_LENGTHOF(measures), "5:37");
3163 }
3164
helperTestManyLocaleDurations(const char * localeID,UMeasureFormatWidth width,const Measure * measures,int32_t measureCount,const char * expected)3165 void MeasureFormatTest::helperTestManyLocaleDurations( const char *localeID,
3166 UMeasureFormatWidth width,
3167 const Measure *measures,
3168 int32_t measureCount,
3169 const char *expected) {
3170 UErrorCode status = U_ZERO_ERROR;
3171 MeasureFormat fmt(Locale(localeID), width, status);
3172 if (U_FAILURE(status)) {
3173 errln("Could not create MeasureFormat for locale %s, width %d, status: %s", localeID, (int)width, u_errorName(status));
3174 return;
3175 }
3176 UnicodeString buffer;
3177 FieldPosition pos(FieldPosition::DONT_CARE);
3178 fmt.formatMeasures(measures, measureCount, buffer, pos, status);
3179 if (U_FAILURE(status)) {
3180 errln("MeasureFormat::formatMeasures failed for locale %s, width %d, status: %s", localeID, (int)width, u_errorName(status));
3181 return;
3182 }
3183 UnicodeString expStr(UnicodeString(expected).unescape());
3184 if (buffer != expStr) {
3185 errln("MeasureFormat::formatMeasures for locale " + UnicodeString(localeID) + ", width " + width + ", expected \"" + expStr + "\", got \"" + buffer + "\"");
3186 }
3187 }
3188
TestGram()3189 void MeasureFormatTest::TestGram() {
3190 UErrorCode status = U_ZERO_ERROR;
3191 MeasureFormat fmt("en", UMEASFMT_WIDTH_SHORT, status);
3192 if (!assertSuccess("Error creating format object", status)) {
3193 return;
3194 }
3195 Measure gram((double)1, MeasureUnit::createGram(status), status);
3196 Measure gforce((double)1, MeasureUnit::createGForce(status), status);
3197 if (!assertSuccess("Error creating measures", status)) {
3198 return;
3199 }
3200 verifyFormat("TestGram", fmt, &gram, 1, "1 g");
3201 verifyFormat("TestGram", fmt, &gforce, 1, "1 G");
3202 }
3203
TestCurrencies()3204 void MeasureFormatTest::TestCurrencies() {
3205 UChar USD[4] = {};
3206 u_uastrcpy(USD, "USD");
3207 UErrorCode status = U_ZERO_ERROR;
3208 CurrencyUnit USD_unit(USD, status);
3209 assertEquals("Currency Unit", USD, USD_unit.getISOCurrency());
3210 if (!assertSuccess("Error creating CurrencyUnit", status)) {
3211 return;
3212 }
3213 CurrencyAmount USD_1(1.0, USD, status);
3214 assertEquals("Currency Code", USD, USD_1.getISOCurrency());
3215 CurrencyAmount USD_2(2.0, USD, status);
3216 CurrencyAmount USD_NEG_1(-1.0, USD, status);
3217 if (!assertSuccess("Error creating currencies", status)) {
3218 return;
3219 }
3220 Locale en("en");
3221 MeasureFormat fmt(en, UMEASFMT_WIDTH_WIDE, status);
3222 if (!assertSuccess("Error creating format object", status)) {
3223 return;
3224 }
3225 verifyFormat("TestCurrenciesWide", fmt, &USD_NEG_1, 1, "-1.00 US dollars");
3226 verifyFormat("TestCurrenciesWide", fmt, &USD_1, 1, "1.00 US dollars");
3227 verifyFormat("TestCurrenciesWide", fmt, &USD_2, 1, "2.00 US dollars");
3228 fmt = MeasureFormat(en, UMEASFMT_WIDTH_SHORT, status);
3229 if (!assertSuccess("Error creating format object", status)) {
3230 return;
3231 }
3232 verifyFormat("TestCurrenciesShort", fmt, &USD_NEG_1, 1, "-USD\\u00A01.00");
3233 verifyFormat("TestCurrenciesShort", fmt, &USD_1, 1, "USD\\u00A01.00");
3234 verifyFormat("TestCurrenciesShort", fmt, &USD_2, 1, "USD\\u00A02.00");
3235 fmt = MeasureFormat(en, UMEASFMT_WIDTH_NARROW, status);
3236 if (!assertSuccess("Error creating format object", status)) {
3237 return;
3238 }
3239 verifyFormat("TestCurrenciesNarrow", fmt, &USD_NEG_1, 1, "-$1.00");
3240 verifyFormat("TestCurrenciesNarrow", fmt, &USD_1, 1, "$1.00");
3241 verifyFormat("TestCurrenciesNarrow", fmt, &USD_2, 1, "$2.00");
3242 fmt = MeasureFormat(en, UMEASFMT_WIDTH_NUMERIC, status);
3243 if (!assertSuccess("Error creating format object", status)) {
3244 return;
3245 }
3246 verifyFormat("TestCurrenciesNumeric", fmt, &USD_NEG_1, 1, "-$1.00");
3247 verifyFormat("TestCurrenciesNumeric", fmt, &USD_1, 1, "$1.00");
3248 verifyFormat("TestCurrenciesNumeric", fmt, &USD_2, 1, "$2.00");
3249 }
3250
TestDisplayNames()3251 void MeasureFormatTest::TestDisplayNames() {
3252 UErrorCode status = U_ZERO_ERROR;
3253 helperTestDisplayName( MeasureUnit::createYear(status), "en", UMEASFMT_WIDTH_WIDE, "years" );
3254 helperTestDisplayName( MeasureUnit::createYear(status), "ja", UMEASFMT_WIDTH_WIDE, "\\u5E74" );
3255 helperTestDisplayName( MeasureUnit::createYear(status), "es", UMEASFMT_WIDTH_WIDE, "a\\u00F1os" );
3256 helperTestDisplayName( MeasureUnit::createYear(status), "pt", UMEASFMT_WIDTH_WIDE, "anos" );
3257 helperTestDisplayName( MeasureUnit::createYear(status), "pt-PT", UMEASFMT_WIDTH_WIDE, "anos" );
3258 helperTestDisplayName( MeasureUnit::createAmpere(status), "en", UMEASFMT_WIDTH_WIDE, "amperes" );
3259 helperTestDisplayName( MeasureUnit::createAmpere(status), "ja", UMEASFMT_WIDTH_WIDE, "\\u30A2\\u30F3\\u30DA\\u30A2" );
3260 helperTestDisplayName( MeasureUnit::createAmpere(status), "es", UMEASFMT_WIDTH_WIDE, "amperios" );
3261 helperTestDisplayName( MeasureUnit::createAmpere(status), "pt", UMEASFMT_WIDTH_WIDE, "amperes" );
3262 helperTestDisplayName( MeasureUnit::createAmpere(status), "pt-PT", UMEASFMT_WIDTH_WIDE, "amperes" );
3263 helperTestDisplayName( MeasureUnit::createMeterPerSecondSquared(status), "pt", UMEASFMT_WIDTH_WIDE, "metros por segundo ao quadrado" );
3264 helperTestDisplayName( MeasureUnit::createMeterPerSecondSquared(status), "pt-PT", UMEASFMT_WIDTH_WIDE, "metros por segundo quadrado" );
3265 helperTestDisplayName( MeasureUnit::createSquareKilometer(status), "pt", UMEASFMT_WIDTH_NARROW, "km\\u00B2" );
3266 helperTestDisplayName( MeasureUnit::createSquareKilometer(status), "pt", UMEASFMT_WIDTH_SHORT, "km\\u00B2" );
3267 helperTestDisplayName( MeasureUnit::createSquareKilometer(status), "pt", UMEASFMT_WIDTH_WIDE, "quil\\u00F4metros quadrados" );
3268 helperTestDisplayName( MeasureUnit::createSecond(status), "pt-PT", UMEASFMT_WIDTH_NARROW, "s" );
3269 helperTestDisplayName( MeasureUnit::createSecond(status), "pt-PT", UMEASFMT_WIDTH_SHORT, "s" );
3270 helperTestDisplayName( MeasureUnit::createSecond(status), "pt-PT", UMEASFMT_WIDTH_WIDE, "segundos" );
3271 helperTestDisplayName( MeasureUnit::createSecond(status), "pt", UMEASFMT_WIDTH_NARROW, "seg" );
3272 helperTestDisplayName( MeasureUnit::createSecond(status), "pt", UMEASFMT_WIDTH_SHORT, "seg" );
3273 helperTestDisplayName( MeasureUnit::createSecond(status), "pt", UMEASFMT_WIDTH_WIDE, "segundos" );
3274 assertSuccess("Error creating measure units", status);
3275 }
3276
helperTestDisplayName(const MeasureUnit * unit,const char * localeID,UMeasureFormatWidth width,const char * expected)3277 void MeasureFormatTest::helperTestDisplayName(const MeasureUnit *unit,
3278 const char *localeID,
3279 UMeasureFormatWidth width,
3280 const char *expected) {
3281 UErrorCode status = U_ZERO_ERROR;
3282 MeasureFormat fmt(Locale(localeID), width, status);
3283 if (U_FAILURE(status)) {
3284 errln("Could not create MeasureFormat for locale %s, width %d, status: %s",
3285 localeID, (int)width, u_errorName(status));
3286 return;
3287 }
3288
3289 UnicodeString dnam = fmt.getUnitDisplayName(*unit, status);
3290 if (U_FAILURE(status)) {
3291 errln("MeasureFormat::getUnitDisplayName failed for unit %s-%s, locale %s, width %d, status: %s",
3292 unit->getType(), unit->getSubtype(), localeID, (int)width, u_errorName(status));
3293 return;
3294 }
3295
3296 UnicodeString expStr(UnicodeString(expected).unescape());
3297 if (dnam != expStr) {
3298 errln("MeasureFormat::getUnitDisplayName for unit %s-%s, locale %s, width %d: expected \"%s\", got \"%s\"",
3299 unit->getType(), unit->getSubtype(), localeID, (int)width, CStr(expStr)(), CStr(dnam)());
3300 }
3301
3302 // Delete the measure unit
3303 delete unit;
3304 }
3305
TestFieldPosition()3306 void MeasureFormatTest::TestFieldPosition() {
3307 UErrorCode status = U_ZERO_ERROR;
3308 MeasureFormat fmt("en", UMEASFMT_WIDTH_SHORT, status);
3309 if (!assertSuccess("Error creating format object", status)) {
3310 return;
3311 }
3312 Measure measure(43.5, MeasureUnit::createFoot(status), status);
3313 if (!assertSuccess("Error creating measure object 1", status)) {
3314 return;
3315 }
3316 UnicodeString prefix("123456: ");
3317 verifyFieldPosition(
3318 "",
3319 fmt,
3320 prefix,
3321 &measure,
3322 1,
3323 NumberFormat::kDecimalSeparatorField,
3324 10,
3325 11);
3326 measure = Measure(43.0, MeasureUnit::createFoot(status), status);
3327 if (!assertSuccess("Error creating measure object 2", status)) {
3328 return;
3329 }
3330 verifyFieldPosition(
3331 "",
3332 fmt,
3333 prefix,
3334 &measure,
3335 1,
3336 NumberFormat::kDecimalSeparatorField,
3337 0,
3338 0);
3339 }
3340
TestFieldPositionMultiple()3341 void MeasureFormatTest::TestFieldPositionMultiple() {
3342 UErrorCode status = U_ZERO_ERROR;
3343 MeasureFormat fmt("en", UMEASFMT_WIDTH_SHORT, status);
3344 if (!assertSuccess("Error creating format object", status)) {
3345 return;
3346 }
3347 Measure first[] = {
3348 Measure((double)354, MeasureUnit::createMeter(status), status),
3349 Measure((double)23, MeasureUnit::createCentimeter(status), status)};
3350 Measure second[] = {
3351 Measure((double)354, MeasureUnit::createMeter(status), status),
3352 Measure((double)23, MeasureUnit::createCentimeter(status), status),
3353 Measure((double)5.4, MeasureUnit::createMillimeter(status), status)};
3354 Measure third[] = {
3355 Measure((double)3, MeasureUnit::createMeter(status), status),
3356 Measure((double)23, MeasureUnit::createCentimeter(status), status),
3357 Measure((double)5, MeasureUnit::createMillimeter(status), status)};
3358 if (!assertSuccess("Error creating measure objects", status)) {
3359 return;
3360 }
3361 UnicodeString prefix("123456: ");
3362 verifyFieldPosition(
3363 "Integer",
3364 fmt,
3365 prefix,
3366 first,
3367 UPRV_LENGTHOF(first),
3368 NumberFormat::kIntegerField,
3369 8,
3370 11);
3371 verifyFieldPosition(
3372 "Decimal separator",
3373 fmt,
3374 prefix,
3375 second,
3376 UPRV_LENGTHOF(second),
3377 NumberFormat::kDecimalSeparatorField,
3378 23,
3379 24);
3380 verifyFieldPosition(
3381 "no decimal separator",
3382 fmt,
3383 prefix,
3384 third,
3385 UPRV_LENGTHOF(third),
3386 NumberFormat::kDecimalSeparatorField,
3387 0,
3388 0);
3389 }
3390
TestBadArg()3391 void MeasureFormatTest::TestBadArg() {
3392 UErrorCode status = U_ZERO_ERROR;
3393 MeasureFormat fmt("en", UMEASFMT_WIDTH_SHORT, status);
3394 if (!assertSuccess("Error creating format object", status)) {
3395 return;
3396 }
3397 FieldPosition pos(FieldPosition::DONT_CARE);
3398 UnicodeString buffer;
3399 fmt.format(
3400 9.3,
3401 buffer,
3402 pos,
3403 status);
3404 if (status != U_ILLEGAL_ARGUMENT_ERROR) {
3405 errln("Expected ILLEGAL_ARGUMENT_ERROR");
3406 }
3407 }
3408
TestEquality()3409 void MeasureFormatTest::TestEquality() {
3410 UErrorCode status = U_ZERO_ERROR;
3411 NumberFormat* nfeq = NumberFormat::createInstance("en", status);
3412 NumberFormat* nfne = NumberFormat::createInstance("fr", status);
3413 MeasureFormat fmt("en", UMEASFMT_WIDTH_SHORT, status);
3414 MeasureFormat fmtEq2("en", UMEASFMT_WIDTH_SHORT, nfeq, status);
3415 MeasureFormat fmtne1("en", UMEASFMT_WIDTH_WIDE, status);
3416 MeasureFormat fmtne2("fr", UMEASFMT_WIDTH_SHORT, status);
3417 MeasureFormat fmtne3("en", UMEASFMT_WIDTH_SHORT, nfne, status);
3418 if (U_FAILURE(status)) {
3419 dataerrln("Error creating MeasureFormats - %s", u_errorName(status));
3420 return;
3421 }
3422 MeasureFormat fmtEq(fmt);
3423 assertTrue("Equal", fmt == fmtEq);
3424 assertTrue("Equal2", fmt == fmtEq2);
3425 assertFalse("Equal Neg", fmt != fmtEq);
3426 assertTrue("Not Equal 1", fmt != fmtne1);
3427 assertFalse("Not Equal Neg 1", fmt == fmtne1);
3428 assertTrue("Not Equal 2", fmt != fmtne2);
3429 assertTrue("Not Equal 3", fmt != fmtne3);
3430 }
3431
TestGroupingSeparator()3432 void MeasureFormatTest::TestGroupingSeparator() {
3433 UErrorCode status = U_ZERO_ERROR;
3434 Locale en("en");
3435 MeasureFormat fmt(en, UMEASFMT_WIDTH_SHORT, status);
3436 if (!assertSuccess("Error creating format object", status)) {
3437 return;
3438 }
3439 Measure ms[] = {
3440 Measure((int32_t)INT32_MAX, MeasureUnit::createYear(status), status),
3441 Measure((int32_t)INT32_MIN, MeasureUnit::createMonth(status), status),
3442 Measure(-987.0, MeasureUnit::createDay(status), status),
3443 Measure(1362.0, MeasureUnit::createHour(status), status),
3444 Measure(987.0, MeasureUnit::createMinute(status), status)};
3445 FieldPosition pos(NumberFormat::kGroupingSeparatorField);
3446 UnicodeString appendTo;
3447 fmt.formatMeasures(ms, 5, appendTo, pos, status);
3448 if (!assertSuccess("Error formatting", status)) {
3449 return;
3450 }
3451 assertEquals(
3452 "grouping separator",
3453 "2,147,483,647 yrs, -2,147,483,648 mths, -987 days, 1,362 hr, 987 min",
3454 appendTo);
3455 assertEquals("begin index", 1, pos.getBeginIndex());
3456 assertEquals("end index", 2, pos.getEndIndex());
3457 }
3458
TestDoubleZero()3459 void MeasureFormatTest::TestDoubleZero() {
3460 UErrorCode status = U_ZERO_ERROR;
3461 Measure measures[] = {
3462 Measure(4.7, MeasureUnit::createHour(status), status),
3463 Measure(23.0, MeasureUnit::createMinute(status), status),
3464 Measure(16.0, MeasureUnit::createSecond(status), status)};
3465 Locale en("en");
3466 NumberFormat *nf = NumberFormat::createInstance(en, status);
3467 MeasureFormat fmt("en", UMEASFMT_WIDTH_WIDE, nf, status);
3468 UnicodeString appendTo;
3469 FieldPosition pos(FieldPosition::DONT_CARE);
3470 if (U_FAILURE(status)) {
3471 dataerrln("Error creating formatter - %s", u_errorName(status));
3472 return;
3473 }
3474 nf->setMinimumFractionDigits(2);
3475 nf->setMaximumFractionDigits(2);
3476 fmt.formatMeasures(measures, UPRV_LENGTHOF(measures), appendTo, pos, status);
3477 if (!assertSuccess("Error formatting", status)) {
3478 return;
3479 }
3480 assertEquals(
3481 "TestDoubleZero",
3482 UnicodeString("4 hours, 23 minutes, 16.00 seconds"),
3483 appendTo);
3484 measures[0] = Measure(-4.7, MeasureUnit::createHour(status), status);
3485 appendTo.remove();
3486 fmt.formatMeasures(measures, UPRV_LENGTHOF(measures), appendTo, pos, status);
3487 if (!assertSuccess("Error formatting", status)) {
3488 return;
3489 }
3490 assertEquals(
3491 "TestDoubleZero",
3492 UnicodeString("-4 hours, 23 minutes, 16.00 seconds"),
3493 appendTo);
3494 }
3495
TestUnitPerUnitResolution()3496 void MeasureFormatTest::TestUnitPerUnitResolution() {
3497 UErrorCode status = U_ZERO_ERROR;
3498 Locale en("en");
3499 MeasureFormat fmt("en", UMEASFMT_WIDTH_SHORT, status);
3500 Measure measure(50.0, MeasureUnit::createPoundForce(status), status);
3501 LocalPointer<MeasureUnit> sqInch(MeasureUnit::createSquareInch(status));
3502 if (!assertSuccess("Create of format unit and per unit", status)) {
3503 return;
3504 }
3505 FieldPosition pos(FieldPosition::DONT_CARE);
3506 UnicodeString actual;
3507 fmt.formatMeasurePerUnit(
3508 measure,
3509 *sqInch,
3510 actual,
3511 pos,
3512 status);
3513 assertEquals("", "50 psi", actual);
3514 }
3515
TestIndividualPluralFallback()3516 void MeasureFormatTest::TestIndividualPluralFallback() {
3517 // See ticket #11986 "incomplete fallback in MeasureFormat".
3518 // In CLDR 28, fr_CA temperature-generic/short has only the "one" form,
3519 // and falls back to fr for the "other" form.
3520 IcuTestErrorCode errorCode(*this, "TestIndividualPluralFallback");
3521 MeasureFormat mf("fr_CA", UMEASFMT_WIDTH_SHORT, errorCode);
3522 if (errorCode.errIfFailureAndReset("MeasureFormat mf(...) failed.")) {
3523 return;
3524 }
3525 LocalPointer<Measure> twoDeg(
3526 new Measure(2.0, MeasureUnit::createGenericTemperature(errorCode), errorCode), errorCode);
3527 if (errorCode.errIfFailureAndReset("Creating twoDeg failed.")) {
3528 return;
3529 }
3530 UnicodeString expected = UNICODE_STRING_SIMPLE("2\\u00B0").unescape();
3531 UnicodeString actual;
3532 // Formattable adopts the pointer
3533 mf.format(Formattable(twoDeg.orphan()), actual, errorCode);
3534 if (errorCode.errIfFailureAndReset("mf.format(...) failed.")) {
3535 return;
3536 }
3537 assertEquals("2 deg temp in fr_CA", expected, actual, TRUE);
3538 errorCode.errIfFailureAndReset("mf.format failed");
3539 }
3540
Test20332_PersonUnits()3541 void MeasureFormatTest::Test20332_PersonUnits() {
3542 IcuTestErrorCode status(*this, "Test20332_PersonUnits");
3543 const struct TestCase {
3544 const char* locale;
3545 MeasureUnit* unitToAdopt;
3546 UMeasureFormatWidth width;
3547 const char* expected;
3548 } cases[] = {
3549 {"en-us", MeasureUnit::createYearPerson(status), UMEASFMT_WIDTH_NARROW, "25y"},
3550 {"en-us", MeasureUnit::createYearPerson(status), UMEASFMT_WIDTH_SHORT, "25 yrs"},
3551 {"en-us", MeasureUnit::createYearPerson(status), UMEASFMT_WIDTH_WIDE, "25 years"},
3552 {"en-us", MeasureUnit::createMonthPerson(status), UMEASFMT_WIDTH_NARROW, "25m"},
3553 {"en-us", MeasureUnit::createMonthPerson(status), UMEASFMT_WIDTH_SHORT, "25 mths"},
3554 {"en-us", MeasureUnit::createMonthPerson(status), UMEASFMT_WIDTH_WIDE, "25 months"},
3555 {"en-us", MeasureUnit::createWeekPerson(status), UMEASFMT_WIDTH_NARROW, "25w"},
3556 {"en-us", MeasureUnit::createWeekPerson(status), UMEASFMT_WIDTH_SHORT, "25 wks"},
3557 {"en-us", MeasureUnit::createWeekPerson(status), UMEASFMT_WIDTH_WIDE, "25 weeks"},
3558 {"en-us", MeasureUnit::createDayPerson(status), UMEASFMT_WIDTH_NARROW, "25d"},
3559 {"en-us", MeasureUnit::createDayPerson(status), UMEASFMT_WIDTH_SHORT, "25 days"},
3560 {"en-us", MeasureUnit::createDayPerson(status), UMEASFMT_WIDTH_WIDE, "25 days"}
3561 };
3562 for (const auto& cas : cases) {
3563 MeasureFormat mf(cas.locale, cas.width, status);
3564 if (status.errIfFailureAndReset()) { return; }
3565 Measure measure(25, cas.unitToAdopt, status);
3566 if (status.errIfFailureAndReset()) { return; }
3567 verifyFormat(cas.locale, mf, &measure, 1, cas.expected);
3568 }
3569 }
3570
TestNumericTime()3571 void MeasureFormatTest::TestNumericTime() {
3572 IcuTestErrorCode status(*this, "TestNumericTime");
3573
3574 MeasureFormat fmt("en", UMEASFMT_WIDTH_NUMERIC, status);
3575
3576 Measure hours(112, MeasureUnit::createHour(status), status);
3577 Measure minutes(113, MeasureUnit::createMinute(status), status);
3578 Measure seconds(114, MeasureUnit::createSecond(status), status);
3579 Measure fhours(112.8765, MeasureUnit::createHour(status), status);
3580 Measure fminutes(113.8765, MeasureUnit::createMinute(status), status);
3581 Measure fseconds(114.8765, MeasureUnit::createSecond(status), status);
3582 if (status.errDataIfFailureAndReset(WHERE)) return;
3583
3584 verifyFormat("hours", fmt, &hours, 1, "112h");
3585 verifyFormat("minutes", fmt, &minutes, 1, "113m");
3586 verifyFormat("seconds", fmt, &seconds, 1, "114s");
3587
3588 verifyFormat("fhours", fmt, &fhours, 1, "112.876h");
3589 verifyFormat("fminutes", fmt, &fminutes, 1, "113.876m");
3590 verifyFormat("fseconds", fmt, &fseconds, 1, "114.876s");
3591
3592 Measure hoursMinutes[2] = {hours, minutes};
3593 verifyFormat("hoursMinutes", fmt, hoursMinutes, 2, "112:113");
3594 Measure hoursSeconds[2] = {hours, seconds};
3595 verifyFormat("hoursSeconds", fmt, hoursSeconds, 2, "112:00:114");
3596 Measure minutesSeconds[2] = {minutes, seconds};
3597 verifyFormat("minutesSeconds", fmt, minutesSeconds, 2, "113:114");
3598
3599 Measure hoursFminutes[2] = {hours, fminutes};
3600 verifyFormat("hoursFminutes", fmt, hoursFminutes, 2, "112:113.876");
3601 Measure hoursFseconds[2] = {hours, fseconds};
3602 verifyFormat("hoursFseconds", fmt, hoursFseconds, 2, "112:00:114.876");
3603 Measure minutesFseconds[2] = {minutes, fseconds};
3604 verifyFormat("hoursMminutesFsecondsinutes", fmt, minutesFseconds, 2, "113:114.876");
3605
3606 Measure fhoursMinutes[2] = {fhours, minutes};
3607 verifyFormat("fhoursMinutes", fmt, fhoursMinutes, 2, "112:113");
3608 Measure fhoursSeconds[2] = {fhours, seconds};
3609 verifyFormat("fhoursSeconds", fmt, fhoursSeconds, 2, "112:00:114");
3610 Measure fminutesSeconds[2] = {fminutes, seconds};
3611 verifyFormat("fminutesSeconds", fmt, fminutesSeconds, 2, "113:114");
3612
3613 Measure fhoursFminutes[2] = {fhours, fminutes};
3614 verifyFormat("fhoursFminutes", fmt, fhoursFminutes, 2, "112:113.876");
3615 Measure fhoursFseconds[2] = {fhours, fseconds};
3616 verifyFormat("fhoursFseconds", fmt, fhoursFseconds, 2, "112:00:114.876");
3617 Measure fminutesFseconds[2] = {fminutes, fseconds};
3618 verifyFormat("fminutesFseconds", fmt, fminutesFseconds, 2, "113:114.876");
3619
3620 Measure hoursMinutesSeconds[3] = {hours, minutes, seconds};
3621 verifyFormat("hoursMinutesSeconds", fmt, hoursMinutesSeconds, 3, "112:113:114");
3622 Measure fhoursFminutesFseconds[3] = {fhours, fminutes, fseconds};
3623 verifyFormat("fhoursFminutesFseconds", fmt, fhoursFminutesFseconds, 3, "112:113:114.876");
3624 }
3625
TestNumericTimeSomeSpecialFormats()3626 void MeasureFormatTest::TestNumericTimeSomeSpecialFormats() {
3627 IcuTestErrorCode status(*this, "TestNumericTimeSomeSpecialFormats");
3628
3629 Measure fhours(2.8765432, MeasureUnit::createHour(status), status);
3630 Measure fminutes(3.8765432, MeasureUnit::createMinute(status), status);
3631 if (status.errDataIfFailureAndReset(WHERE)) return;
3632
3633 Measure fhoursFminutes[2] = {fhours, fminutes};
3634
3635 // Latvian is one of the very few locales 0-padding the hour
3636 MeasureFormat fmtLt("lt", UMEASFMT_WIDTH_NUMERIC, status);
3637 if (status.errDataIfFailureAndReset(WHERE)) return;
3638 verifyFormat("Latvian fhoursFminutes", fmtLt, fhoursFminutes, 2, "02:03,877");
3639
3640 // Danish is one of the very few locales using '.' as separator
3641 MeasureFormat fmtDa("da", UMEASFMT_WIDTH_NUMERIC, status);
3642 verifyFormat("Danish fhoursFminutes", fmtDa, fhoursFminutes, 2, "2.03,877");
3643 }
3644
TestIdentifiers()3645 void MeasureFormatTest::TestIdentifiers() {
3646 IcuTestErrorCode status(*this, "TestIdentifiers");
3647 struct TestCase {
3648 const char* id;
3649 const char* normalized;
3650 } cases[] = {
3651 // Correctly normalized identifiers should not change
3652 {"", ""},
3653 {"square-meter-per-square-meter", "square-meter-per-square-meter"},
3654 {"kilogram-meter-per-square-meter-square-second",
3655 "kilogram-meter-per-square-meter-square-second"},
3656 {"square-mile-and-square-foot", "square-mile-and-square-foot"},
3657 {"square-foot-and-square-mile", "square-foot-and-square-mile"},
3658 {"per-cubic-centimeter", "per-cubic-centimeter"},
3659 {"per-kilometer", "per-kilometer"},
3660
3661 // Normalization of power and per
3662 {"pow2-foot-and-pow2-mile", "square-foot-and-square-mile"},
3663 {"gram-square-gram-per-dekagram", "cubic-gram-per-dekagram"},
3664 {"kilogram-per-meter-per-second", "kilogram-per-meter-second"},
3665
3666 // TODO(ICU-21284): Add more test cases once the proper ranking is available.
3667 };
3668 for (const auto &cas : cases) {
3669 status.setScope(cas.id);
3670 MeasureUnit unit = MeasureUnit::forIdentifier(cas.id, status);
3671 status.errIfFailureAndReset();
3672 const char* actual = unit.getIdentifier();
3673 assertEquals(cas.id, cas.normalized, actual);
3674 status.errIfFailureAndReset();
3675 }
3676 }
3677
TestInvalidIdentifiers()3678 void MeasureFormatTest::TestInvalidIdentifiers() {
3679 IcuTestErrorCode status(*this, "TestInvalidIdentifiers");
3680
3681 const char *const inputs[] = {
3682 "kilo",
3683 "kilokilo",
3684 "onekilo",
3685 "meterkilo",
3686 "meter-kilo",
3687 "k",
3688 "meter-",
3689 "meter+",
3690 "-meter",
3691 "+meter",
3692 "-kilometer",
3693 "+kilometer",
3694 "-pow2-meter",
3695 "+pow2-meter",
3696 "p2-meter",
3697 "p4-meter",
3698 "+",
3699 "-",
3700 "-mile",
3701 "-and-mile",
3702 "-per-mile",
3703 "one",
3704 "one-one",
3705 "one-per-mile",
3706 "one-per-cubic-centimeter",
3707 "square--per-meter",
3708 "metersecond", // Must have compound part in between single units
3709
3710 // Negative powers not supported in mixed units yet. TODO(CLDR-13701).
3711 "per-hour-and-hertz",
3712 "hertz-and-per-hour",
3713
3714 // Compound units not supported in mixed units yet. TODO(CLDR-13700).
3715 "kilonewton-meter-and-newton-meter",
3716 };
3717
3718 for (const auto& input : inputs) {
3719 status.setScope(input);
3720 MeasureUnit::forIdentifier(input, status);
3721 status.expectErrorAndReset(U_ILLEGAL_ARGUMENT_ERROR);
3722 }
3723 }
3724
TestParseToBuiltIn()3725 void MeasureFormatTest::TestParseToBuiltIn() {
3726 IcuTestErrorCode status(*this, "TestParseToBuiltIn()");
3727 const struct TestCase {
3728 const char *identifier;
3729 MeasureUnit expectedBuiltIn;
3730 } cases[] = {
3731 {"meter-per-second-per-second", MeasureUnit::getMeterPerSecondSquared()},
3732 {"meter-per-second-second", MeasureUnit::getMeterPerSecondSquared()},
3733 {"centimeter-centimeter", MeasureUnit::getSquareCentimeter()},
3734 {"square-foot", MeasureUnit::getSquareFoot()},
3735 {"pow2-inch", MeasureUnit::getSquareInch()},
3736 {"milligram-per-deciliter", MeasureUnit::getMilligramPerDeciliter()},
3737 {"pound-force-per-pow2-inch", MeasureUnit::getPoundPerSquareInch()},
3738 {"yard-pow2-yard", MeasureUnit::getCubicYard()},
3739 {"square-yard-yard", MeasureUnit::getCubicYard()},
3740 };
3741
3742 for (auto &cas : cases) {
3743 MeasureUnit fromIdent = MeasureUnit::forIdentifier(cas.identifier, status);
3744 status.assertSuccess();
3745 assertEquals("forIdentifier returns a normal built-in unit when it exists",
3746 cas.expectedBuiltIn.getOffset(), fromIdent.getOffset());
3747 assertEquals("type", cas.expectedBuiltIn.getType(), fromIdent.getType());
3748 assertEquals("subType", cas.expectedBuiltIn.getSubtype(), fromIdent.getSubtype());
3749 }
3750 }
3751
3752 // Kilogram is a "base unit", although it's also "gram" with a kilo- prefix.
3753 // This tests that it is handled in the preferred manner.
TestKilogramIdentifier()3754 void MeasureFormatTest::TestKilogramIdentifier() {
3755 IcuTestErrorCode status(*this, "TestKilogramIdentifier");
3756
3757 // SI unit of mass
3758 MeasureUnit kilogram = MeasureUnit::forIdentifier("kilogram", status);
3759 // Metric mass unit
3760 MeasureUnit gram = MeasureUnit::forIdentifier("gram", status);
3761 // Microgram: still a built-in type
3762 MeasureUnit microgram = MeasureUnit::forIdentifier("microgram", status);
3763 // Nanogram: not a built-in type at this time
3764 MeasureUnit nanogram = MeasureUnit::forIdentifier("nanogram", status);
3765 status.assertSuccess();
3766
3767 assertEquals("parsed kilogram equals built-in kilogram", MeasureUnit::getKilogram().getType(),
3768 kilogram.getType());
3769 assertEquals("parsed kilogram equals built-in kilogram", MeasureUnit::getKilogram().getSubtype(),
3770 kilogram.getSubtype());
3771 assertEquals("parsed gram equals built-in gram", MeasureUnit::getGram().getType(), gram.getType());
3772 assertEquals("parsed gram equals built-in gram", MeasureUnit::getGram().getSubtype(),
3773 gram.getSubtype());
3774 assertEquals("parsed microgram equals built-in microgram", MeasureUnit::getMicrogram().getType(),
3775 microgram.getType());
3776 assertEquals("parsed microgram equals built-in microgram", MeasureUnit::getMicrogram().getSubtype(),
3777 microgram.getSubtype());
3778 assertEquals("nanogram", "", nanogram.getType());
3779 assertEquals("nanogram", "nanogram", nanogram.getIdentifier());
3780
3781 assertEquals("prefix of kilogram", UMEASURE_SI_PREFIX_KILO, kilogram.getSIPrefix(status));
3782 assertEquals("prefix of gram", UMEASURE_SI_PREFIX_ONE, gram.getSIPrefix(status));
3783 assertEquals("prefix of microgram", UMEASURE_SI_PREFIX_MICRO, microgram.getSIPrefix(status));
3784 assertEquals("prefix of nanogram", UMEASURE_SI_PREFIX_NANO, nanogram.getSIPrefix(status));
3785
3786 MeasureUnit tmp = kilogram.withSIPrefix(UMEASURE_SI_PREFIX_MILLI, status);
3787 assertEquals(UnicodeString("Kilogram + milli should be milligram, got: ") + tmp.getIdentifier(),
3788 MeasureUnit::getMilligram().getIdentifier(), tmp.getIdentifier());
3789 }
3790
TestCompoundUnitOperations()3791 void MeasureFormatTest::TestCompoundUnitOperations() {
3792 IcuTestErrorCode status(*this, "TestCompoundUnitOperations");
3793
3794 MeasureUnit::forIdentifier("kilometer-per-second-joule", status);
3795
3796 MeasureUnit kilometer = MeasureUnit::getKilometer();
3797 MeasureUnit cubicMeter = MeasureUnit::getCubicMeter();
3798 MeasureUnit meter = kilometer.withSIPrefix(UMEASURE_SI_PREFIX_ONE, status);
3799 MeasureUnit centimeter1 = kilometer.withSIPrefix(UMEASURE_SI_PREFIX_CENTI, status);
3800 MeasureUnit centimeter2 = meter.withSIPrefix(UMEASURE_SI_PREFIX_CENTI, status);
3801 MeasureUnit cubicDecimeter = cubicMeter.withSIPrefix(UMEASURE_SI_PREFIX_DECI, status);
3802
3803 verifySingleUnit(kilometer, UMEASURE_SI_PREFIX_KILO, 1, "kilometer");
3804 verifySingleUnit(meter, UMEASURE_SI_PREFIX_ONE, 1, "meter");
3805 verifySingleUnit(centimeter1, UMEASURE_SI_PREFIX_CENTI, 1, "centimeter");
3806 verifySingleUnit(centimeter2, UMEASURE_SI_PREFIX_CENTI, 1, "centimeter");
3807 verifySingleUnit(cubicDecimeter, UMEASURE_SI_PREFIX_DECI, 3, "cubic-decimeter");
3808
3809 assertTrue("centimeter equality", centimeter1 == centimeter2);
3810 assertTrue("kilometer inequality", centimeter1 != kilometer);
3811
3812 MeasureUnit squareMeter = meter.withDimensionality(2, status);
3813 MeasureUnit overCubicCentimeter = centimeter1.withDimensionality(-3, status);
3814 MeasureUnit quarticKilometer = kilometer.withDimensionality(4, status);
3815 MeasureUnit overQuarticKilometer1 = kilometer.withDimensionality(-4, status);
3816
3817 verifySingleUnit(squareMeter, UMEASURE_SI_PREFIX_ONE, 2, "square-meter");
3818 verifySingleUnit(overCubicCentimeter, UMEASURE_SI_PREFIX_CENTI, -3, "per-cubic-centimeter");
3819 verifySingleUnit(quarticKilometer, UMEASURE_SI_PREFIX_KILO, 4, "pow4-kilometer");
3820 verifySingleUnit(overQuarticKilometer1, UMEASURE_SI_PREFIX_KILO, -4, "per-pow4-kilometer");
3821
3822 assertTrue("power inequality", quarticKilometer != overQuarticKilometer1);
3823
3824 MeasureUnit overQuarticKilometer2 = quarticKilometer.reciprocal(status);
3825 MeasureUnit overQuarticKilometer3 = kilometer.product(kilometer, status)
3826 .product(kilometer, status)
3827 .product(kilometer, status)
3828 .reciprocal(status);
3829 MeasureUnit overQuarticKilometer4 = meter.withDimensionality(4, status)
3830 .reciprocal(status)
3831 .withSIPrefix(UMEASURE_SI_PREFIX_KILO, status);
3832
3833 verifySingleUnit(overQuarticKilometer2, UMEASURE_SI_PREFIX_KILO, -4, "per-pow4-kilometer");
3834 verifySingleUnit(overQuarticKilometer3, UMEASURE_SI_PREFIX_KILO, -4, "per-pow4-kilometer");
3835 verifySingleUnit(overQuarticKilometer4, UMEASURE_SI_PREFIX_KILO, -4, "per-pow4-kilometer");
3836
3837 assertTrue("reciprocal equality", overQuarticKilometer1 == overQuarticKilometer2);
3838 assertTrue("reciprocal equality", overQuarticKilometer1 == overQuarticKilometer3);
3839 assertTrue("reciprocal equality", overQuarticKilometer1 == overQuarticKilometer4);
3840
3841 MeasureUnit kiloSquareSecond = MeasureUnit::getSecond()
3842 .withDimensionality(2, status).withSIPrefix(UMEASURE_SI_PREFIX_KILO, status);
3843 MeasureUnit meterSecond = meter.product(kiloSquareSecond, status);
3844 MeasureUnit cubicMeterSecond1 = meter.withDimensionality(3, status).product(kiloSquareSecond, status);
3845 MeasureUnit centimeterSecond1 = meter.withSIPrefix(UMEASURE_SI_PREFIX_CENTI, status).product(kiloSquareSecond, status);
3846 MeasureUnit secondCubicMeter = kiloSquareSecond.product(meter.withDimensionality(3, status), status);
3847 MeasureUnit secondCentimeter = kiloSquareSecond.product(meter.withSIPrefix(UMEASURE_SI_PREFIX_CENTI, status), status);
3848 MeasureUnit secondCentimeterPerKilometer = secondCentimeter.product(kilometer.reciprocal(status), status);
3849
3850 verifySingleUnit(kiloSquareSecond, UMEASURE_SI_PREFIX_KILO, 2, "square-kilosecond");
3851 const char* meterSecondSub[] = {"meter", "square-kilosecond"};
3852 verifyCompoundUnit(meterSecond, "meter-square-kilosecond",
3853 meterSecondSub, UPRV_LENGTHOF(meterSecondSub));
3854 const char* cubicMeterSecond1Sub[] = {"cubic-meter", "square-kilosecond"};
3855 verifyCompoundUnit(cubicMeterSecond1, "cubic-meter-square-kilosecond",
3856 cubicMeterSecond1Sub, UPRV_LENGTHOF(cubicMeterSecond1Sub));
3857 const char* centimeterSecond1Sub[] = {"centimeter", "square-kilosecond"};
3858 verifyCompoundUnit(centimeterSecond1, "centimeter-square-kilosecond",
3859 centimeterSecond1Sub, UPRV_LENGTHOF(centimeterSecond1Sub));
3860 const char* secondCubicMeterSub[] = {"cubic-meter", "square-kilosecond"};
3861 verifyCompoundUnit(secondCubicMeter, "cubic-meter-square-kilosecond",
3862 secondCubicMeterSub, UPRV_LENGTHOF(secondCubicMeterSub));
3863 const char* secondCentimeterSub[] = {"centimeter", "square-kilosecond"};
3864 verifyCompoundUnit(secondCentimeter, "centimeter-square-kilosecond",
3865 secondCentimeterSub, UPRV_LENGTHOF(secondCentimeterSub));
3866 const char* secondCentimeterPerKilometerSub[] = {"centimeter", "square-kilosecond", "per-kilometer"};
3867 verifyCompoundUnit(secondCentimeterPerKilometer, "centimeter-square-kilosecond-per-kilometer",
3868 secondCentimeterPerKilometerSub, UPRV_LENGTHOF(secondCentimeterPerKilometerSub));
3869
3870 assertTrue("reordering equality", cubicMeterSecond1 == secondCubicMeter);
3871 assertTrue("additional simple units inequality", secondCubicMeter != secondCentimeter);
3872
3873 // Don't allow get/set power or SI prefix on compound units
3874 status.errIfFailureAndReset();
3875 meterSecond.getDimensionality(status);
3876 status.expectErrorAndReset(U_ILLEGAL_ARGUMENT_ERROR);
3877 meterSecond.withDimensionality(3, status);
3878 status.expectErrorAndReset(U_ILLEGAL_ARGUMENT_ERROR);
3879 meterSecond.getSIPrefix(status);
3880 status.expectErrorAndReset(U_ILLEGAL_ARGUMENT_ERROR);
3881 meterSecond.withSIPrefix(UMEASURE_SI_PREFIX_CENTI, status);
3882 status.expectErrorAndReset(U_ILLEGAL_ARGUMENT_ERROR);
3883
3884 // Test that StringPiece does not overflow
3885 MeasureUnit centimeter3 = MeasureUnit::forIdentifier({secondCentimeter.getIdentifier(), 10}, status);
3886 verifySingleUnit(centimeter3, UMEASURE_SI_PREFIX_CENTI, 1, "centimeter");
3887 assertTrue("string piece equality", centimeter1 == centimeter3);
3888
3889 MeasureUnit footInch = MeasureUnit::forIdentifier("foot-and-inch", status);
3890 MeasureUnit inchFoot = MeasureUnit::forIdentifier("inch-and-foot", status);
3891
3892 const char* footInchSub[] = {"foot", "inch"};
3893 verifyMixedUnit(footInch, "foot-and-inch",
3894 footInchSub, UPRV_LENGTHOF(footInchSub));
3895 const char* inchFootSub[] = {"inch", "foot"};
3896 verifyMixedUnit(inchFoot, "inch-and-foot",
3897 inchFootSub, UPRV_LENGTHOF(inchFootSub));
3898
3899 assertTrue("order matters inequality", footInch != inchFoot);
3900
3901 MeasureUnit dimensionless;
3902 MeasureUnit dimensionless2 = MeasureUnit::forIdentifier("", status);
3903 status.errIfFailureAndReset("Dimensionless MeasureUnit.");
3904 assertTrue("dimensionless equality", dimensionless == dimensionless2);
3905
3906 // We support starting from an "identity" MeasureUnit and then combining it
3907 // with others via product:
3908 MeasureUnit kilometer2 = dimensionless.product(kilometer, status);
3909 status.errIfFailureAndReset("dimensionless.product(kilometer, status)");
3910 verifySingleUnit(kilometer2, UMEASURE_SI_PREFIX_KILO, 1, "kilometer");
3911 assertTrue("kilometer equality", kilometer == kilometer2);
3912
3913 // Test out-of-range powers
3914 MeasureUnit power15 = MeasureUnit::forIdentifier("pow15-kilometer", status);
3915 verifySingleUnit(power15, UMEASURE_SI_PREFIX_KILO, 15, "pow15-kilometer");
3916 status.errIfFailureAndReset();
3917 MeasureUnit power16a = MeasureUnit::forIdentifier("pow16-kilometer", status);
3918 status.expectErrorAndReset(U_ILLEGAL_ARGUMENT_ERROR);
3919 MeasureUnit power16b = power15.product(kilometer, status);
3920 status.expectErrorAndReset(U_ILLEGAL_ARGUMENT_ERROR);
3921 MeasureUnit powerN15 = MeasureUnit::forIdentifier("per-pow15-kilometer", status);
3922 verifySingleUnit(powerN15, UMEASURE_SI_PREFIX_KILO, -15, "per-pow15-kilometer");
3923 status.errIfFailureAndReset();
3924 MeasureUnit powerN16a = MeasureUnit::forIdentifier("per-pow16-kilometer", status);
3925 status.expectErrorAndReset(U_ILLEGAL_ARGUMENT_ERROR);
3926 MeasureUnit powerN16b = powerN15.product(overQuarticKilometer1, status);
3927 status.expectErrorAndReset(U_ILLEGAL_ARGUMENT_ERROR);
3928 }
3929
TestDimensionlessBehaviour()3930 void MeasureFormatTest::TestDimensionlessBehaviour() {
3931 IcuTestErrorCode status(*this, "TestDimensionlessBehaviour");
3932 MeasureUnit dimensionless;
3933 MeasureUnit modified;
3934
3935 // At the time of writing, each of the seven groups below caused
3936 // Parser::from("") to be called:
3937
3938 // splitToSingleUnits
3939 auto pair = dimensionless.splitToSingleUnits(status);
3940 int32_t count = pair.second;
3941 status.errIfFailureAndReset("dimensionless.splitToSingleUnits(...)");
3942 assertEquals("no singles in dimensionless", 0, count);
3943
3944 // product(dimensionless)
3945 MeasureUnit mile = MeasureUnit::getMile();
3946 mile = mile.product(dimensionless, status);
3947 status.errIfFailureAndReset("mile.product(dimensionless, ...)");
3948 verifySingleUnit(mile, UMEASURE_SI_PREFIX_ONE, 1, "mile");
3949
3950 // dimensionless.getSIPrefix()
3951 UMeasureSIPrefix siPrefix = dimensionless.getSIPrefix(status);
3952 status.errIfFailureAndReset("dimensionless.getSIPrefix(...)");
3953 assertEquals("dimensionless SIPrefix", UMEASURE_SI_PREFIX_ONE, siPrefix);
3954
3955 // dimensionless.withSIPrefix()
3956 modified = dimensionless.withSIPrefix(UMEASURE_SI_PREFIX_KILO, status);
3957 status.errIfFailureAndReset("dimensionless.withSIPrefix(...)");
3958 pair = dimensionless.splitToSingleUnits(status);
3959 count = pair.second;
3960 assertEquals("no singles in modified", 0, count);
3961 siPrefix = modified.getSIPrefix(status);
3962 status.errIfFailureAndReset("modified.getSIPrefix(...)");
3963 assertEquals("modified SIPrefix", UMEASURE_SI_PREFIX_ONE, siPrefix);
3964
3965 // dimensionless.getComplexity()
3966 UMeasureUnitComplexity complexity = dimensionless.getComplexity(status);
3967 status.errIfFailureAndReset("dimensionless.getComplexity(...)");
3968 assertEquals("dimensionless complexity", UMEASURE_UNIT_SINGLE, complexity);
3969
3970 // Dimensionality is mostly meaningless for dimensionless units, but it's
3971 // still considered a SINGLE unit, so this code doesn't throw errors:
3972
3973 // dimensionless.getDimensionality()
3974 int32_t dimensionality = dimensionless.getDimensionality(status);
3975 status.errIfFailureAndReset("dimensionless.getDimensionality(...)");
3976 assertEquals("dimensionless dimensionality", 0, dimensionality);
3977
3978 // dimensionless.withDimensionality()
3979 dimensionless.withDimensionality(-1, status);
3980 status.errIfFailureAndReset("dimensionless.withDimensionality(...)");
3981 dimensionality = dimensionless.getDimensionality(status);
3982 status.errIfFailureAndReset("dimensionless.getDimensionality(...)");
3983 assertEquals("dimensionless dimensionality", 0, dimensionality);
3984 }
3985
3986 // ICU-21060
Test21060_AddressSanitizerProblem()3987 void MeasureFormatTest::Test21060_AddressSanitizerProblem() {
3988 IcuTestErrorCode status(*this, "Test21060_AddressSanitizerProblem");
3989
3990 MeasureUnit first = MeasureUnit::forIdentifier("", status);
3991 status.errIfFailureAndReset();
3992
3993 // Experimentally, a compound unit like "kilogram-meter" failed. A single
3994 // unit like "kilogram" or "meter" did not fail, did not trigger the
3995 // problem.
3996 MeasureUnit crux = MeasureUnit::forIdentifier("per-meter", status);
3997
3998 // Heap allocation of a new CharString for first.identifier happens here:
3999 first = first.product(crux, status);
4000
4001 // Constructing second from first's identifier resulted in a failure later,
4002 // as second held a reference to a substring of first's identifier:
4003 MeasureUnit second = MeasureUnit::forIdentifier(first.getIdentifier(), status);
4004
4005 // Heap is freed here, as an old first.identifier CharString is deallocated
4006 // and a new CharString is allocated:
4007 first = first.product(crux, status);
4008
4009 // Proving we've had no failure yet:
4010 status.errIfFailureAndReset();
4011
4012 // heap-use-after-free failure happened here, since a SingleUnitImpl had
4013 // held onto a StringPiece pointing at a substring of an identifier that was
4014 // freed above:
4015 second = second.product(crux, status);
4016
4017 status.errIfFailureAndReset();
4018 }
4019
Test21223_FrenchDuration()4020 void MeasureFormatTest::Test21223_FrenchDuration() {
4021 IcuTestErrorCode status(*this, "Test21223_FrenchDuration");
4022 MeasureFormat mf("fr-FR", UMEASFMT_WIDTH_NARROW, status);
4023 Measure H5M10[] = {
4024 {5, MeasureUnit::createHour(status), status},
4025 {10, MeasureUnit::createMinute(status), status}
4026 };
4027 UnicodeString result;
4028 FieldPosition pos;
4029 mf.formatMeasures(H5M10, UPRV_LENGTHOF(H5M10), result, pos, status);
4030 assertEquals("Should have consistent spacing", u"5h 10min", result);
4031
4032 // Test additional locales:
4033 // int32_t localeCount;
4034 // const Locale* locales = Locale::getAvailableLocales(localeCount);
4035 // for (int32_t i=0; i<localeCount; i++) {
4036 // auto& loc = locales[i];
4037 // MeasureFormat mf1(loc, UMEASFMT_WIDTH_NARROW, status);
4038 // mf1.formatMeasures(H5M10, UPRV_LENGTHOF(H5M10), result.remove(), pos, status);
4039 // assertFalse(result + u" " + loc.getName(), TRUE);
4040 // }
4041 }
4042
TestInternalMeasureUnitImpl()4043 void MeasureFormatTest::TestInternalMeasureUnitImpl() {
4044 IcuTestErrorCode status(*this, "TestInternalMeasureUnitImpl");
4045 MeasureUnitImpl mu1 = MeasureUnitImpl::forIdentifier("meter", status);
4046 status.assertSuccess();
4047 assertEquals("mu1 initial identifier", "", mu1.identifier.data());
4048 assertEquals("mu1 initial complexity", UMEASURE_UNIT_SINGLE, mu1.complexity);
4049 assertEquals("mu1 initial units length", 1, mu1.units.length());
4050 assertEquals("mu1 initial units[0]", "meter", mu1.units[0]->getSimpleUnitID());
4051
4052 // Producing identifier via build(): the std::move() means mu1 gets modified
4053 // while it also gets assigned to tmp's internal fImpl.
4054 MeasureUnit tmp = std::move(mu1).build(status);
4055 status.assertSuccess();
4056 assertEquals("mu1 post-move-build identifier", "meter", mu1.identifier.data());
4057 assertEquals("mu1 post-move-build complexity", UMEASURE_UNIT_SINGLE, mu1.complexity);
4058 assertEquals("mu1 post-move-build units length", 1, mu1.units.length());
4059 assertEquals("mu1 post-move-build units[0]", "meter", mu1.units[0]->getSimpleUnitID());
4060 assertEquals("MeasureUnit tmp identifier", "meter", tmp.getIdentifier());
4061
4062 // This temporary variable is used when forMeasureUnit's first parameter
4063 // lacks an fImpl instance:
4064 MeasureUnitImpl tmpMemory;
4065 const MeasureUnitImpl &tmpImplRef = MeasureUnitImpl::forMeasureUnit(tmp, tmpMemory, status);
4066 status.assertSuccess();
4067 assertEquals("tmpMemory identifier", "", tmpMemory.identifier.data());
4068 assertEquals("tmpMemory complexity", UMEASURE_UNIT_SINGLE, tmpMemory.complexity);
4069 assertEquals("tmpMemory units length", 1, tmpMemory.units.length());
4070 assertEquals("tmpMemory units[0]", "meter", tmpMemory.units[0]->getSimpleUnitID());
4071 assertEquals("tmpImplRef identifier", "", tmpImplRef.identifier.data());
4072 assertEquals("tmpImplRef complexity", UMEASURE_UNIT_SINGLE, tmpImplRef.complexity);
4073
4074 MeasureUnitImpl mu2 = MeasureUnitImpl::forIdentifier("newton-meter", status);
4075 status.assertSuccess();
4076 mu1 = std::move(mu2);
4077 assertEquals("mu1 = move(mu2): identifier", "", mu1.identifier.data());
4078 assertEquals("mu1 = move(mu2): complexity", UMEASURE_UNIT_COMPOUND, mu1.complexity);
4079 assertEquals("mu1 = move(mu2): units length", 2, mu1.units.length());
4080 assertEquals("mu1 = move(mu2): units[0]", "newton", mu1.units[0]->getSimpleUnitID());
4081 assertEquals("mu1 = move(mu2): units[1]", "meter", mu1.units[1]->getSimpleUnitID());
4082
4083 mu1 = MeasureUnitImpl::forIdentifier("hour-and-minute-and-second", status);
4084 status.assertSuccess();
4085 assertEquals("mu1 = HMS: identifier", "", mu1.identifier.data());
4086 assertEquals("mu1 = HMS: complexity", UMEASURE_UNIT_MIXED, mu1.complexity);
4087 assertEquals("mu1 = HMS: units length", 3, mu1.units.length());
4088 assertEquals("mu1 = HMS: units[0]", "hour", mu1.units[0]->getSimpleUnitID());
4089 assertEquals("mu1 = HMS: units[1]", "minute", mu1.units[1]->getSimpleUnitID());
4090 assertEquals("mu1 = HMS: units[2]", "second", mu1.units[2]->getSimpleUnitID());
4091 }
4092
4093
verifyFieldPosition(const char * description,const MeasureFormat & fmt,const UnicodeString & prefix,const Measure * measures,int32_t measureCount,NumberFormat::EAlignmentFields field,int32_t start,int32_t end)4094 void MeasureFormatTest::verifyFieldPosition(
4095 const char *description,
4096 const MeasureFormat &fmt,
4097 const UnicodeString &prefix,
4098 const Measure *measures,
4099 int32_t measureCount,
4100 NumberFormat::EAlignmentFields field,
4101 int32_t start,
4102 int32_t end) {
4103 // 8 char lead
4104 UnicodeString result(prefix);
4105 FieldPosition pos(field);
4106 UErrorCode status = U_ZERO_ERROR;
4107 CharString ch;
4108 const char *descPrefix = ch.append(description, status)
4109 .append(": ", status).data();
4110 CharString beginIndex;
4111 beginIndex.append(descPrefix, status).append("beginIndex", status);
4112 CharString endIndex;
4113 endIndex.append(descPrefix, status).append("endIndex", status);
4114 fmt.formatMeasures(measures, measureCount, result, pos, status);
4115 if (!assertSuccess("Error formatting", status)) {
4116 return;
4117 }
4118 assertEquals(beginIndex.data(), start, pos.getBeginIndex());
4119 assertEquals(endIndex.data(), end, pos.getEndIndex());
4120 }
4121
verifyFormat(const char * description,const MeasureFormat & fmt,const Measure * measures,int32_t measureCount,const char * expected)4122 void MeasureFormatTest::verifyFormat(
4123 const char *description,
4124 const MeasureFormat &fmt,
4125 const Measure *measures,
4126 int32_t measureCount,
4127 const char *expected) {
4128 verifyFormatWithPrefix(
4129 description,
4130 fmt,
4131 "",
4132 measures,
4133 measureCount,
4134 expected);
4135 }
4136
verifyFormatWithPrefix(const char * description,const MeasureFormat & fmt,const UnicodeString & prefix,const Measure * measures,int32_t measureCount,const char * expected)4137 void MeasureFormatTest::verifyFormatWithPrefix(
4138 const char *description,
4139 const MeasureFormat &fmt,
4140 const UnicodeString &prefix,
4141 const Measure *measures,
4142 int32_t measureCount,
4143 const char *expected) {
4144 UnicodeString result(prefix);
4145 FieldPosition pos(FieldPosition::DONT_CARE);
4146 UErrorCode status = U_ZERO_ERROR;
4147 fmt.formatMeasures(measures, measureCount, result, pos, status);
4148 if (!assertSuccess("Error formatting", status)) {
4149 return;
4150 }
4151 assertEquals(description, ctou(expected), result);
4152 }
4153
verifyFormat(const char * description,const MeasureFormat & fmt,const ExpectedResult * expectedResults,int32_t count)4154 void MeasureFormatTest::verifyFormat(
4155 const char *description,
4156 const MeasureFormat &fmt,
4157 const ExpectedResult *expectedResults,
4158 int32_t count) {
4159 for (int32_t i = 0; i < count; ++i) {
4160 verifyFormat(description, fmt, expectedResults[i].measures, expectedResults[i].count, expectedResults[i].expected);
4161 }
4162 }
4163
verifySingleUnit(const MeasureUnit & unit,UMeasureSIPrefix siPrefix,int8_t power,const char * identifier)4164 void MeasureFormatTest::verifySingleUnit(
4165 const MeasureUnit& unit,
4166 UMeasureSIPrefix siPrefix,
4167 int8_t power,
4168 const char* identifier) {
4169 IcuTestErrorCode status(*this, "verifySingleUnit");
4170 UnicodeString uid(identifier, -1, US_INV);
4171 assertEquals(uid + ": SI prefix",
4172 siPrefix,
4173 unit.getSIPrefix(status));
4174 status.errIfFailureAndReset("%s: SI prefix", identifier);
4175 assertEquals(uid + ": Power",
4176 static_cast<int32_t>(power),
4177 static_cast<int32_t>(unit.getDimensionality(status)));
4178 status.errIfFailureAndReset("%s: Power", identifier);
4179 assertEquals(uid + ": Identifier",
4180 identifier,
4181 unit.getIdentifier());
4182 status.errIfFailureAndReset("%s: Identifier", identifier);
4183 assertTrue(uid + ": Constructor",
4184 unit == MeasureUnit::forIdentifier(identifier, status));
4185 status.errIfFailureAndReset("%s: Constructor", identifier);
4186 assertEquals(uid + ": Complexity",
4187 UMEASURE_UNIT_SINGLE,
4188 unit.getComplexity(status));
4189 status.errIfFailureAndReset("%s: Complexity", identifier);
4190 }
4191
verifyCompoundUnit(const MeasureUnit & unit,const char * identifier,const char ** subIdentifiers,int32_t subIdentifierCount)4192 void MeasureFormatTest::verifyCompoundUnit(
4193 const MeasureUnit& unit,
4194 const char* identifier,
4195 const char** subIdentifiers,
4196 int32_t subIdentifierCount) {
4197 IcuTestErrorCode status(*this, "verifyCompoundUnit");
4198 UnicodeString uid(identifier, -1, US_INV);
4199 assertEquals(uid + ": Identifier",
4200 identifier,
4201 unit.getIdentifier());
4202 status.errIfFailureAndReset("%s: Identifier", identifier);
4203 assertTrue(uid + ": Constructor",
4204 unit == MeasureUnit::forIdentifier(identifier, status));
4205 status.errIfFailureAndReset("%s: Constructor", identifier);
4206 assertEquals(uid + ": Complexity",
4207 UMEASURE_UNIT_COMPOUND,
4208 unit.getComplexity(status));
4209 status.errIfFailureAndReset("%s: Complexity", identifier);
4210
4211 auto pair = unit.splitToSingleUnits(status);
4212 const LocalArray<MeasureUnit>& subUnits = pair.first;
4213 int32_t length = pair.second;
4214 assertEquals(uid + ": Length", subIdentifierCount, length);
4215 for (int32_t i = 0;; i++) {
4216 if (i >= subIdentifierCount || i >= length) break;
4217 assertEquals(uid + ": Sub-unit #" + Int64ToUnicodeString(i),
4218 subIdentifiers[i],
4219 subUnits[i].getIdentifier());
4220 assertEquals(uid + ": Sub-unit Complexity",
4221 UMEASURE_UNIT_SINGLE,
4222 subUnits[i].getComplexity(status));
4223 }
4224 }
4225
verifyMixedUnit(const MeasureUnit & unit,const char * identifier,const char ** subIdentifiers,int32_t subIdentifierCount)4226 void MeasureFormatTest::verifyMixedUnit(
4227 const MeasureUnit& unit,
4228 const char* identifier,
4229 const char** subIdentifiers,
4230 int32_t subIdentifierCount) {
4231 IcuTestErrorCode status(*this, "verifyMixedUnit");
4232 UnicodeString uid(identifier, -1, US_INV);
4233 assertEquals(uid + ": Identifier",
4234 identifier,
4235 unit.getIdentifier());
4236 status.errIfFailureAndReset("%s: Identifier", identifier);
4237 assertTrue(uid + ": Constructor",
4238 unit == MeasureUnit::forIdentifier(identifier, status));
4239 status.errIfFailureAndReset("%s: Constructor", identifier);
4240 assertEquals(uid + ": Complexity",
4241 UMEASURE_UNIT_MIXED,
4242 unit.getComplexity(status));
4243 status.errIfFailureAndReset("%s: Complexity", identifier);
4244
4245 auto pair = unit.splitToSingleUnits(status);
4246 const LocalArray<MeasureUnit>& subUnits = pair.first;
4247 int32_t length = pair.second;
4248 assertEquals(uid + ": Length", subIdentifierCount, length);
4249 for (int32_t i = 0;; i++) {
4250 if (i >= subIdentifierCount || i >= length) break;
4251 assertEquals(uid + ": Sub-unit #" + Int64ToUnicodeString(i),
4252 subIdentifiers[i],
4253 subUnits[i].getIdentifier());
4254 }
4255 }
4256
createMeasureFormatTest()4257 extern IntlTest *createMeasureFormatTest() {
4258 return new MeasureFormatTest();
4259 }
4260
4261 #endif
4262
4263