]>
Commit | Line | Data |
---|---|---|
2ca993e8 A |
1 | /******************************************************************** |
2 | * Copyright (c) 2015-2016, Apple Inc. All Rights Reserved. | |
3 | ********************************************************************/ | |
4 | /* C API TEST FOR APPLE MEASUREFORMAT C WRAPPER */ | |
5 | ||
6 | #include "unicode/utypes.h" | |
f3c0d7a5 A |
7 | |
8 | #if U_PLATFORM_IS_DARWIN_BASED || U_PLATFORM_IS_LINUX_BASED || U_PLATFORM == U_PF_BSD || U_PLATFORM == U_PF_SOLARIS | |
2ca993e8 | 9 | #include <unistd.h> |
f3c0d7a5 | 10 | #endif |
2ca993e8 A |
11 | |
12 | #if !UCONFIG_NO_FORMATTING | |
13 | ||
14 | #include "unicode/uameasureformat.h" | |
15 | #include "unicode/ustring.h" | |
a62d09fc | 16 | #include "unicode/uloc.h" |
2ca993e8 A |
17 | #include "cintltst.h" |
18 | #include "cmemory.h" | |
19 | #include "cstring.h" | |
20 | ||
21 | static void TestUAMeasureFormat(void); | |
a62d09fc | 22 | static void TestUAMeasFmtOpenAllLocs(void); |
2ca993e8 A |
23 | static void TestUAGetUnitsForUsage(void); |
24 | static void TestUAGetCategoryForUnit(void); | |
25 | ||
26 | void addMeasureFormatTest(TestNode** root); | |
27 | ||
28 | #define TESTCASE(x) addTest(root, &x, "tsformat/cmeasureformattest/" #x) | |
29 | ||
30 | void addMeasureFormatTest(TestNode** root) | |
31 | { | |
32 | TESTCASE(TestUAMeasureFormat); | |
a62d09fc | 33 | TESTCASE(TestUAMeasFmtOpenAllLocs); |
2ca993e8 A |
34 | TESTCASE(TestUAGetUnitsForUsage); |
35 | TESTCASE(TestUAGetCategoryForUnit); | |
36 | } | |
37 | ||
38 | typedef struct { | |
39 | UAMeasureUnit unit; | |
40 | float value; | |
41 | const char * expectFmt_wide_2; | |
42 | const char * expectFmt_wide_0; | |
43 | const char * expectFmt_shrt_X; | |
44 | const char * expectFmt_shrt_1; | |
45 | const char * expectFmt_narr_0; | |
46 | const char * expectFmt_numr_0; | |
47 | int32_t beginInt_wide_0; | |
48 | int32_t endInt_wide_0; | |
49 | int32_t beginInt_numr_0; | |
50 | int32_t endInt_numr_0; | |
51 | } SingleUnitFormat; | |
52 | ||
53 | typedef struct { | |
54 | UAMeasureUnit unit; | |
55 | const char * expectName_wide; | |
56 | const char * expectName_shrt; | |
57 | const char * expectName_narr; | |
58 | } SingleUnitName; | |
59 | ||
60 | typedef struct { | |
61 | const UAMeasure* measures; | |
62 | int32_t measureCount; | |
63 | const char * expectFmt_wide_2; | |
64 | const char * expectFmt_wide_0; | |
65 | const char * expectFmt_shrt_X; | |
66 | const char * expectFmt_shrt_1; | |
67 | const char * expectFmt_shrtr_1; | |
68 | const char * expectFmt_narr_0; | |
69 | const char * expectFmt_numr_0; | |
70 | int32_t ranges_wide_2[8][3]; | |
71 | int32_t ranges_shrtr_1[8][3]; | |
72 | int32_t ranges_numr_0[8][3]; | |
73 | } MultipleUnitFormat; | |
74 | ||
75 | typedef struct { | |
76 | const UAMeasureUnit* units; | |
77 | int32_t unitCount; | |
78 | UAMeasureNameListStyle listStyle; | |
79 | const char * expectName_wide; | |
80 | const char * expectName_shrt; | |
81 | const char * expectName_narr; | |
82 | } MultipleUnitName; | |
83 | ||
84 | typedef struct { | |
85 | const char * locale; | |
86 | const SingleUnitFormat * singleUnitFormatTests; // may be NULL | |
87 | const SingleUnitName * singleUnitNameTests; // may be NULL | |
88 | const MultipleUnitFormat * multipleUnitFormatTests; // may be NULL | |
89 | const MultipleUnitName * multipleUnitNameTests; // may be NULL | |
90 | } LocaleWidthNumFmtItem; | |
91 | ||
92 | static const SingleUnitFormat en_singFmt[] = { | |
93 | // unit value wide_2 wide_0 shrt_X shrt_1 narr_0 numr_0 wide_0 narr_0 | |
94 | { UAMEASUNIT_DURATION_MINUTE, 0.0, "0.00 minutes", "0 minutes", "0 min", "0.0 min", "0m", "0m", 0,1, 0,1 }, | |
95 | { UAMEASUNIT_DURATION_MINUTE, 1.0, "1.00 minutes", "1 minute", "1 min", "1.0 min", "1m", "1m", 0,1, 0,1 }, | |
96 | { UAMEASUNIT_DURATION_MINUTE, 5.25, "5.25 minutes", "5 minutes", "5.25 min", "5.2 min", "5m", "5m", 0,1, 0,1 }, | |
97 | { UAMEASUNIT_DURATION_DAY, 5.25, "5.25 days", "5 days", "5.25 days", "5.2 days", "5d", "5d", 0,1, 0,1 }, | |
98 | { UAMEASUNIT_DURATION_WEEK, 5.25, "5.25 weeks", "5 weeks", "5.25 wks", "5.2 wks", "5w", "5w", 0,1, 0,1 }, | |
99 | { UAMEASUNIT_DURATION_CENTURY, 37.203, "37.20 centuries", "37 centuries", "37.203 c", "37.2 c", "37 c", "37 c", 0,2, 0,2 }, | |
100 | { UAMEASUNIT_LENGTH_CENTIMETER, 37.203, "37.20 centimeters", "37 centimeters", "37.203 cm", "37.2 cm", "37cm", "37cm", 0,2, 0,2 }, | |
0f5d89e8 | 101 | { UAMEASUNIT_SPEED_KILOMETER_PER_HOUR, 37.203, "37.20 kilometers per hour", "37 kilometers per hour", "37.203 km/h", "37.2 km/h", "37km/h", "37km/h", 0,2, 0,2 }, |
2ca993e8 A |
102 | { UAMEASUNIT_TEMPERATURE_CELSIUS, 37.203, "37.20 degrees Celsius", "37 degrees Celsius", "37.203\\u00B0C", "37.2\\u00B0C", "37\\u00B0C", "37\\u00B0", 0,2, 0,2 }, |
103 | { UAMEASUNIT_TEMPERATURE_FAHRENHEIT, 37.203, "37.20 degrees Fahrenheit", "37 degrees Fahrenheit", "37.203\\u00B0F", "37.2\\u00B0F", "37\\u00B0", "37\\u00B0", 0,2, 0,2 }, | |
f3c0d7a5 | 104 | { UAMEASUNIT_TEMPERATURE_GENERIC, 37.203, "37.20 degrees", "37 degrees", "37.203\\u00B0", "37.2\\u00B0", "37\\u00B0", "37\\u00B0", 0,2, 0,2 }, |
2ca993e8 A |
105 | { UAMEASUNIT_VOLUME_LITER, 37.203, "37.20 liters", "37 liters", "37.203 L", "37.2 L", "37L", "37L", 0,2, 0,2 }, |
106 | { UAMEASUNIT_ENERGY_FOODCALORIE, 37.203, "37.20 Calories", "37 Calories", "37.203 Cal", "37.2 Cal", "37Cal", "37Cal", 0,2, 0,2 }, | |
107 | { UAMEASUNIT_ENERGY_JOULE, 37.203, "37.20 joules", "37 joules", "37.203 J", "37.2 J", "37J", "37J", 0,2, 0,2 }, | |
108 | { UAMEASUNIT_DIGITAL_MEGABYTE, 37.203, "37.20 megabytes", "37 megabytes", "37.203 MB", "37.2 MB", "37MB", "37MB", 0,2, 0,2 }, | |
109 | { (UAMeasureUnit)0, 0, NULL, NULL, NULL, NULL, NULL, NULL } | |
110 | }; | |
111 | ||
112 | static const SingleUnitFormat en_GB_singFmt[] = { | |
113 | // unit value wide_2 wide_0 shrt_X shrt_1 narr_0 numr_0 wide_0 narr_0 | |
114 | { UAMEASUNIT_DURATION_MINUTE, 0.0, "0.00 minutes", "0 minutes", "0 min", "0.0 min", "0m", "0m", 0,1, 0,1 }, | |
115 | { UAMEASUNIT_DURATION_MINUTE, 1.0, "1.00 minutes", "1 minute", "1 min", "1.0 min", "1m", "1m", 0,1, 0,1 }, | |
116 | { UAMEASUNIT_DURATION_MINUTE, 5.25, "5.25 minutes", "5 minutes", "5.25 min", "5.2 min", "5m", "5m", 0,1, 0,1 }, | |
117 | { UAMEASUNIT_LENGTH_CENTIMETER, 37.203, "37.20 centimetres", "37 centimetres", "37.203 cm", "37.2 cm", "37cm", "37cm", 0,2, 0,2 }, | |
118 | { UAMEASUNIT_TEMPERATURE_CELSIUS, 37.203, "37.20 degrees Celsius", "37 degrees Celsius", "37.203\\u00B0C", "37.2\\u00B0C", "37\\u00B0", "37\\u00B0", 0,2, 0,2 }, | |
119 | { UAMEASUNIT_TEMPERATURE_FAHRENHEIT, 37.203, "37.20 degrees Fahrenheit", "37 degrees Fahrenheit", "37.203\\u00B0F", "37.2\\u00B0F", "37\\u00B0F", "37\\u00B0", 0,2, 0,2 }, | |
f3c0d7a5 | 120 | { UAMEASUNIT_TEMPERATURE_GENERIC, 37.203, "37.20 degrees", "37 degrees", "37.203\\u00B0", "37.2\\u00B0", "37\\u00B0", "37\\u00B0", 0,2, 0,2 }, |
2ca993e8 A |
121 | { UAMEASUNIT_VOLUME_LITER, 37.203, "37.20 litres", "37 litres", "37.203 l", "37.2 l", "37l", "37l", 0,2, 0,2 }, |
122 | { UAMEASUNIT_ENERGY_FOODCALORIE, 37.203, "37.20 Calories", "37 Calories", "37.203 Cal", "37.2 Cal", "37Cal", "37Cal", 0,2, 0,2 }, | |
123 | { (UAMeasureUnit)0, 0, NULL, NULL, NULL, NULL, NULL, NULL } | |
124 | }; | |
125 | ||
126 | static const SingleUnitFormat fr_singFmt[] = { | |
127 | // unit value wide_2 wide_0 shrt_X shrt_1 narr_0 numr_0 wide_0 narr_0 | |
3d1f044b A |
128 | { UAMEASUNIT_DURATION_MINUTE, 0.0, "0,00 minute", "0 minute", "0\\u00A0mn", "0,0\\u00A0mn", "0mn", "0mn", 0,1, 0,1 }, |
129 | { UAMEASUNIT_DURATION_MINUTE, 1.0, "1,00 minute", "1 minute", "1\\u00A0mn", "1,0\\u00A0mn", "1mn", "1mn", 0,1, 0,1 }, | |
130 | { UAMEASUNIT_DURATION_MINUTE, 5.25, "5,25 minutes", "5 minutes", "5,25\\u00A0mn", "5,2\\u00A0mn", "5mn", "5mn", 0,1, 0,1 }, | |
131 | { UAMEASUNIT_LENGTH_CENTIMETER, 37.203, "37,20\\u00A0centim\\u00E8tres", "37\\u00A0centim\\u00E8tres", "37,203\\u202Fcm", "37,2\\u202Fcm", "37 cm", "37 cm", 0,2, 0,2 }, | |
132 | { UAMEASUNIT_TEMPERATURE_CELSIUS, 37.203, "37,20\\u00A0degr\\u00E9s Celsius","37\\u00A0degr\\u00E9s Celsius", "37,203\\u202F\\u00B0C", "37,2\\u202F\\u00B0C", "37\\u00B0C", "37\\u00B0", 0,2, 0,2 }, | |
133 | { UAMEASUNIT_TEMPERATURE_FAHRENHEIT, 37.203, "37,20\\u00A0degr\\u00E9s Fahrenheit", "37\\u00A0degr\\u00E9s Fahrenheit", "37,203\\u202F\\u00B0F", "37,2\\u202F\\u00B0F", "37\\u202F\\u00B0F", "37\\u00B0", 0,2, 0,2 }, | |
134 | { UAMEASUNIT_TEMPERATURE_GENERIC, 37.203, "37,20\\u00A0degr\\u00E9s", "37\\u00A0degr\\u00E9s", "37,203\\u00B0", "37,2\\u00B0", "37\\u00B0", "37\\u00B0", 0,2, 0,2 }, | |
135 | { UAMEASUNIT_VOLUME_LITER, 37.203, "37,20\\u00A0litres", "37\\u00A0litres", "37,203\\u202Fl", "37,2\\u202Fl", "37 l", "37 l", 0,2, 0,2 }, | |
136 | { UAMEASUNIT_ENERGY_FOODCALORIE, 37.203, "37,20\\u00A0kilocalories", "37\\u00A0kilocalories", "37,203\\u202Fkcal","37,2\\u202Fkcal","37\\u202Fkcal","37\\u202Fkcal", 0,2, 0,2 }, | |
2ca993e8 A |
137 | { (UAMeasureUnit)0, 0, NULL, NULL, NULL, NULL, NULL, NULL } |
138 | }; | |
139 | ||
140 | static const SingleUnitFormat fr_CA_singFmt[] = { | |
141 | // unit value wide_2 wide_0 shrt_X shrt_1 narr_0 numr_0 wide_0 narr_0 | |
142 | { UAMEASUNIT_DURATION_MINUTE, 0.0, "0,00 minute", "0 minute", "0 min", "0,0 min", "0m", "0m", 0,1, 0,1 }, | |
143 | { UAMEASUNIT_DURATION_MINUTE, 1.0, "1,00 minute", "1 minute", "1 min", "1,0 min", "1m", "1m", 0,1, 0,1 }, | |
144 | { UAMEASUNIT_DURATION_MINUTE, 5.25, "5,25 minutes", "5 minutes", "5,25 min", "5,2 min", "5m", "5m", 0,1, 0,1 }, | |
145 | { UAMEASUNIT_LENGTH_CENTIMETER, 37.203, "37,20 centim\\u00E8tres", "37 centim\\u00E8tres", "37,203 cm", "37,2 cm", "37 cm", "37 cm", 0,2, 0,2 }, | |
c5116b9f A |
146 | { UAMEASUNIT_TEMPERATURE_CELSIUS, 37.203, "37,20 degr\\u00E9s Celsius", "37 degr\\u00E9s Celsius", "37,203\\u00A0\\u00B0C", "37,2\\u00A0\\u00B0C", "37\\u00A0\\u00B0C", "37\\u00B0", 0,2, 0,2 }, |
147 | { UAMEASUNIT_TEMPERATURE_FAHRENHEIT, 37.203, "37,20 degr\\u00E9s Fahrenheit", "37 degr\\u00E9s Fahrenheit", "37,203\\u00A0\\u00B0F", "37,2\\u00A0\\u00B0F", "37\\u00A0\\u00B0F", "37\\u00B0", 0,2, 0,2 }, | |
2ca993e8 A |
148 | { UAMEASUNIT_TEMPERATURE_GENERIC, 37.203, "37,20\\u00B0", "37\\u00B0", "37,203\\u00B0", "37,2\\u00B0", "37\\u00B0", "37\\u00B0", 0,2, 0,2 }, |
149 | { UAMEASUNIT_VOLUME_LITER, 37.203, "37,20 litres", "37 litres", "37,203 L", "37,2 L", "37L", "37L", 0,2, 0,2 }, | |
3d1f044b | 150 | { UAMEASUNIT_ENERGY_FOODCALORIE, 37.203, "37,20 calories", "37 calories", "37,203 cal", "37,2 cal", "37 cal", "37 cal", 0,2, 0,2 }, |
2ca993e8 A |
151 | { (UAMeasureUnit)0, 0, NULL, NULL, NULL, NULL, NULL, NULL } |
152 | }; | |
153 | ||
c5116b9f A |
154 | static const SingleUnitFormat zh_Hant_singFmt[] = { |
155 | // unit value wide_2 wide_0 shrt_X shrt_1 narr_0 numr_0 wide_0 narr_0 | |
156 | { UAMEASUNIT_DURATION_MINUTE, 5.25, "5.25\\u5206\\u9418", "5\\u5206\\u9418", "5.25\\u5206\\u9418", "5.2\\u5206\\u9418", "5\\u5206", "5\\u5206", 0,1, 0,1 }, | |
157 | { UAMEASUNIT_LENGTH_CENTIMETER, 37.203, "37.20\\u516C\\u5206", "37\\u516C\\u5206", "37.203\\u516C\\u5206", "37.2\\u516C\\u5206", "37\\u516C\\u5206", "37\\u516C\\u5206", 0,2, 0,2 }, | |
158 | { UAMEASUNIT_TEMPERATURE_GENERIC, 37.203, "37.20\\u00B0", "37\\u00B0", "37.203\\u00B0", "37.2\\u00B0", "37\\u00B0", "37\\u00B0", 0,2, 0,2 }, | |
159 | { UAMEASUNIT_ANGLE_DEGREE, 37.203, "37.20\\u5EA6", "37\\u5EA6", "37.203\\u00B0", "37.2\\u00B0", "37\\u00B0", "37\\u00B0", 0,2, 0,2 }, | |
160 | { (UAMeasureUnit)0, 0, NULL, NULL, NULL, NULL, NULL, NULL } | |
161 | }; | |
162 | ||
2ca993e8 A |
163 | static const SingleUnitFormat cs_singFmt[] = { |
164 | // unit value wide_2 wide_0 shrt_X shrt_1 narr_0 numr_0 wide_0 narr_0 | |
165 | { UAMEASUNIT_DURATION_MINUTE, 0.0, "0,00 minuty", "0 minut", "0 min", "0,0 min", "0 m", "0 m", 0,1, 0,1 }, // other for integer, else many | |
166 | { UAMEASUNIT_DURATION_MINUTE, 1.0, "1,00 minuty", "1 minuta", "1 min", "1,0 min", "1 m", "1 m", 0,1, 0,1 }, // one for integer, else many | |
167 | { UAMEASUNIT_DURATION_MINUTE, 2.0, "2,00 minuty", "2 minuty", "2 min", "2,0 min", "2 m", "2 m", 0,1, 0,1 }, // few for integer, else many | |
168 | { UAMEASUNIT_DURATION_MINUTE, 8.5, "8,50 minuty", "8 minut", "8,5 min", "8,5 min", "8 m", "8 m", 0,1, 0,1 }, // other for integer, else many | |
169 | { (UAMeasureUnit)0, 0, NULL, NULL, NULL, NULL, NULL, NULL } | |
170 | }; | |
171 | ||
1a147d09 A |
172 | static const SingleUnitFormat nl_singFmt[] = { |
173 | // unit value wide_2 wide_0 shrt_X shrt_1 narr_0 numr_0 wide_0 narr_0 | |
174 | { UAMEASUNIT_TEMPERATURE_CELSIUS, 37.203, "37,20 graden Celsius", "37 graden Celsius", "37,203\\u00A0\\u00B0C", "37,2\\u00A0\\u00B0C", "37\\u00B0", "37\\u00B0", 0,2, 0,2 }, | |
175 | { UAMEASUNIT_TEMPERATURE_FAHRENHEIT, 37.203, "37,20 graden Fahrenheit", "37 graden Fahrenheit", "37,203\\u00A0\\u00B0F", "37,2\\u00A0\\u00B0F", "37\\u00B0F", "37\\u00B0", 0,2, 0,2 }, | |
176 | { (UAMeasureUnit)0, 0, NULL, NULL, NULL, NULL, NULL, NULL } | |
177 | }; | |
178 | ||
179 | static const SingleUnitFormat it_singFmt[] = { | |
180 | // unit value wide_2 wide_0 shrt_X shrt_1 narr_0 numr_0 wide_0 narr_0 | |
181 | { UAMEASUNIT_DURATION_HOUR, 37.203, "37,20 ore", "37 ore", "37,203 h", "37,2 h", "37 h", "37 h", 0,2, 0,2 }, | |
182 | { UAMEASUNIT_DURATION_MINUTE, 37.203, "37,20 minuti", "37 minuti", "37,203 min", "37,2 min", "37 min", "37 min", 0,2, 0,2 }, | |
183 | { (UAMeasureUnit)0, 0, NULL, NULL, NULL, NULL, NULL, NULL } | |
184 | }; | |
185 | ||
186 | static const SingleUnitFormat nb_singFmt[] = { | |
187 | // unit value wide_2 wide_0 shrt_X shrt_1 narr_0 numr_0 wide_0 narr_0 | |
188 | { UAMEASUNIT_DURATION_HOUR, 37.203, "37,20 timer", "37 timer", "37,203 t", "37,2 t", "37 t", "37 t", 0,2, 0,2 }, | |
189 | { UAMEASUNIT_DURATION_MINUTE, 37.203, "37,20 minutter", "37 minutter", "37,203 min", "37,2 min", "37 m", "37 m", 0,2, 0,2 }, | |
190 | { (UAMeasureUnit)0, 0, NULL, NULL, NULL, NULL, NULL, NULL } | |
191 | }; | |
192 | ||
2ca993e8 A |
193 | static const SingleUnitName en_singNam[] = { |
194 | // unit wide shrt narr | |
195 | { UAMEASUNIT_DURATION_MINUTE, "minutes", "min", "min" }, | |
196 | { UAMEASUNIT_DURATION_CENTURY, "centuries", "c", "c" }, | |
197 | { UAMEASUNIT_LENGTH_CENTIMETER, "centimeters", "cm", "cm" }, | |
198 | { UAMEASUNIT_SPEED_KILOMETER_PER_HOUR, "kilometers per hour", "km/hour", "km/hr" }, | |
199 | { UAMEASUNIT_TEMPERATURE_CELSIUS, "degrees Celsius", "deg. C", "\\u00B0C" }, | |
200 | { UAMEASUNIT_TEMPERATURE_FAHRENHEIT, "degrees Fahrenheit", "deg. F", "\\u00B0F" }, | |
f3c0d7a5 | 201 | { UAMEASUNIT_TEMPERATURE_GENERIC, "degrees", "deg.", "deg." }, |
2ca993e8 A |
202 | { UAMEASUNIT_VOLUME_LITER, "liters", "liters", "liter" }, |
203 | { UAMEASUNIT_ENERGY_FOODCALORIE, "Calories", "Cal", "Cal" }, | |
204 | { UAMEASUNIT_ENERGY_JOULE, "joules", "joules", "joule" }, | |
205 | { UAMEASUNIT_DIGITAL_MEGABYTE, "megabytes", "MByte", "MByte" }, | |
206 | { (UAMeasureUnit)0, NULL, NULL, NULL } | |
207 | }; | |
208 | ||
209 | static const SingleUnitName en_GB_singNam[] = { | |
210 | // unit wide shrt narr | |
211 | { UAMEASUNIT_DURATION_MINUTE, "minutes", "min", "min" }, | |
212 | { UAMEASUNIT_LENGTH_CENTIMETER, "centimetres", "cm", "cm" }, | |
213 | { UAMEASUNIT_TEMPERATURE_CELSIUS, "degrees Celsius", "deg. C", "\\u00B0C" }, | |
214 | { UAMEASUNIT_TEMPERATURE_FAHRENHEIT, "degrees Fahrenheit", "deg. F", "\\u00B0F" }, | |
f3c0d7a5 | 215 | { UAMEASUNIT_TEMPERATURE_GENERIC, "degrees", "deg.", "deg." }, |
2ca993e8 A |
216 | { UAMEASUNIT_VOLUME_LITER, "litres", "litres", "litre" }, |
217 | { UAMEASUNIT_ENERGY_FOODCALORIE, "Calories", "Cal", "Cal" }, | |
218 | { (UAMeasureUnit)0, NULL, NULL, NULL } | |
219 | }; | |
220 | ||
221 | static const UAMeasure meas_hrMnSc[] = { {37.3,UAMEASUNIT_DURATION_HOUR}, {12.1,UAMEASUNIT_DURATION_MINUTE}, {5.32,UAMEASUNIT_DURATION_SECOND} }; | |
222 | static const UAMeasure meas_hrMn[] = { {37.3,UAMEASUNIT_DURATION_HOUR}, {12.1,UAMEASUNIT_DURATION_MINUTE} }; | |
223 | static const UAMeasure meas_mCm[] = { {37.3,UAMEASUNIT_LENGTH_METER}, {12.1,UAMEASUNIT_LENGTH_CENTIMETER} }; | |
224 | static const UAMeasure meas_cm[] = { {12.1,UAMEASUNIT_LENGTH_CENTIMETER} }; | |
225 | static const UAMeasure meas_2hrMn[] = { {2.0,UAMEASUNIT_DURATION_HOUR}, {12.1,UAMEASUNIT_DURATION_MINUTE} }; | |
226 | static const UAMeasure meas_moDys[] = { {1.0,UAMEASUNIT_DURATION_MONTH}, {2.0,UAMEASUNIT_DURATION_DAY} }; | |
227 | ||
228 | static const MultipleUnitFormat en_multFmt[] = { | |
229 | // measures count wide_2 wide_0 shrt_X shrt_1 shrtr_1 narr_0 numr_0 | |
230 | { meas_hrMnSc, UPRV_LENGTHOF(meas_hrMnSc), "37 hours, 12 minutes, 5.32 seconds", "37 hours, 12 minutes, 5 seconds", "37 hr, 12 min, 5.32 sec", "37 hr, 12 min, 5.3 sec", "37hr 12min 5.3sec", "37h 12m 5s", "13:12:05", | |
231 | /* ranges_wide_2: */ {{UAMEASUNIT_DURATION_HOUR,0,8},{UAMEASUNIT_DURATION_HOUR|UAMEASFMT_NUMERIC_FIELD_FLAG,0,2},{UAMEASUNIT_DURATION_MINUTE,10,20},{UAMEASUNIT_DURATION_MINUTE|UAMEASFMT_NUMERIC_FIELD_FLAG,10,12},{UAMEASUNIT_DURATION_SECOND,22,34},{UAMEASUNIT_DURATION_SECOND|UAMEASFMT_NUMERIC_FIELD_FLAG,22,26}}, | |
232 | /* ranges_shrtr_1: */ {{UAMEASUNIT_DURATION_HOUR,0,4},{UAMEASUNIT_DURATION_HOUR|UAMEASFMT_NUMERIC_FIELD_FLAG,0,2},{UAMEASUNIT_DURATION_MINUTE, 5,10},{UAMEASUNIT_DURATION_MINUTE|UAMEASFMT_NUMERIC_FIELD_FLAG, 5, 7},{UAMEASUNIT_DURATION_SECOND,11,17},{UAMEASUNIT_DURATION_SECOND|UAMEASFMT_NUMERIC_FIELD_FLAG,11,14}}, | |
233 | /* ranges_numr_0: */ {{UAMEASUNIT_DURATION_HOUR,0,2},{UAMEASUNIT_DURATION_HOUR|UAMEASFMT_NUMERIC_FIELD_FLAG,0,2},{UAMEASUNIT_DURATION_MINUTE, 3, 5},{UAMEASUNIT_DURATION_MINUTE|UAMEASFMT_NUMERIC_FIELD_FLAG, 3, 5},{UAMEASUNIT_DURATION_SECOND, 6, 8},{UAMEASUNIT_DURATION_SECOND|UAMEASFMT_NUMERIC_FIELD_FLAG, 6, 8}} }, | |
234 | { meas_hrMn, UPRV_LENGTHOF(meas_hrMn), "37 hours, 12.10 minutes", "37 hours, 12 minutes", "37 hr, 12.1 min", "37 hr, 12.1 min", "37hr 12.1min", "37h 12m", "13:12", | |
235 | /* ranges_wide_2: */ {{UAMEASUNIT_DURATION_HOUR,0,8},{UAMEASUNIT_DURATION_HOUR|UAMEASFMT_NUMERIC_FIELD_FLAG,0,2},{UAMEASUNIT_DURATION_MINUTE,10,23},{UAMEASUNIT_DURATION_MINUTE|UAMEASFMT_NUMERIC_FIELD_FLAG,10,15}}, | |
236 | /* ranges_shrtr_1: */ {{UAMEASUNIT_DURATION_HOUR,0,4},{UAMEASUNIT_DURATION_HOUR|UAMEASFMT_NUMERIC_FIELD_FLAG,0,2},{UAMEASUNIT_DURATION_MINUTE, 5,12},{UAMEASUNIT_DURATION_MINUTE|UAMEASFMT_NUMERIC_FIELD_FLAG, 5, 9}}, | |
237 | /* ranges_numr_0: */ {{UAMEASUNIT_DURATION_HOUR,0,2},{UAMEASUNIT_DURATION_HOUR|UAMEASFMT_NUMERIC_FIELD_FLAG,0,2},{UAMEASUNIT_DURATION_MINUTE, 3, 5},{UAMEASUNIT_DURATION_MINUTE|UAMEASFMT_NUMERIC_FIELD_FLAG, 3, 5}} }, | |
238 | { meas_mCm, UPRV_LENGTHOF(meas_mCm), "37 meters, 12.10 centimeters", "37 meters, 12 centimeters", "37 m, 12.1 cm", "37 m, 12.1 cm", "37m 12.1cm", "37m 12cm", "37m 12cm", | |
239 | /* ranges_wide_2: */ {{UAMEASUNIT_LENGTH_METER,0,9},{UAMEASUNIT_LENGTH_METER|UAMEASFMT_NUMERIC_FIELD_FLAG,0,2},{UAMEASUNIT_LENGTH_CENTIMETER,11,28},{UAMEASUNIT_LENGTH_CENTIMETER|UAMEASFMT_NUMERIC_FIELD_FLAG,11,16}}, | |
240 | /* ranges_shrtr_1: */ {{UAMEASUNIT_LENGTH_METER,0,3},{UAMEASUNIT_LENGTH_METER|UAMEASFMT_NUMERIC_FIELD_FLAG,0,2},{UAMEASUNIT_LENGTH_CENTIMETER, 4,10},{UAMEASUNIT_LENGTH_CENTIMETER|UAMEASFMT_NUMERIC_FIELD_FLAG, 4, 8}}, | |
241 | /* ranges_numr_0: */ {{UAMEASUNIT_LENGTH_METER,0,3},{UAMEASUNIT_LENGTH_METER|UAMEASFMT_NUMERIC_FIELD_FLAG,0,2},{UAMEASUNIT_LENGTH_CENTIMETER, 4, 8},{UAMEASUNIT_LENGTH_CENTIMETER|UAMEASFMT_NUMERIC_FIELD_FLAG, 4, 6}} }, | |
242 | { meas_cm, UPRV_LENGTHOF(meas_cm), "12.10 centimeters", "12 centimeters", "12.1 cm", "12.1 cm", "12.1cm", "12cm", "12cm", | |
243 | /* ranges_wide_2: */ {{UAMEASUNIT_LENGTH_CENTIMETER,0,17},{UAMEASUNIT_LENGTH_CENTIMETER|UAMEASFMT_NUMERIC_FIELD_FLAG,0,5}}, | |
244 | /* ranges_shrtr_1: */ {{UAMEASUNIT_LENGTH_CENTIMETER,0, 6},{UAMEASUNIT_LENGTH_CENTIMETER|UAMEASFMT_NUMERIC_FIELD_FLAG,0,4}}, | |
245 | /* ranges_numr_0: */ {{UAMEASUNIT_LENGTH_CENTIMETER,0, 4},{UAMEASUNIT_LENGTH_CENTIMETER|UAMEASFMT_NUMERIC_FIELD_FLAG,0,2}} }, | |
246 | { NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL } | |
247 | }; | |
248 | ||
249 | static const MultipleUnitFormat en_GB_multFmt[] = { | |
250 | // measures count wide_2 wide_0 shrt_X shrt_1 shrtr_1 narr_0 numr_0 | |
251 | { meas_hrMnSc, UPRV_LENGTHOF(meas_hrMnSc), "37 hours, 12 minutes, 5.32 seconds", "37 hours, 12 minutes, 5 seconds", "37 hrs, 12 min, 5.32 secs", "37 hrs, 12 min, 5.3 secs", "37hrs 12min 5.3secs", "37h 12m 5s", "13:12:05", | |
252 | /* ranges_wide_2: */ {{UAMEASUNIT_DURATION_HOUR,0,8},{UAMEASUNIT_DURATION_HOUR|UAMEASFMT_NUMERIC_FIELD_FLAG,0,2},{UAMEASUNIT_DURATION_MINUTE,10,20},{UAMEASUNIT_DURATION_MINUTE|UAMEASFMT_NUMERIC_FIELD_FLAG,10,12},{UAMEASUNIT_DURATION_SECOND,22,34},{UAMEASUNIT_DURATION_SECOND|UAMEASFMT_NUMERIC_FIELD_FLAG,22,26}}, | |
253 | /* ranges_shrtr_1: */ {{UAMEASUNIT_DURATION_HOUR,0,5},{UAMEASUNIT_DURATION_HOUR|UAMEASFMT_NUMERIC_FIELD_FLAG,0,2},{UAMEASUNIT_DURATION_MINUTE, 6,11},{UAMEASUNIT_DURATION_MINUTE|UAMEASFMT_NUMERIC_FIELD_FLAG, 6, 8},{UAMEASUNIT_DURATION_SECOND,12,19},{UAMEASUNIT_DURATION_SECOND|UAMEASFMT_NUMERIC_FIELD_FLAG,12,15}}, | |
254 | /* ranges_numr_0: */ {{UAMEASUNIT_DURATION_HOUR,0,2},{UAMEASUNIT_DURATION_HOUR|UAMEASFMT_NUMERIC_FIELD_FLAG,0,2},{UAMEASUNIT_DURATION_MINUTE, 3, 5},{UAMEASUNIT_DURATION_MINUTE|UAMEASFMT_NUMERIC_FIELD_FLAG, 3, 5},{UAMEASUNIT_DURATION_SECOND, 6, 8},{UAMEASUNIT_DURATION_SECOND|UAMEASFMT_NUMERIC_FIELD_FLAG, 6, 8}} }, | |
255 | { meas_hrMn, UPRV_LENGTHOF(meas_hrMn), "37 hours, 12.10 minutes", "37 hours, 12 minutes", "37 hrs, 12.1 min", "37 hrs, 12.1 min", "37hrs 12.1min", "37h 12m", "13:12", | |
256 | /* ranges_wide_2: */ {{UAMEASUNIT_DURATION_HOUR,0,8},{UAMEASUNIT_DURATION_HOUR|UAMEASFMT_NUMERIC_FIELD_FLAG,0,2},{UAMEASUNIT_DURATION_MINUTE,10,23},{UAMEASUNIT_DURATION_MINUTE|UAMEASFMT_NUMERIC_FIELD_FLAG,10,15}}, | |
257 | /* ranges_shrtr_1: */ {{UAMEASUNIT_DURATION_HOUR,0,5},{UAMEASUNIT_DURATION_HOUR|UAMEASFMT_NUMERIC_FIELD_FLAG,0,2},{UAMEASUNIT_DURATION_MINUTE, 6,13},{UAMEASUNIT_DURATION_MINUTE|UAMEASFMT_NUMERIC_FIELD_FLAG, 6,10}}, | |
258 | /* ranges_numr_0: */ {{UAMEASUNIT_DURATION_HOUR,0,2},{UAMEASUNIT_DURATION_HOUR|UAMEASFMT_NUMERIC_FIELD_FLAG,0,2},{UAMEASUNIT_DURATION_MINUTE, 3, 5},{UAMEASUNIT_DURATION_MINUTE|UAMEASFMT_NUMERIC_FIELD_FLAG, 3, 5}} }, | |
259 | { meas_mCm, UPRV_LENGTHOF(meas_mCm), "37 metres, 12.10 centimetres", "37 metres, 12 centimetres", "37 m, 12.1 cm", "37 m, 12.1 cm", "37m 12.1cm", "37m 12cm", "37m 12cm", | |
260 | /* ranges_wide_2: */ {{UAMEASUNIT_LENGTH_METER,0,9},{UAMEASUNIT_LENGTH_METER|UAMEASFMT_NUMERIC_FIELD_FLAG,0,2},{UAMEASUNIT_LENGTH_CENTIMETER,11,28},{UAMEASUNIT_LENGTH_CENTIMETER|UAMEASFMT_NUMERIC_FIELD_FLAG,11,16}}, | |
261 | /* ranges_shrtr_1: */ {{UAMEASUNIT_LENGTH_METER,0,3},{UAMEASUNIT_LENGTH_METER|UAMEASFMT_NUMERIC_FIELD_FLAG,0,2},{UAMEASUNIT_LENGTH_CENTIMETER, 4,10},{UAMEASUNIT_LENGTH_CENTIMETER|UAMEASFMT_NUMERIC_FIELD_FLAG, 4, 8}}, | |
262 | /* ranges_numr_0: */ {{UAMEASUNIT_LENGTH_METER,0,3},{UAMEASUNIT_LENGTH_METER|UAMEASFMT_NUMERIC_FIELD_FLAG,0,2},{UAMEASUNIT_LENGTH_CENTIMETER, 4, 8},{UAMEASUNIT_LENGTH_CENTIMETER|UAMEASFMT_NUMERIC_FIELD_FLAG, 4, 6}} }, | |
263 | { meas_cm, UPRV_LENGTHOF(meas_cm), "12.10 centimetres", "12 centimetres", "12.1 cm", "12.1 cm", "12.1cm", "12cm", "12cm", | |
264 | /* ranges_wide_2: */ {{UAMEASUNIT_LENGTH_CENTIMETER,0,17},{UAMEASUNIT_LENGTH_CENTIMETER|UAMEASFMT_NUMERIC_FIELD_FLAG,0,5}}, | |
265 | /* ranges_shrtr_1: */ {{UAMEASUNIT_LENGTH_CENTIMETER,0, 6},{UAMEASUNIT_LENGTH_CENTIMETER|UAMEASFMT_NUMERIC_FIELD_FLAG,0,4}}, | |
266 | /* ranges_numr_0: */ {{UAMEASUNIT_LENGTH_CENTIMETER,0, 4},{UAMEASUNIT_LENGTH_CENTIMETER|UAMEASFMT_NUMERIC_FIELD_FLAG,0,2}} }, | |
267 | { NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL } | |
268 | }; | |
269 | ||
270 | static const MultipleUnitFormat he_multFmt[] = { | |
271 | // measures count wide_2 wide_0 | |
272 | { meas_2hrMn, UPRV_LENGTHOF(meas_2hrMn), "\\u05E9\\u05E2\\u05EA\\u05D9\\u05D9\\u05DD \\u05D512.10 \\u05D3\\u05E7\\u05D5\\u05EA", "\\u05E9\\u05E2\\u05EA\\u05D9\\u05D9\\u05DD \\u05D512 \\u05D3\\u05E7\\u05D5\\u05EA", | |
273 | /* shrt_X, shrt_1*/ "\\u05E9\\u05E2\\u05EA\\u05D9\\u05D9\\u05DD \\u05D512.1 \\u05D3\\u05E7\\u05F3", "\\u05E9\\u05E2\\u05EA\\u05D9\\u05D9\\u05DD \\u05D512.1 \\u05D3\\u05E7\\u05F3", | |
274 | /* shrtr_1, narr_0, numr_0*/ "\\u05E9\\u05E2\\u05EA\\u05D9\\u05D9\\u05DD \\u05D512.1 \\u05D3\\u05E7\\u05F3", "\\u05E9\\u05E2\\u05EA\\u05D9\\u05D9\\u05DD \\u05D512 \\u05D3\\u05E7\\u05F3", "2:12", | |
275 | /* ranges_wide_2: */ {{UAMEASUNIT_DURATION_HOUR,0,6},{UAMEASUNIT_DURATION_MINUTE,8,18},{UAMEASUNIT_DURATION_MINUTE|UAMEASFMT_NUMERIC_FIELD_FLAG,8,13}}, | |
276 | /* ranges_shrtr_1: */ {{UAMEASUNIT_DURATION_HOUR,0,6},{UAMEASUNIT_DURATION_MINUTE,8,16},{UAMEASUNIT_DURATION_MINUTE|UAMEASFMT_NUMERIC_FIELD_FLAG,8,12}}, | |
277 | /* ranges_numr_0: */ {{UAMEASUNIT_DURATION_HOUR,0,1},{UAMEASUNIT_DURATION_HOUR|UAMEASFMT_NUMERIC_FIELD_FLAG,0,1},{UAMEASUNIT_DURATION_MINUTE,2,4},{UAMEASUNIT_DURATION_MINUTE|UAMEASFMT_NUMERIC_FIELD_FLAG,2,4}} }, | |
278 | }; | |
279 | ||
280 | static const MultipleUnitFormat hi_multFmt[] = { | |
281 | // measures count wide_2 wide_0 | |
3d1f044b A |
282 | { meas_moDys, UPRV_LENGTHOF(meas_moDys), "1 \\u092E\\u093E\\u0939 \\u0914\\u0930 2.00 \\u0926\\u093F\\u0928", "1 \\u092E\\u093E\\u0939 \\u0914\\u0930 2 \\u0926\\u093F\\u0928", |
283 | /* shrt_X, shrt_1*/ "1 \\u092E\\u093E\\u0939, 2 \\u0926\\u093F\\u0928", "1 \\u092E\\u093E\\u0939, 2.0 \\u0926\\u093F\\u0928", | |
284 | /* shrtr_1, narr_0, numr_0*/ "1 \\u092E\\u093E\\u0939, 2.0 \\u0926\\u093F\\u0928", "1 \\u092E\\u093E\\u0939, 2 \\u0926\\u093F\\u0928", "1 \\u092E\\u093E\\u0939, 2 \\u0926\\u093F\\u0928", | |
2ca993e8 A |
285 | /* ranges_wide_2: */ {{UAMEASUNIT_DURATION_MONTH,0,5},{UAMEASUNIT_DURATION_MONTH|UAMEASFMT_NUMERIC_FIELD_FLAG,0,1},{UAMEASUNIT_DURATION_DAY,9,17},{UAMEASUNIT_DURATION_DAY|UAMEASFMT_NUMERIC_FIELD_FLAG,9,13}}, |
286 | /* ranges_shrtr_1: */ {{UAMEASUNIT_DURATION_MONTH,0,5},{UAMEASUNIT_DURATION_MONTH|UAMEASFMT_NUMERIC_FIELD_FLAG,0,1},{UAMEASUNIT_DURATION_DAY,7,14},{UAMEASUNIT_DURATION_DAY|UAMEASFMT_NUMERIC_FIELD_FLAG,7,10}}, | |
287 | /* ranges_numr_0: */ {{UAMEASUNIT_DURATION_MONTH,0,5},{UAMEASUNIT_DURATION_MONTH|UAMEASFMT_NUMERIC_FIELD_FLAG,0,1},{UAMEASUNIT_DURATION_DAY,7,12},{UAMEASUNIT_DURATION_DAY|UAMEASFMT_NUMERIC_FIELD_FLAG,7,8}} }, | |
288 | }; | |
289 | ||
290 | static const UAMeasureUnit unit_hrMnSc[] = { UAMEASUNIT_DURATION_HOUR, UAMEASUNIT_DURATION_MINUTE, UAMEASUNIT_DURATION_SECOND }; | |
291 | static const UAMeasureUnit unit_hrMn[] = { UAMEASUNIT_DURATION_HOUR, UAMEASUNIT_DURATION_MINUTE }; | |
292 | static const UAMeasureUnit unit_mCm[] = { UAMEASUNIT_LENGTH_METER, UAMEASUNIT_LENGTH_CENTIMETER }; | |
293 | ||
294 | static const MultipleUnitName en_multNam[] = { | |
295 | // units count listStyle wide shrt narr | |
296 | { unit_hrMnSc, UPRV_LENGTHOF(unit_hrMnSc), UAMEASNAME_LIST_STANDARD, "hours, minutes, and seconds", "hours, min, and secs", "hour, min, and sec" }, | |
297 | { unit_hrMnSc, UPRV_LENGTHOF(unit_hrMnSc), UAMEASNAME_LIST_MATCHUNITS, "hours, minutes, seconds", "hours, min, secs", "hour min sec" }, | |
298 | { unit_hrMn, UPRV_LENGTHOF(unit_hrMn), UAMEASNAME_LIST_STANDARD, "hours and minutes", "hours and min", "hour and min" }, | |
299 | { unit_hrMn, UPRV_LENGTHOF(unit_hrMn), UAMEASNAME_LIST_MATCHUNITS, "hours, minutes", "hours, min", "hour min" }, | |
300 | { unit_mCm, UPRV_LENGTHOF(unit_mCm), UAMEASNAME_LIST_STANDARD, "meters and centimeters", "meters and cm", "meter and cm" }, | |
301 | { unit_mCm, UPRV_LENGTHOF(unit_mCm), UAMEASNAME_LIST_MATCHUNITS, "meters, centimeters", "meters, cm", "meter cm" }, | |
302 | { NULL, 0, (UAMeasureNameListStyle)0, NULL, NULL, NULL } | |
303 | }; | |
304 | ||
305 | static const MultipleUnitName en_GB_multNam[] = { | |
306 | // units count listStyle wide shrt narr | |
307 | { unit_hrMnSc, UPRV_LENGTHOF(unit_hrMnSc), UAMEASNAME_LIST_STANDARD, "hours, minutes and seconds", "hours, min and secs", "hour, min and sec" }, | |
308 | { unit_hrMnSc, UPRV_LENGTHOF(unit_hrMnSc), UAMEASNAME_LIST_MATCHUNITS, "hours, minutes, seconds", "hours, min, secs", "hour min sec" }, | |
309 | { unit_hrMn, UPRV_LENGTHOF(unit_hrMn), UAMEASNAME_LIST_STANDARD, "hours and minutes", "hours and min", "hour and min" }, | |
310 | { unit_hrMn, UPRV_LENGTHOF(unit_hrMn), UAMEASNAME_LIST_MATCHUNITS, "hours, minutes", "hours, min", "hour min" }, | |
311 | { unit_mCm, UPRV_LENGTHOF(unit_mCm), UAMEASNAME_LIST_STANDARD, "metres and centimetres", "metres and cm", "m and cm" }, | |
312 | { unit_mCm, UPRV_LENGTHOF(unit_mCm), UAMEASNAME_LIST_MATCHUNITS, "metres, centimetres", "metres, cm", "m cm" }, | |
313 | { NULL, 0, (UAMeasureNameListStyle)0, NULL, NULL, NULL } | |
314 | }; | |
315 | ||
316 | static const MultipleUnitName ja_multNam[] = { | |
317 | // units count listStyle wide shrt narr | |
318 | { unit_hrMnSc, UPRV_LENGTHOF(unit_hrMnSc), UAMEASNAME_LIST_STANDARD, "\\u6642\\u9593\\u3001\\u5206\\u3001\\u79D2", "\\u6642\\u9593\\u3001\\u5206\\u3001\\u79D2", "\\u6642\\u9593\\u3001\\u5206\\u3001\\u79D2" }, | |
319 | { unit_hrMnSc, UPRV_LENGTHOF(unit_hrMnSc), UAMEASNAME_LIST_MATCHUNITS, "\\u6642\\u9593 \\u5206 \\u79D2", "\\u6642\\u9593 \\u5206 \\u79D2", "\\u6642\\u9593\\u5206\\u79D2" }, | |
320 | { unit_hrMn, UPRV_LENGTHOF(unit_hrMn), UAMEASNAME_LIST_STANDARD, "\\u6642\\u9593\\u3001\\u5206", "\\u6642\\u9593\\u3001\\u5206", "\\u6642\\u9593\\u3001\\u5206" }, | |
321 | { unit_hrMn, UPRV_LENGTHOF(unit_hrMn), UAMEASNAME_LIST_MATCHUNITS, "\\u6642\\u9593 \\u5206", "\\u6642\\u9593 \\u5206", "\\u6642\\u9593\\u5206" }, | |
322 | { unit_mCm, UPRV_LENGTHOF(unit_mCm), UAMEASNAME_LIST_STANDARD, "\\u30E1\\u30FC\\u30C8\\u30EB\\u3001\\u30BB\\u30F3\\u30C1\\u30E1\\u30FC\\u30C8\\u30EB", "m\\u3001cm", "m\\u3001cm" }, | |
323 | { unit_mCm, UPRV_LENGTHOF(unit_mCm), UAMEASNAME_LIST_MATCHUNITS, "\\u30E1\\u30FC\\u30C8\\u30EB \\u30BB\\u30F3\\u30C1\\u30E1\\u30FC\\u30C8\\u30EB", "m cm", "mcm" }, | |
324 | { NULL, 0, (UAMeasureNameListStyle)0, NULL, NULL, NULL } | |
325 | }; | |
326 | ||
327 | static const LocaleWidthNumFmtItem lwnItems[] = { | |
328 | // ============= TIER 0,1 and subocales | |
329 | { "en", en_singFmt, en_singNam, en_multFmt, en_multNam }, // en: try plural cases for 1, other | |
330 | { "en_GB", en_GB_singFmt, en_GB_singNam, en_GB_multFmt, en_GB_multNam }, | |
331 | { "en_AU", NULL, NULL, NULL, NULL }, | |
332 | { "de", NULL, NULL, NULL, NULL }, // de: try plural cases for 1, other | |
333 | { "fr", fr_singFmt, NULL, NULL, NULL }, // fr: try plural cases for 1, other | |
334 | { "fr_CA", fr_CA_singFmt, NULL, NULL, NULL }, | |
335 | { "ja", NULL, NULL, NULL, ja_multNam }, // ja: try plural cases for other only | |
336 | { "zh_Hans", NULL, NULL, NULL, NULL }, // zh_Hans: try plural cases for other only | |
337 | ||
338 | // ============= TIER 2,3 and sublocales | |
339 | { "ar", NULL, NULL, NULL, NULL }, // ar: try plural cases for 0, 1, 2, 3, 11, 100 | |
340 | { "ca", NULL, NULL, NULL, NULL }, // ca: try plural cases for 1, other | |
341 | { "cs", cs_singFmt, NULL, NULL, NULL }, // cs: try plural cases for 1, 2, 8.5, 5 | |
342 | { "da", NULL, NULL, NULL, NULL }, // da: try plural cases for 1, other | |
343 | { "el", NULL, NULL, NULL, NULL }, // el: try plural cases for 1, other | |
344 | { "es", NULL, NULL, NULL, NULL }, // es: try plural cases for 1, other | |
345 | { "es_MX", NULL, NULL, NULL, NULL }, | |
346 | { "fi", NULL, NULL, NULL, NULL }, // fi: try plural cases for 1, other | |
347 | { "he", NULL, NULL, he_multFmt, NULL }, // he: try plural cases for 1, 2, 20, 3 | |
348 | { "hi", NULL, NULL, hi_multFmt, NULL }, // hi: try plural cases for 1 (covers 0.0-1.0), other | |
349 | { "hr", NULL, NULL, NULL, NULL }, // hr: try plural cases for 1, 2, 5 | |
350 | { "hu", NULL, NULL, NULL, NULL }, // hu: try plural cases for 1, other | |
351 | { "id", NULL, NULL, NULL, NULL }, // id: try plural cases for other only | |
1a147d09 | 352 | { "it", it_singFmt, NULL, NULL, NULL }, // it: try plural cases for 1, other |
2ca993e8 A |
353 | { "ko", NULL, NULL, NULL, NULL }, // ko: try plural cases for other only |
354 | { "ms", NULL, NULL, NULL, NULL }, // ms: try plural cases for other only | |
1a147d09 A |
355 | { "nb", nb_singFmt, NULL, NULL, NULL }, // nb: try plural cases for 1, other |
356 | { "nl", nl_singFmt, NULL, NULL, NULL }, // nl: try plural cases for 1, other | |
2ca993e8 A |
357 | { "pl", NULL, NULL, NULL, NULL }, // pl: try plural cases for 1, 2, 5, 8.5 |
358 | { "pt", NULL, NULL, NULL, NULL }, // pt: try plural cases for 1, other | |
359 | { "pt_PT", NULL, NULL, NULL, NULL }, | |
360 | { "ro", NULL, NULL, NULL, NULL }, // ro: try plural cases for 1, 2, 20 | |
361 | { "ru", NULL, NULL, NULL, NULL }, // ru: try plural cases for 1, 2, 5, 8.5 | |
362 | { "sk", NULL, NULL, NULL, NULL }, // sk: try plural cases for 1, 2, 8.5, 5 | |
363 | { "sv", NULL, NULL, NULL, NULL }, // sv: try plural cases for 1, other | |
364 | { "th", NULL, NULL, NULL, NULL }, // th: try plural cases for other only | |
365 | { "tr", NULL, NULL, NULL, NULL }, // tr: try plural cases for 1, other | |
366 | { "uk", NULL, NULL, NULL, NULL }, // uk: try plural cases for 1, 2, 5, 8.5 | |
367 | { "vi", NULL, NULL, NULL, NULL }, // vi: try plural cases for other only | |
c5116b9f | 368 | { "zh_Hant", zh_Hant_singFmt, NULL, NULL, NULL }, // zh_Hant: try plural cases for other only |
2ca993e8 A |
369 | { "zh_Hant_HK", NULL, NULL, NULL, NULL }, |
370 | ||
371 | // =============TERMINATOR | |
372 | { NULL, NULL, NULL, NULL, NULL } | |
373 | }; | |
374 | ||
375 | enum { kUBufMax = 96, kBBufMax = 192 }; | |
376 | ||
377 | ||
378 | static void TestUAMeasureFormat() | |
379 | { | |
380 | const LocaleWidthNumFmtItem * itemPtr; | |
381 | log_verbose("\nTesting uameasfmt functions\n"); | |
382 | for (itemPtr = lwnItems; itemPtr->locale != NULL; itemPtr++) { | |
383 | UChar uget[kUBufMax]; | |
384 | UChar uexp[kUBufMax]; | |
385 | char bget[kBBufMax]; | |
386 | char bexp[kBBufMax]; | |
387 | int32_t ugetLen, uexpLen; | |
388 | UErrorCode status = U_ZERO_ERROR; | |
389 | UNumberFormat* numfmt_0; | |
390 | UNumberFormat* numfmt_1; | |
391 | UNumberFormat* numfmt_2; | |
392 | UAMeasureFormat* measfmt_wide_2; | |
393 | UAMeasureFormat* measfmt_wide_0; | |
394 | UAMeasureFormat* measfmt_shrt_X; | |
395 | UAMeasureFormat* measfmt_shrt_1; | |
396 | UAMeasureFormat* measfmt_shrtr_1; | |
397 | UAMeasureFormat* measfmt_narr_0; | |
398 | UAMeasureFormat* measfmt_numr_0; | |
399 | ||
400 | numfmt_0 = unum_open(UNUM_DECIMAL, NULL, 0, itemPtr->locale, NULL, &status); | |
401 | if ( U_FAILURE(status) ) { | |
402 | log_data_err("FAIL: unum_open(UNUM_DECIMAL,...) fails for locale %s: %s\n", | |
403 | itemPtr->locale, u_errorName(status) ); | |
404 | continue; | |
405 | } | |
406 | numfmt_1 = unum_clone(numfmt_0, &status); | |
407 | numfmt_2 = unum_clone(numfmt_0, &status); | |
408 | if ( U_FAILURE(status) ) { | |
409 | log_err("FAIL: unum_clone fails for locale %s: %s\n", | |
410 | itemPtr->locale, u_errorName(status) ); | |
411 | unum_close(numfmt_0); | |
412 | continue; | |
413 | } | |
414 | unum_setAttribute(numfmt_0, UNUM_MIN_FRACTION_DIGITS, 0); | |
415 | unum_setAttribute(numfmt_0, UNUM_MAX_FRACTION_DIGITS, 0); | |
416 | unum_setAttribute(numfmt_0, UNUM_ROUNDING_MODE, UNUM_ROUND_DOWN); | |
417 | unum_setAttribute(numfmt_1, UNUM_MIN_FRACTION_DIGITS, 1); | |
418 | unum_setAttribute(numfmt_1, UNUM_MAX_FRACTION_DIGITS, 1); | |
419 | unum_setAttribute(numfmt_1, UNUM_ROUNDING_MODE, UNUM_ROUND_DOWN); | |
420 | unum_setAttribute(numfmt_2, UNUM_MIN_FRACTION_DIGITS, 2); | |
421 | unum_setAttribute(numfmt_2, UNUM_MAX_FRACTION_DIGITS, 2); | |
422 | unum_setAttribute(numfmt_2, UNUM_ROUNDING_MODE, UNUM_ROUND_DOWN); | |
423 | ||
424 | measfmt_wide_2 = uameasfmt_open(itemPtr->locale, UAMEASFMT_WIDTH_WIDE, unum_clone(numfmt_2, &status), &status); // wide, num fmt with 2 decimals | |
425 | measfmt_wide_0 = uameasfmt_open(itemPtr->locale, UAMEASFMT_WIDTH_WIDE, unum_clone(numfmt_0, &status), &status); // wide, num fmt with 0 decimals | |
426 | measfmt_shrt_X = uameasfmt_open(itemPtr->locale, UAMEASFMT_WIDTH_SHORT, NULL, &status); // short, default num fmt | |
427 | measfmt_shrt_1 = uameasfmt_open(itemPtr->locale, UAMEASFMT_WIDTH_SHORT, unum_clone(numfmt_1, &status), &status); // short, num fmt with 1 decimal | |
428 | measfmt_shrtr_1 = uameasfmt_open(itemPtr->locale, UAMEASFMT_WIDTH_SHORTER, unum_clone(numfmt_1, &status), &status); // shorter, num fmt with 1 decimal | |
429 | measfmt_narr_0 = uameasfmt_open(itemPtr->locale, UAMEASFMT_WIDTH_NARROW, unum_clone(numfmt_0, &status), &status); // narrow, num fmt with 0 decimal | |
430 | measfmt_numr_0 = uameasfmt_open(itemPtr->locale, UAMEASFMT_WIDTH_NUMERIC, unum_clone(numfmt_0, &status), &status); // numeric, num fmt with 0 decimal | |
431 | ||
432 | if ( U_FAILURE(status) ) { | |
433 | log_data_err("FAIL: uameasfmt_open fails for locale %s, various widths and number formatters: %s\n", | |
434 | itemPtr->locale, u_errorName(status) ); | |
435 | unum_close(numfmt_0); | |
436 | unum_close(numfmt_1); | |
437 | unum_close(numfmt_2); | |
438 | continue; | |
439 | } | |
440 | ||
441 | if (itemPtr->singleUnitFormatTests != NULL) { | |
442 | const SingleUnitFormat * singFmtPtr; | |
443 | for (singFmtPtr = itemPtr->singleUnitFormatTests; singFmtPtr->expectFmt_wide_2 != 0; singFmtPtr++) { | |
444 | UFieldPosition fpos = { UNUM_INTEGER_FIELD, 0, 0 }; | |
445 | // wide_2 | |
446 | status = U_ZERO_ERROR; | |
447 | ugetLen = uameasfmt_formatGetPosition(measfmt_wide_2, singFmtPtr->value, singFmtPtr->unit, uget, kUBufMax, NULL, &status); | |
448 | if ( U_FAILURE(status) ) { | |
449 | log_err("FAIL: uameasfmt_formatGetPosition locale %s, single format wide_2 for unit %d:%d, status %s\n", | |
450 | itemPtr->locale, ((int)singFmtPtr->unit) >> 8, ((int)singFmtPtr->unit) & 0xFF, u_errorName(status)); | |
451 | } else { | |
452 | uexpLen = u_unescape(singFmtPtr->expectFmt_wide_2, uexp, kUBufMax); | |
453 | if (ugetLen != uexpLen || u_strcmp(uget, uexp) != 0 ) { | |
454 | u_strToUTF8(bexp, kBBufMax, NULL, uexp, uexpLen, &status); | |
455 | u_strToUTF8(bget, kBBufMax, NULL, uget, ugetLen, &status); | |
456 | log_err("FAIL: uameasfmt_formatGetPosition locale %s, single format wide_2 for unit %d:%d, expected \"%s\", got \"%s\"\n", | |
457 | itemPtr->locale, ((int)singFmtPtr->unit) >> 8, ((int)singFmtPtr->unit) & 0xFF, bexp, bget); | |
458 | } | |
459 | } | |
460 | // wide_0 | |
461 | status = U_ZERO_ERROR; | |
462 | fpos.beginIndex = -1; | |
463 | fpos.endIndex = -1; | |
464 | ugetLen = uameasfmt_formatGetPosition(measfmt_wide_0, singFmtPtr->value, singFmtPtr->unit, uget, kUBufMax, &fpos, &status); | |
465 | if ( U_FAILURE(status) ) { | |
466 | log_err("FAIL: uameasfmt_formatGetPosition locale %s, single format wide_0 for unit %d:%d, status %s\n", | |
467 | itemPtr->locale, ((int)singFmtPtr->unit) >> 8, ((int)singFmtPtr->unit) & 0xFF, u_errorName(status)); | |
468 | } else { | |
469 | uexpLen = u_unescape(singFmtPtr->expectFmt_wide_0, uexp, kUBufMax); | |
470 | if (ugetLen != uexpLen || u_strcmp(uget, uexp) != 0 || fpos.beginIndex != singFmtPtr->beginInt_wide_0 || fpos.endIndex != singFmtPtr->endInt_wide_0) { | |
471 | u_strToUTF8(bexp, kBBufMax, NULL, uexp, uexpLen, &status); | |
472 | u_strToUTF8(bget, kBBufMax, NULL, uget, ugetLen, &status); | |
473 | log_err("FAIL: uameasfmt_formatGetPosition locale %s, single format wide_0 for unit %d:%d,\n expect \"%s\" int pos [%d:%d],\n get \"%s\" int pos [%d:%d]\n", | |
474 | itemPtr->locale, ((int)singFmtPtr->unit) >> 8, ((int)singFmtPtr->unit) & 0xFF, | |
475 | bexp, singFmtPtr->beginInt_wide_0, singFmtPtr->endInt_wide_0, | |
476 | bget, fpos.beginIndex, fpos.endIndex); | |
477 | } | |
478 | } | |
479 | // shrt_X | |
480 | status = U_ZERO_ERROR; | |
481 | ugetLen = uameasfmt_formatGetPosition(measfmt_shrt_X, singFmtPtr->value, singFmtPtr->unit, uget, kUBufMax, NULL, &status); | |
482 | if ( U_FAILURE(status) ) { | |
483 | log_err("FAIL: uameasfmt_formatGetPosition locale %s, single format shrt_X for unit %d:%d, status %s\n", | |
484 | itemPtr->locale, ((int)singFmtPtr->unit) >> 8, ((int)singFmtPtr->unit) & 0xFF, u_errorName(status)); | |
485 | } else { | |
486 | uexpLen = u_unescape(singFmtPtr->expectFmt_shrt_X, uexp, kUBufMax); | |
487 | if (ugetLen != uexpLen || u_strcmp(uget, uexp) != 0 ) { | |
488 | u_strToUTF8(bexp, kBBufMax, NULL, uexp, uexpLen, &status); | |
489 | u_strToUTF8(bget, kBBufMax, NULL, uget, ugetLen, &status); | |
490 | log_err("FAIL: uameasfmt_formatGetPosition locale %s, single format shrt_X for unit %d:%d, expected \"%s\", got \"%s\"\n", | |
491 | itemPtr->locale, ((int)singFmtPtr->unit) >> 8, ((int)singFmtPtr->unit) & 0xFF, bexp, bget); | |
492 | } | |
493 | } | |
494 | // shrt_1 | |
495 | status = U_ZERO_ERROR; | |
496 | ugetLen = uameasfmt_formatGetPosition(measfmt_shrt_1, singFmtPtr->value, singFmtPtr->unit, uget, kUBufMax, NULL, &status); | |
497 | if ( U_FAILURE(status) ) { | |
498 | log_err("FAIL: uameasfmt_formatGetPosition locale %s, single format shrt_1 for unit %d:%d, status %s\n", | |
499 | itemPtr->locale, ((int)singFmtPtr->unit) >> 8, ((int)singFmtPtr->unit) & 0xFF, u_errorName(status)); | |
500 | } else { | |
501 | uexpLen = u_unescape(singFmtPtr->expectFmt_shrt_1, uexp, kUBufMax); | |
502 | if (ugetLen != uexpLen || u_strcmp(uget, uexp) != 0 ) { | |
503 | u_strToUTF8(bexp, kBBufMax, NULL, uexp, uexpLen, &status); | |
504 | u_strToUTF8(bget, kBBufMax, NULL, uget, ugetLen, &status); | |
505 | log_err("FAIL: uameasfmt_formatGetPosition locale %s, single format shrt_1 for unit %d:%d, expected \"%s\", got \"%s\"\n", | |
506 | itemPtr->locale, ((int)singFmtPtr->unit) >> 8, ((int)singFmtPtr->unit) & 0xFF, bexp, bget); | |
507 | } | |
508 | } | |
509 | // narr_0 | |
510 | status = U_ZERO_ERROR; | |
511 | ugetLen = uameasfmt_formatGetPosition(measfmt_narr_0, singFmtPtr->value, singFmtPtr->unit, uget, kUBufMax, NULL, &status); | |
512 | if ( U_FAILURE(status) ) { | |
513 | log_err("FAIL: uameasfmt_formatGetPosition locale %s, single format narr_0 for unit %d:%d, status %s\n", | |
514 | itemPtr->locale, ((int)singFmtPtr->unit) >> 8, ((int)singFmtPtr->unit) & 0xFF, u_errorName(status)); | |
515 | } else { | |
516 | uexpLen = u_unescape(singFmtPtr->expectFmt_narr_0, uexp, kUBufMax); | |
517 | if (ugetLen != uexpLen || u_strcmp(uget, uexp) != 0 ) { | |
518 | u_strToUTF8(bexp, kBBufMax, NULL, uexp, uexpLen, &status); | |
519 | u_strToUTF8(bget, kBBufMax, NULL, uget, ugetLen, &status); | |
520 | log_err("FAIL: uameasfmt_formatGetPosition locale %s, single format narr_0 for unit %d:%d, expected \"%s\", got \"%s\"\n", | |
521 | itemPtr->locale, ((int)singFmtPtr->unit) >> 8, ((int)singFmtPtr->unit) & 0xFF, bexp, bget); | |
522 | } | |
523 | } | |
524 | // numr_0 | |
525 | status = U_ZERO_ERROR; | |
526 | fpos.beginIndex = -1; | |
527 | fpos.endIndex = -1; | |
528 | ugetLen = uameasfmt_formatGetPosition(measfmt_numr_0, singFmtPtr->value, singFmtPtr->unit, uget, kUBufMax, &fpos, &status); | |
529 | if ( U_FAILURE(status) ) { | |
530 | log_err("FAIL: uameasfmt_formatGetPosition locale %s, single format numr_0 for unit %d:%d, status %s\n", | |
531 | itemPtr->locale, ((int)singFmtPtr->unit) >> 8, ((int)singFmtPtr->unit) & 0xFF, u_errorName(status)); | |
532 | } else { | |
533 | uexpLen = u_unescape(singFmtPtr->expectFmt_numr_0, uexp, kUBufMax); | |
534 | if (ugetLen != uexpLen || u_strcmp(uget, uexp) != 0 || fpos.beginIndex != singFmtPtr->beginInt_numr_0 || fpos.endIndex != singFmtPtr->endInt_numr_0) { | |
535 | u_strToUTF8(bexp, kBBufMax, NULL, uexp, uexpLen, &status); | |
536 | u_strToUTF8(bget, kBBufMax, NULL, uget, ugetLen, &status); | |
537 | log_err("FAIL: uameasfmt_formatGetPosition locale %s, single format numr_0 for unit %d:%d,\n expect \"%s\" int pos [%d:%d],\n get \"%s\" int pos [%d:%d]\n", | |
538 | itemPtr->locale, ((int)singFmtPtr->unit) >> 8, ((int)singFmtPtr->unit) & 0xFF, | |
539 | bexp, singFmtPtr->beginInt_numr_0, singFmtPtr->endInt_numr_0, | |
540 | bget, fpos.beginIndex, fpos.endIndex); | |
541 | } | |
542 | } | |
543 | } | |
544 | } | |
545 | ||
546 | if (itemPtr->singleUnitNameTests != NULL) { | |
547 | const SingleUnitName * singNamPtr; | |
548 | for (singNamPtr = itemPtr->singleUnitNameTests; singNamPtr->expectName_wide != 0; singNamPtr++) { | |
549 | // wide | |
550 | status = U_ZERO_ERROR; | |
551 | ugetLen = uameasfmt_getUnitName(measfmt_wide_2, singNamPtr->unit, uget, kUBufMax, &status); | |
552 | if ( U_FAILURE(status) ) { | |
553 | log_err("FAIL: uameasfmt_getUnitName locale %s, single name wide for unit %d:%d, status %s\n", | |
554 | itemPtr->locale, ((int)singNamPtr->unit) >> 8, ((int)singNamPtr->unit) & 0xFF, u_errorName(status)); | |
555 | } else { | |
556 | uexpLen = u_unescape(singNamPtr->expectName_wide, uexp, kUBufMax); | |
557 | if (ugetLen != uexpLen || u_strcmp(uget, uexp) != 0 ) { | |
558 | u_strToUTF8(bexp, kBBufMax, NULL, uexp, uexpLen, &status); | |
559 | u_strToUTF8(bget, kBBufMax, NULL, uget, ugetLen, &status); | |
560 | log_err("FAIL: uameasfmt_getUnitName locale %s, single name wide for unit %d:%d, expected \"%s\", got \"%s\"\n", | |
561 | itemPtr->locale, ((int)singNamPtr->unit) >> 8, ((int)singNamPtr->unit) & 0xFF, bexp, bget); | |
562 | } | |
563 | } | |
564 | // shrt | |
565 | status = U_ZERO_ERROR; | |
566 | ugetLen = uameasfmt_getUnitName(measfmt_shrt_X, singNamPtr->unit, uget, kUBufMax, &status); | |
567 | if ( U_FAILURE(status) ) { | |
568 | log_err("FAIL: uameasfmt_getUnitName locale %s, single name shrt for unit %d:%d, status %s\n", | |
569 | itemPtr->locale, ((int)singNamPtr->unit) >> 8, ((int)singNamPtr->unit) & 0xFF, u_errorName(status)); | |
570 | } else { | |
571 | uexpLen = u_unescape(singNamPtr->expectName_shrt, uexp, kUBufMax); | |
572 | if (ugetLen != uexpLen || u_strcmp(uget, uexp) != 0 ) { | |
573 | u_strToUTF8(bexp, kBBufMax, NULL, uexp, uexpLen, &status); | |
574 | u_strToUTF8(bget, kBBufMax, NULL, uget, ugetLen, &status); | |
575 | log_err("FAIL: uameasfmt_getUnitName locale %s, single name shrt for unit %d:%d, expected \"%s\", got \"%s\"\n", | |
576 | itemPtr->locale, ((int)singNamPtr->unit) >> 8, ((int)singNamPtr->unit) & 0xFF, bexp, bget); | |
577 | } | |
578 | } | |
579 | // narr | |
580 | status = U_ZERO_ERROR; | |
581 | ugetLen = uameasfmt_getUnitName(measfmt_narr_0, singNamPtr->unit, uget, kUBufMax, &status); | |
582 | if ( U_FAILURE(status) ) { | |
583 | log_err("FAIL: uameasfmt_getUnitName locale %s, single name narr for unit %d:%d, status %s\n", | |
584 | itemPtr->locale, ((int)singNamPtr->unit) >> 8, ((int)singNamPtr->unit) & 0xFF, u_errorName(status)); | |
585 | } else { | |
586 | uexpLen = u_unescape(singNamPtr->expectName_narr, uexp, kUBufMax); | |
587 | if (ugetLen != uexpLen || u_strcmp(uget, uexp) != 0 ) { | |
588 | u_strToUTF8(bexp, kBBufMax, NULL, uexp, uexpLen, &status); | |
589 | u_strToUTF8(bget, kBBufMax, NULL, uget, ugetLen, &status); | |
590 | log_err("FAIL: uameasfmt_getUnitName locale %s, single name narr for unit %d:%d, expected \"%s\", got \"%s\"\n", | |
591 | itemPtr->locale, ((int)singNamPtr->unit) >> 8, ((int)singNamPtr->unit) & 0xFF, bexp, bget); | |
592 | } | |
593 | } | |
594 | } | |
595 | } | |
596 | ||
597 | if (itemPtr->multipleUnitFormatTests != NULL) { | |
598 | status = U_ZERO_ERROR; | |
599 | UFieldPositionIterator* fpositer = ufieldpositer_open(&status); | |
600 | if ( U_FAILURE(status) ) { | |
601 | log_err("FAIL: ufieldpositer_open, status %s\n", u_errorName(status)); | |
602 | } else { | |
603 | const MultipleUnitFormat * multFmtPtr; | |
604 | for (multFmtPtr = itemPtr->multipleUnitFormatTests; multFmtPtr->measures != 0; multFmtPtr++) { | |
605 | // wide_2 | |
606 | status = U_ZERO_ERROR; | |
607 | ugetLen = uameasfmt_formatMultipleForFields(measfmt_wide_2, multFmtPtr->measures, multFmtPtr->measureCount, uget, kUBufMax, fpositer, &status); | |
608 | if ( U_FAILURE(status) ) { | |
609 | log_err("FAIL: uameasfmt_formatMultipleForFields locale %s, multiple format wide_2 for measureCount %d, status %s\n", | |
610 | itemPtr->locale, multFmtPtr->measureCount, u_errorName(status)); | |
611 | } else { | |
612 | uexpLen = u_unescape(multFmtPtr->expectFmt_wide_2, uexp, kUBufMax); | |
613 | if (ugetLen != uexpLen || u_strcmp(uget, uexp) != 0 ) { | |
614 | u_strToUTF8(bexp, kBBufMax, NULL, uexp, uexpLen, &status); | |
615 | u_strToUTF8(bget, kBBufMax, NULL, uget, ugetLen, &status); | |
616 | log_err("FAIL: uameasfmt_formatMultipleForFields locale %s, multiple format wide_2 for measureCount %d, expected \"%s\", got \"%s\"\n", | |
617 | itemPtr->locale, multFmtPtr->measureCount, bexp, bget); | |
618 | } else { | |
619 | // check fpositer | |
620 | int32_t field, beginIndex, endIndex, count; | |
621 | for (count = 0; (field = ufieldpositer_next(fpositer, &beginIndex, &endIndex)) >= 0; count++) { | |
622 | if (field != multFmtPtr->ranges_wide_2[count][0] || beginIndex != multFmtPtr->ranges_wide_2[count][1] || endIndex != multFmtPtr->ranges_wide_2[count][2]) { | |
623 | log_err("FAIL: uameasfmt_formatMultipleForFields locale %s, multiple format wide_2 for measureCount %d,\n expect field %0X range %d..%d,\n get field %0X range %d..%d\n", | |
624 | itemPtr->locale, multFmtPtr->measureCount, | |
625 | multFmtPtr->ranges_wide_2[count][0], multFmtPtr->ranges_wide_2[count][1], multFmtPtr->ranges_wide_2[count][2], | |
626 | field, beginIndex, endIndex); | |
627 | break; | |
628 | } | |
629 | } | |
630 | } | |
631 | } | |
632 | // wide_0 | |
633 | status = U_ZERO_ERROR; | |
634 | ugetLen = uameasfmt_formatMultipleForFields(measfmt_wide_0, multFmtPtr->measures, multFmtPtr->measureCount, uget, kUBufMax, NULL, &status); | |
635 | if ( U_FAILURE(status) ) { | |
636 | log_err("FAIL: uameasfmt_formatMultipleForFields locale %s, multiple format wide_0 for measureCount %d, status %s\n", | |
637 | itemPtr->locale, multFmtPtr->measureCount, u_errorName(status)); | |
638 | } else { | |
639 | uexpLen = u_unescape(multFmtPtr->expectFmt_wide_0, uexp, kUBufMax); | |
640 | if (ugetLen != uexpLen || u_strcmp(uget, uexp) != 0 ) { | |
641 | u_strToUTF8(bexp, kBBufMax, NULL, uexp, uexpLen, &status); | |
642 | u_strToUTF8(bget, kBBufMax, NULL, uget, ugetLen, &status); | |
643 | log_err("FAIL: uameasfmt_formatMultipleForFields locale %s, multiple format wide_0 for measureCount %d, expected \"%s\", got \"%s\"\n", | |
644 | itemPtr->locale, multFmtPtr->measureCount, bexp, bget); | |
645 | } | |
646 | } | |
647 | // shrt_X | |
648 | status = U_ZERO_ERROR; | |
649 | ugetLen = uameasfmt_formatMultipleForFields(measfmt_shrt_X, multFmtPtr->measures, multFmtPtr->measureCount, uget, kUBufMax, NULL, &status); | |
650 | if ( U_FAILURE(status) ) { | |
651 | log_err("FAIL: uameasfmt_formatMultipleForFields locale %s, multiple format shrt_X for measureCount %d, status %s\n", | |
652 | itemPtr->locale, multFmtPtr->measureCount, u_errorName(status)); | |
653 | } else { | |
654 | uexpLen = u_unescape(multFmtPtr->expectFmt_shrt_X, uexp, kUBufMax); | |
655 | if (ugetLen != uexpLen || u_strcmp(uget, uexp) != 0 ) { | |
656 | u_strToUTF8(bexp, kBBufMax, NULL, uexp, uexpLen, &status); | |
657 | u_strToUTF8(bget, kBBufMax, NULL, uget, ugetLen, &status); | |
658 | log_err("FAIL: uameasfmt_formatMultipleForFields locale %s, multiple format shrt_X for measureCount %d, expected \"%s\", got \"%s\"\n", | |
659 | itemPtr->locale, multFmtPtr->measureCount, bexp, bget); | |
660 | } | |
661 | } | |
662 | // shrt_1 | |
663 | status = U_ZERO_ERROR; | |
664 | ugetLen = uameasfmt_formatMultipleForFields(measfmt_shrt_1, multFmtPtr->measures, multFmtPtr->measureCount, uget, kUBufMax, NULL, &status); | |
665 | if ( U_FAILURE(status) ) { | |
666 | log_err("FAIL: uameasfmt_formatMultipleForFields locale %s, multiple format shrt_1 for measureCount %d, status %s\n", | |
667 | itemPtr->locale, multFmtPtr->measureCount, u_errorName(status)); | |
668 | } else { | |
669 | uexpLen = u_unescape(multFmtPtr->expectFmt_shrt_1, uexp, kUBufMax); | |
670 | if (ugetLen != uexpLen || u_strcmp(uget, uexp) != 0 ) { | |
671 | u_strToUTF8(bexp, kBBufMax, NULL, uexp, uexpLen, &status); | |
672 | u_strToUTF8(bget, kBBufMax, NULL, uget, ugetLen, &status); | |
673 | log_err("FAIL: uameasfmt_formatMultipleForFields locale %s, multiple format shrt_1 for measureCount %d, expected \"%s\", got \"%s\"\n", | |
674 | itemPtr->locale, multFmtPtr->measureCount, bexp, bget); | |
675 | } | |
676 | } | |
677 | // shrtr_1 | |
678 | status = U_ZERO_ERROR; | |
679 | ugetLen = uameasfmt_formatMultipleForFields(measfmt_shrtr_1, multFmtPtr->measures, multFmtPtr->measureCount, uget, kUBufMax, fpositer, &status); | |
680 | if ( U_FAILURE(status) ) { | |
681 | log_err("FAIL: uameasfmt_formatMultipleForFields locale %s, multiple format shrtr_1 for measureCount %d, status %s\n", | |
682 | itemPtr->locale, multFmtPtr->measureCount, u_errorName(status)); | |
683 | } else { | |
684 | uexpLen = u_unescape(multFmtPtr->expectFmt_shrtr_1, uexp, kUBufMax); | |
685 | if (ugetLen != uexpLen || u_strcmp(uget, uexp) != 0 ) { | |
686 | u_strToUTF8(bexp, kBBufMax, NULL, uexp, uexpLen, &status); | |
687 | u_strToUTF8(bget, kBBufMax, NULL, uget, ugetLen, &status); | |
688 | log_err("FAIL: uameasfmt_formatMultipleForFields locale %s, multiple format shrtr_1 for measureCount %d, expected \"%s\", got \"%s\"\n", | |
689 | itemPtr->locale, multFmtPtr->measureCount, bexp, bget); | |
690 | } else { | |
691 | // check fpositer | |
692 | int32_t field, beginIndex, endIndex, count; | |
693 | for (count = 0; (field = ufieldpositer_next(fpositer, &beginIndex, &endIndex)) >= 0; count++) { | |
694 | if (field != multFmtPtr->ranges_shrtr_1[count][0] || beginIndex != multFmtPtr->ranges_shrtr_1[count][1] || endIndex != multFmtPtr->ranges_shrtr_1[count][2]) { | |
695 | log_err("FAIL: uameasfmt_formatMultipleForFields locale %s, multiple format shrtr_1 for measureCount %d,\n expect field %0X range %d..%d,\n get field %0X range %d..%d\n", | |
696 | itemPtr->locale, multFmtPtr->measureCount, | |
697 | multFmtPtr->ranges_shrtr_1[count][0], multFmtPtr->ranges_shrtr_1[count][1], multFmtPtr->ranges_shrtr_1[count][2], | |
698 | field, beginIndex, endIndex); | |
699 | break; | |
700 | } | |
701 | } | |
702 | } | |
703 | } | |
704 | // narr_0 | |
705 | status = U_ZERO_ERROR; | |
706 | ugetLen = uameasfmt_formatMultipleForFields(measfmt_narr_0, multFmtPtr->measures, multFmtPtr->measureCount, uget, kUBufMax, NULL, &status); | |
707 | if ( U_FAILURE(status) ) { | |
708 | log_err("FAIL: uameasfmt_formatMultipleForFields locale %s, multiple format narr_0 for measureCount %d, status %s\n", | |
709 | itemPtr->locale, multFmtPtr->measureCount, u_errorName(status)); | |
710 | } else { | |
711 | uexpLen = u_unescape(multFmtPtr->expectFmt_narr_0, uexp, kUBufMax); | |
712 | if (ugetLen != uexpLen || u_strcmp(uget, uexp) != 0 ) { | |
713 | u_strToUTF8(bexp, kBBufMax, NULL, uexp, uexpLen, &status); | |
714 | u_strToUTF8(bget, kBBufMax, NULL, uget, ugetLen, &status); | |
715 | log_err("FAIL: uameasfmt_formatMultipleForFields locale %s, multiple format narr_0 for measureCount %d, expected \"%s\", got \"%s\"\n", | |
716 | itemPtr->locale, multFmtPtr->measureCount, bexp, bget); | |
717 | } | |
718 | } | |
719 | // numr_0 | |
720 | status = U_ZERO_ERROR; | |
721 | ugetLen = uameasfmt_formatMultipleForFields(measfmt_numr_0, multFmtPtr->measures, multFmtPtr->measureCount, uget, kUBufMax, fpositer, &status); | |
722 | if ( U_FAILURE(status) ) { | |
723 | log_err("FAIL: uameasfmt_formatMultipleForFields locale %s, multiple format numr_0 for measureCount %d, status %s\n", | |
724 | itemPtr->locale, multFmtPtr->measureCount, u_errorName(status)); | |
725 | } else { | |
726 | uexpLen = u_unescape(multFmtPtr->expectFmt_numr_0, uexp, kUBufMax); | |
727 | if (ugetLen != uexpLen || u_strcmp(uget, uexp) != 0 ) { | |
728 | u_strToUTF8(bexp, kBBufMax, NULL, uexp, uexpLen, &status); | |
729 | u_strToUTF8(bget, kBBufMax, NULL, uget, ugetLen, &status); | |
730 | log_err("FAIL: uameasfmt_formatMultipleForFields locale %s, multiple format numr_0 for measureCount %d, expected \"%s\", got \"%s\"\n", | |
731 | itemPtr->locale, multFmtPtr->measureCount, bexp, bget); | |
732 | } else { | |
733 | // check fpositer | |
734 | int32_t field, beginIndex, endIndex, count; | |
735 | for (count = 0; (field = ufieldpositer_next(fpositer, &beginIndex, &endIndex)) >= 0; count++) { | |
736 | if (field != multFmtPtr->ranges_numr_0[count][0] || beginIndex != multFmtPtr->ranges_numr_0[count][1] || endIndex != multFmtPtr->ranges_numr_0[count][2]) { | |
737 | log_err("FAIL: uameasfmt_formatMultipleForFields locale %s, multiple format numr_0 for measureCount %d,\n expect field %0X range %d..%d,\n get field %0X range %d..%d\n", | |
738 | itemPtr->locale, multFmtPtr->measureCount, | |
739 | multFmtPtr->ranges_numr_0[count][0], multFmtPtr->ranges_numr_0[count][1], multFmtPtr->ranges_numr_0[count][2], | |
740 | field, beginIndex, endIndex); | |
741 | break; | |
742 | } | |
743 | } | |
744 | } | |
745 | } | |
746 | } | |
747 | ufieldpositer_close(fpositer); | |
748 | } | |
749 | } | |
750 | ||
751 | if (itemPtr->multipleUnitNameTests != NULL) { | |
752 | const MultipleUnitName * multNamPtr; | |
753 | for (multNamPtr = itemPtr->multipleUnitNameTests; multNamPtr->units != 0; multNamPtr++) { | |
754 | // wide | |
755 | status = U_ZERO_ERROR; | |
756 | ugetLen = uameasfmt_getMultipleUnitNames(measfmt_wide_2, multNamPtr->units, multNamPtr->unitCount, multNamPtr->listStyle, uget, kUBufMax, &status); | |
757 | if ( U_FAILURE(status) ) { | |
758 | log_err("FAIL: uameasfmt_getMultipleUnitNames locale %s, multiple name wide for unitCount %d, listStyle %d, status %s\n", | |
759 | itemPtr->locale, multNamPtr->unitCount, multNamPtr->listStyle, u_errorName(status)); | |
760 | } else { | |
761 | uexpLen = u_unescape(multNamPtr->expectName_wide, uexp, kUBufMax); | |
762 | if (ugetLen != uexpLen || u_strcmp(uget, uexp) != 0 ) { | |
763 | u_strToUTF8(bexp, kBBufMax, NULL, uexp, uexpLen, &status); | |
764 | u_strToUTF8(bget, kBBufMax, NULL, uget, ugetLen, &status); | |
765 | log_err("FAIL: uameasfmt_getMultipleUnitNames locale %s, multiple name wide for unitCount %d, listStyle %d, expected \"%s\", got \"%s\"\n", | |
766 | itemPtr->locale, multNamPtr->unitCount, multNamPtr->listStyle, bexp, bget); | |
767 | } | |
768 | } | |
769 | // shrt | |
770 | status = U_ZERO_ERROR; | |
771 | ugetLen = uameasfmt_getMultipleUnitNames(measfmt_shrt_X, multNamPtr->units, multNamPtr->unitCount, multNamPtr->listStyle, uget, kUBufMax, &status); | |
772 | if ( U_FAILURE(status) ) { | |
773 | log_err("FAIL: uameasfmt_getMultipleUnitNames locale %s, multiple name shrt for unitCount %d, listStyle %d, status %s\n", | |
774 | itemPtr->locale, multNamPtr->unitCount, multNamPtr->listStyle, u_errorName(status)); | |
775 | } else { | |
776 | uexpLen = u_unescape(multNamPtr->expectName_shrt, uexp, kUBufMax); | |
777 | if (ugetLen != uexpLen || u_strcmp(uget, uexp) != 0 ) { | |
778 | u_strToUTF8(bexp, kBBufMax, NULL, uexp, uexpLen, &status); | |
779 | u_strToUTF8(bget, kBBufMax, NULL, uget, ugetLen, &status); | |
780 | log_err("FAIL: uameasfmt_getMultipleUnitNames locale %s, multiple name shrt for unitCount %d, listStyle %d, expected \"%s\", got \"%s\"\n", | |
781 | itemPtr->locale, multNamPtr->unitCount, multNamPtr->listStyle, bexp, bget); | |
782 | } | |
783 | } | |
784 | // narr | |
785 | status = U_ZERO_ERROR; | |
786 | ugetLen = uameasfmt_getMultipleUnitNames(measfmt_narr_0, multNamPtr->units, multNamPtr->unitCount, multNamPtr->listStyle, uget, kUBufMax, &status); | |
787 | if ( U_FAILURE(status) ) { | |
788 | log_err("FAIL: uameasfmt_getMultipleUnitNames locale %s, multiple name narr for unitCount %d, listStyle %d, status %s\n", | |
789 | itemPtr->locale, multNamPtr->unitCount, multNamPtr->listStyle, u_errorName(status)); | |
790 | } else { | |
791 | uexpLen = u_unescape(multNamPtr->expectName_narr, uexp, kUBufMax); | |
792 | if (ugetLen != uexpLen || u_strcmp(uget, uexp) != 0 ) { | |
793 | u_strToUTF8(bexp, kBBufMax, NULL, uexp, uexpLen, &status); | |
794 | u_strToUTF8(bget, kBBufMax, NULL, uget, ugetLen, &status); | |
795 | log_err("FAIL: uameasfmt_getMultipleUnitNames locale %s, multiple name narr for unitCount %d, listStyle %d, expected \"%s\", got \"%s\"\n", | |
796 | itemPtr->locale, multNamPtr->unitCount, multNamPtr->listStyle, bexp, bget); | |
797 | } | |
798 | } | |
799 | } | |
800 | } | |
801 | ||
802 | uameasfmt_close(measfmt_wide_2); | |
803 | uameasfmt_close(measfmt_wide_0); | |
804 | uameasfmt_close(measfmt_shrt_X); | |
805 | uameasfmt_close(measfmt_shrt_1); | |
806 | uameasfmt_close(measfmt_shrtr_1); | |
807 | uameasfmt_close(measfmt_narr_0); | |
808 | uameasfmt_close(measfmt_numr_0); | |
809 | ||
810 | unum_close(numfmt_0); | |
811 | unum_close(numfmt_1); | |
812 | unum_close(numfmt_2); | |
813 | } | |
814 | /* sleep to check leaks etc */ | |
f3c0d7a5 | 815 | #if U_PLATFORM_IS_DARWIN_BASED || U_PLATFORM_IS_LINUX_BASED || U_PLATFORM == U_PF_BSD || U_PLATFORM == U_PF_SOLARIS |
2ca993e8 | 816 | sleep(8); |
f3c0d7a5 | 817 | #endif |
2ca993e8 A |
818 | } |
819 | ||
a62d09fc A |
820 | static void TestUAMeasFmtOpenAllLocs() |
821 | { | |
822 | int32_t iLoc, nLoc = uloc_countAvailable(); | |
823 | for (iLoc = 0; iLoc <= nLoc; iLoc++) { | |
824 | const char *loc = (iLoc < nLoc)? uloc_getAvailable(iLoc): "xyz" /* something bogus */; | |
825 | if (loc != NULL) { | |
826 | UAMeasureFormat* measfmt; | |
827 | UErrorCode status; | |
828 | ||
829 | status = U_ZERO_ERROR; | |
830 | measfmt = uameasfmt_open(loc, UAMEASFMT_WIDTH_WIDE, NULL, &status); | |
831 | if ( U_SUCCESS(status) ) { | |
832 | uameasfmt_close(measfmt); | |
833 | } else { | |
834 | log_data_err("FAIL: uameasfmt_open fails for locale %-10s, width WIDE : %s\n", loc, u_errorName(status) ); | |
835 | } | |
836 | ||
837 | status = U_ZERO_ERROR; | |
838 | measfmt = uameasfmt_open(loc, UAMEASFMT_WIDTH_SHORT, NULL, &status); | |
839 | if ( U_SUCCESS(status) ) { | |
840 | uameasfmt_close(measfmt); | |
841 | } else { | |
842 | log_data_err("FAIL: uameasfmt_open fails for locale %-10s, width SHORT : %s\n", loc, u_errorName(status) ); | |
843 | } | |
844 | ||
845 | status = U_ZERO_ERROR; | |
846 | measfmt = uameasfmt_open(loc, UAMEASFMT_WIDTH_NARROW, NULL, &status); | |
847 | if ( U_SUCCESS(status) ) { | |
848 | uameasfmt_close(measfmt); | |
849 | } else { | |
850 | log_data_err("FAIL: uameasfmt_open fails for locale %-10s, width NARROW : %s\n", loc, u_errorName(status) ); | |
851 | } | |
852 | ||
853 | ||
854 | status = U_ZERO_ERROR; | |
855 | measfmt = uameasfmt_open(loc, UAMEASFMT_WIDTH_NUMERIC, NULL, &status); | |
856 | if ( U_SUCCESS(status) ) { | |
857 | uameasfmt_close(measfmt); | |
858 | } else { | |
859 | log_data_err("FAIL: uameasfmt_open fails for locale %-10s, width NUMERIC: %s\n", loc, u_errorName(status) ); | |
860 | } | |
861 | } | |
862 | } | |
863 | } | |
864 | ||
2ca993e8 A |
865 | enum { kMeasureUnitMax = 3 }; |
866 | ||
867 | typedef struct { | |
868 | const char* locale; | |
869 | const char* category; | |
870 | const char* usage; | |
871 | int32_t unitCount; | |
872 | UAMeasureUnit units[kMeasureUnitMax]; | |
873 | } UnitsForUsageItem; | |
874 | ||
875 | static const UnitsForUsageItem unitsForUsageItems[] = { | |
876 | { "en_US", "length", "person", 1, { UAMEASUNIT_LENGTH_INCH } }, | |
877 | { "en_US", "length", "person-informal", 2, { UAMEASUNIT_LENGTH_FOOT, UAMEASUNIT_LENGTH_INCH } }, | |
878 | { "en_US", "length", "person-small", 1, { UAMEASUNIT_LENGTH_INCH } }, | |
879 | { "fr_FR", "length", "person", 2, { UAMEASUNIT_LENGTH_METER, UAMEASUNIT_LENGTH_CENTIMETER } }, | |
880 | { "fr_FR", "length", "person-informal", 2, { UAMEASUNIT_LENGTH_METER, UAMEASUNIT_LENGTH_CENTIMETER } }, | |
881 | { "fr_FR", "length", "person-small", 1, { UAMEASUNIT_LENGTH_CENTIMETER } }, | |
882 | { "fr_FR@rg=USZZZZ", "length", "person", 1, { UAMEASUNIT_LENGTH_INCH } }, | |
883 | { "fr_FR@rg=USZZZZ", "length", "person-informal", 2, { UAMEASUNIT_LENGTH_FOOT, UAMEASUNIT_LENGTH_INCH } }, | |
884 | { "fr_FR@rg=USZZZZ", "length", "person-small", 1, { UAMEASUNIT_LENGTH_INCH } }, | |
f3c0d7a5 | 885 | { "en_IN", "pressure","baromtrc", 1, { UAMEASUNIT_PRESSURE_HECTOPASCAL } }, |
2ca993e8 A |
886 | { "es_MX", "pressure","baromtrc", 1, { UAMEASUNIT_PRESSURE_MILLIMETER_OF_MERCURY } }, |
887 | { "fr_FR", "pressure","baromtrc", 1, { UAMEASUNIT_PRESSURE_HECTOPASCAL } }, | |
888 | { "pt"/*BR*/, "pressure","baromtrc", 1, { UAMEASUNIT_PRESSURE_MILLIBAR } }, | |
889 | { "en_US", "length", NULL, 1, { UAMEASUNIT_LENGTH_FOOT } }, | |
890 | { "en_US", "length", "large", 1, { UAMEASUNIT_LENGTH_MILE } }, | |
891 | { "en_US", "length", "small", 1, { UAMEASUNIT_LENGTH_INCH } }, | |
892 | { "fr_FR", "length", NULL, 1, { UAMEASUNIT_LENGTH_METER } }, | |
893 | { "fr_FR", "length", "large", 1, { UAMEASUNIT_LENGTH_KILOMETER } }, | |
894 | { "fr_FR", "length", "small", 1, { UAMEASUNIT_LENGTH_CENTIMETER } }, | |
895 | { "en_US", "xxxxxxxx","yyyyyyyy", 0, { (UAMeasureUnit)0 } }, | |
f3c0d7a5 A |
896 | // tests for ms= |
897 | { "en_US@ms=metric", "length", "large", 1, { UAMEASUNIT_LENGTH_KILOMETER } }, | |
898 | { "fr_FR@ms=ussystem", "length", "large", 1, { UAMEASUNIT_LENGTH_MILE } }, | |
899 | { "en_GB@ms=metric", "concentr", "blood-glucose", 1, { UAMEASUNIT_CONCENTRATION_MILLIMOLE_PER_LITER } }, | |
900 | { "en_US@ms=uksystem", "mass", "person", 2, { UAMEASUNIT_MASS_STONE, UAMEASUNIT_MASS_POUND } }, | |
901 | { "fr_FR", "mass", "person", 1, { UAMEASUNIT_MASS_KILOGRAM } }, | |
902 | { "fr_FR@rg=USZZZZ", "mass", "person", 1, { UAMEASUNIT_MASS_POUND } }, | |
903 | { "fr_FR@ms=uksystem;rg=USZZZZ", "mass", "person", 2, { UAMEASUNIT_MASS_STONE, UAMEASUNIT_MASS_POUND } }, | |
904 | // terminator | |
905 | { NULL, NULL, NULL, 0, { (UAMeasureUnit)0 } } | |
2ca993e8 A |
906 | }; |
907 | ||
908 | static void TestUAGetUnitsForUsage() | |
909 | { | |
910 | const UnitsForUsageItem* itemPtr = unitsForUsageItems; | |
911 | for (; itemPtr->locale != NULL; itemPtr++) { | |
912 | UAMeasureUnit units[kMeasureUnitMax]; | |
913 | UErrorCode status = U_ZERO_ERROR; | |
914 | int32_t unitsCount = uameasfmt_getUnitsForUsage(itemPtr->locale, itemPtr->category, itemPtr->usage, | |
915 | units, kMeasureUnitMax, &status); | |
916 | if ( U_FAILURE(status) ) { | |
917 | if (itemPtr->unitCount != 0) { | |
918 | log_err("FAIL: uameasfmt_getUnitsForUsage locale %s, category %s-%s, status %s\n", | |
919 | itemPtr->locale, itemPtr->category, itemPtr->usage, u_errorName(status)); | |
920 | } | |
921 | } else if (itemPtr->unitCount == 0) { | |
922 | log_err("FAIL: uameasfmt_getUnitsForUsage locale %s, category %s-%s, expected failure, got status %s\n", | |
923 | itemPtr->locale, itemPtr->category, itemPtr->usage, u_errorName(status)); | |
924 | } else if (unitsCount != itemPtr->unitCount) { | |
925 | log_err("FAIL: uameasfmt_getUnitsForUsage locale %s, category %s-%s, expected count %d, got %d\n", | |
926 | itemPtr->locale, itemPtr->category, itemPtr->usage, itemPtr->unitCount, unitsCount); | |
927 | } else if (units[0] != itemPtr->units[0] || (unitsCount == 2 && units[1] != itemPtr->units[1])) { | |
928 | log_err("FAIL: uameasfmt_getUnitsForUsage locale %s, category %s-%s, expected units x%04X ..., got x%04X ...\n", | |
929 | itemPtr->locale, itemPtr->category, itemPtr->usage, itemPtr->units[0], units[0]); | |
930 | } | |
931 | } | |
932 | } | |
933 | ||
934 | typedef struct { | |
935 | UAMeasureUnit unit; | |
936 | const char* category; | |
937 | } CategoryForUnit; | |
938 | ||
939 | static const CategoryForUnit categoryForUnitItems[] = { | |
940 | { UAMEASUNIT_VOLUME_LITER, "volume" }, | |
941 | { UAMEASUNIT_LENGTH_METER, "length" }, | |
942 | { UAMEASUNIT_PRESSURE_HECTOPASCAL, "pressure" }, | |
943 | { UAMEASUNIT_CONCENTRATION_MILLIMOLE_PER_LITER, "concentr" }, | |
944 | { (UAMeasureUnit)0, NULL } | |
945 | }; | |
946 | ||
947 | static void TestUAGetCategoryForUnit() | |
948 | { | |
949 | const CategoryForUnit* itemPtr = categoryForUnitItems; | |
950 | for (; itemPtr->category != NULL; itemPtr++) { | |
951 | UErrorCode status = U_ZERO_ERROR; | |
952 | const char *category = uameasfmt_getUnitCategory(itemPtr->unit, &status); | |
953 | if ( U_FAILURE(status) ) { | |
954 | log_err("FAIL: uameasfmt_getUnitCategory unit %d:%d, got status %s\n", | |
955 | ((int)itemPtr->unit) >> 8, ((int)itemPtr->unit) & 0xFF, u_errorName(status)); | |
956 | } else if (category == NULL) { | |
957 | log_err("FAIL: uameasfmt_getUnitCategory unit %d:%d, got NULL return\n", | |
958 | ((int)itemPtr->unit) >> 8, ((int)itemPtr->unit) & 0xFF); | |
959 | } else if (uprv_strcmp(category, itemPtr->category) != 0) { | |
960 | log_err("FAIL: uameasfmt_getUnitCategory unit %d:%d, expected %s, got %s\n", | |
961 | ((int)itemPtr->unit) >> 8, ((int)itemPtr->unit) & 0xFF, itemPtr->category, category); | |
962 | } | |
963 | } | |
964 | } | |
965 | ||
966 | #endif /* #if !UCONFIG_NO_FORMATTING */ |