Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 // © 2016 and later: Unicode, Inc. and others. | 1 // © 2016 and later: Unicode, Inc. and others. |
2 // License & terms of use: http://www.unicode.org/copyright.html | 2 // License & terms of use: http://www.unicode.org/copyright.html |
3 /******************************************************************** | 3 /******************************************************************** |
4 * COPYRIGHT: | 4 * COPYRIGHT: |
5 * Copyright (c) 1997-2013, International Business Machines Corporation and | 5 * Copyright (c) 1997-2013, International Business Machines Corporation and |
6 * others. All Rights Reserved. | 6 * others. All Rights Reserved. |
7 ********************************************************************/ | 7 ********************************************************************/ |
8 | 8 |
9 #include "unicode/utypes.h" | 9 #include "unicode/utypes.h" |
10 | 10 |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
244 DecimalFormatSymbols::ENumberFormatSymbol e = (DecimalFormatSymbols::ENu mberFormatSymbol)i; | 244 DecimalFormatSymbols::ENumberFormatSymbol e = (DecimalFormatSymbols::ENu mberFormatSymbol)i; |
245 assertEquals("last-resort symbol vs. root", root.getSymbol(e), lastResor t->getSymbol(e)); | 245 assertEquals("last-resort symbol vs. root", root.getSymbol(e), lastResor t->getSymbol(e)); |
246 } | 246 } |
247 // Also, the CurrencySpacing patterns are empty in the last resort instance, | 247 // Also, the CurrencySpacing patterns are empty in the last resort instance, |
248 // but not in root. | 248 // but not in root. |
249 Verify(1234567.25, "#,##0.##", *lastResort, "1,234,567.25"); | 249 Verify(1234567.25, "#,##0.##", *lastResort, "1,234,567.25"); |
250 } | 250 } |
251 | 251 |
252 void IntlTestDecimalFormatSymbols::testNumberingSystem() { | 252 void IntlTestDecimalFormatSymbols::testNumberingSystem() { |
253 IcuTestErrorCode errorCode(*this, "testNumberingSystem"); | 253 IcuTestErrorCode errorCode(*this, "testNumberingSystem"); |
254 char* cases[8][4] = { | 254 struct testcase { |
255 {"en", "latn", "1,234.56", ";"}, | 255 const char* locid; |
256 {"en", "arab", "١٬٢٣٤٫٥٦", "؛"}, | 256 const char* nsname; |
257 {"en", "mathsanb", "𝟭,𝟮𝟯𝟰.𝟱𝟲", ";"}, | 257 const char16_t* expected1; // Expected number format string |
258 {"en", "mymr", "၁,၂၃၄.၅၆", ";"}, | 258 const char16_t* expected2; // Expected pattern separator |
259 {"my", "latn", "1,234.56", ";"}, | |
260 {"my", "arab", "١٬٢٣٤٫٥٦", "؛"}, | |
261 {"my", "mathsanb", "𝟭,𝟮𝟯𝟰.𝟱𝟲", ";"}, | |
262 {"my", "mymr", "၁,၂၃၄.၅၆", "၊"}, | |
sffc
2017/07/27 06:15:59
This construct gives the following compiler warnin
markus.icu
2017/07/27 20:52:17
On 2017/07/27 06:15:59, sffc wrote:
Make it
st
sffc
2017/07/27 21:15:20
Done.
| |
263 }; | 259 }; |
260 static const testcase cases[9] = { | |
261 {"en", "latn", u"1,234.56", u";"}, | |
262 {"en", "arab", u"١٬٢٣٤٫٥٦", u"؛"}, | |
263 {"en", "mathsanb", u"𝟭,𝟮𝟯𝟰.𝟱𝟲", u";"}, | |
264 {"en", "mymr", u"၁,၂၃၄.၅၆", u";"}, | |
265 {"my", "latn", u"1,234.56", u";"}, | |
266 {"my", "arab", u"١٬٢٣٤٫٥٦", u"؛"}, | |
267 {"my", "mathsanb", u"𝟭,𝟮𝟯𝟰.𝟱𝟲", u";"}, | |
268 {"my", "mymr", u"၁,၂၃၄.၅၆", u"၊"}, | |
269 {"en@numbers=thai", "mymr", u"၁,၂၃၄.၅၆", u";"}, // conflicting numbe ring system | |
270 }; | |
264 | 271 |
265 for (int i=0; i<8; i++) { | 272 for (int i=0; i<8; i++) { |
266 Locale loc = Locale::createFromName(cases[i][0]); | 273 testcase cas = cases[i]; |
267 LocalPointer<NumberingSystem> ns(NumberingSystem::createInstanceByName(c ases[i][1], errorCode)); | 274 Locale loc(cas.locid); |
275 LocalPointer<NumberingSystem> ns(NumberingSystem::createInstanceByName(c as.nsname, errorCode)); | |
268 if (errorCode.logDataIfFailureAndReset("NumberingSystem failed")) { | 276 if (errorCode.logDataIfFailureAndReset("NumberingSystem failed")) { |
269 return; | 277 return; |
270 } | 278 } |
271 UnicodeString expected1(cases[i][2], "utf-8"); | 279 UnicodeString expected1(cas.expected1); |
272 UnicodeString expected2(cases[i][3], "utf-8"); | 280 UnicodeString expected2(cas.expected2); |
273 DecimalFormatSymbols dfs(loc, *ns, errorCode); | 281 DecimalFormatSymbols dfs(loc, *ns, errorCode); |
274 if (errorCode.logDataIfFailureAndReset("DecimalFormatSymbols failed")) { | 282 if (errorCode.logDataIfFailureAndReset("DecimalFormatSymbols failed")) { |
275 return; | 283 return; |
276 } | 284 } |
277 Verify(1234.56, "#,##0.##", dfs, expected1); | 285 Verify(1234.56, "#,##0.##", dfs, expected1); |
278 // The pattern separator is something that differs by numbering system i n my@numbers=mymr. | 286 // The pattern separator is something that differs by numbering system i n my@numbers=mymr. |
279 UnicodeString actual2 = dfs.getSymbol(DecimalFormatSymbols::kPatternSepa ratorSymbol); | 287 UnicodeString actual2 = dfs.getSymbol(DecimalFormatSymbols::kPatternSepa ratorSymbol); |
280 if (expected2 != actual2) { | 288 if (expected2 != actual2) { |
281 errln((UnicodeString)"ERROR: DecimalFormatSymbols returned pattern s eparator " + actual2 | 289 errln((UnicodeString)"ERROR: DecimalFormatSymbols returned pattern s eparator " + actual2 |
282 + " but we expected " + expected2); | 290 + " but we expected " + expected2); |
(...skipping 11 matching lines...) Expand all Loading... | |
294 UnicodeString buffer; | 302 UnicodeString buffer; |
295 FieldPosition pos(FieldPosition::DONT_CARE); | 303 FieldPosition pos(FieldPosition::DONT_CARE); |
296 buffer = df.format(value, buffer, pos); | 304 buffer = df.format(value, buffer, pos); |
297 if(buffer != expected){ | 305 if(buffer != expected){ |
298 errln((UnicodeString)"ERROR: format() returns wrong result\n Expected " + | 306 errln((UnicodeString)"ERROR: format() returns wrong result\n Expected " + |
299 expected + ", Got " + buffer); | 307 expected + ", Got " + buffer); |
300 } | 308 } |
301 } | 309 } |
302 | 310 |
303 #endif /* #if !UCONFIG_NO_FORMATTING */ | 311 #endif /* #if !UCONFIG_NO_FORMATTING */ |
LEFT | RIGHT |