From a01113dcd0f39d5da295ef82785beff9ed86fe38 Mon Sep 17 00:00:00 2001 From: Apple Date: Fri, 1 May 2020 18:26:33 +0000 Subject: [PATCH] ICU-64260.0.1.tar.gz --- icuSources/data/locales/es_US.txt | 3 + icuSources/data/region/ca.txt | 3 +- icuSources/data/region/cs.txt | 4 +- icuSources/data/region/da.txt | 3 +- icuSources/data/region/de.txt | 2 +- icuSources/data/region/es.txt | 4 +- icuSources/data/region/es_419.txt | 1 - icuSources/data/region/fi.txt | 4 +- icuSources/data/region/hr.txt | 4 +- icuSources/data/region/hu.txt | 4 +- icuSources/data/region/id.txt | 4 +- icuSources/data/region/it.txt | 4 +- icuSources/data/region/ms.txt | 2 +- icuSources/data/region/nb.txt | 3 +- icuSources/data/region/nl.txt | 2 +- icuSources/data/region/nn.txt | 3 +- icuSources/data/region/pt.txt | 4 +- icuSources/data/region/pt_PT.txt | 2 - icuSources/data/region/sk.txt | 3 +- icuSources/data/region/sv.txt | 4 +- icuSources/data/region/tr.txt | 3 +- icuSources/i18n/number_formatimpl.cpp | 6 ++ icuSources/i18n/number_mapper.cpp | 5 +- icuSources/test/cintltst/cnumtst.c | 88 +++++++++++++++++++-- icuSources/test/intltest/numbertest_api.cpp | 2 +- 25 files changed, 125 insertions(+), 42 deletions(-) diff --git a/icuSources/data/locales/es_US.txt b/icuSources/data/locales/es_US.txt index fc0a1a5a..9897bbcf 100644 --- a/icuSources/data/locales/es_US.txt +++ b/icuSources/data/locales/es_US.txt @@ -5,6 +5,9 @@ es_US{ MoreInformation{"[...]"} NumberElements{ latn{ + patterns{ + percentFormat{"#,##0%"} + } patternsLong{ decimalFormat{ 1000000000{ diff --git a/icuSources/data/region/ca.txt b/icuSources/data/region/ca.txt index fca03be7..e67b5525 100644 --- a/icuSources/data/region/ca.txt +++ b/icuSources/data/region/ca.txt @@ -77,7 +77,7 @@ ca{ CF{"República Centreafricana"} CG{"Congo - Brazzaville"} CH{"Suïssa"} - CI{"Costa d’Ivori"} + CI{"Côte d’Ivoire"} CK{"Illes Cook"} CL{"Xile"} CM{"Camerun"} @@ -306,6 +306,7 @@ ca{ Countries%variant{ CD{"Congo (República Democràtica del Congo)"} CG{"Congo (República del Congo)"} + CI{"Costa d’Ivori"} CZ{"República Txeca"} FK{"Illes Malvines (Illes Falkland)"} SZ{"Swazilàndia"} diff --git a/icuSources/data/region/cs.txt b/icuSources/data/region/cs.txt index aa37dc7c..f6945b4f 100644 --- a/icuSources/data/region/cs.txt +++ b/icuSources/data/region/cs.txt @@ -77,7 +77,7 @@ cs{ CF{"Středoafrická republika"} CG{"Kongo – Brazzaville"} CH{"Švýcarsko"} - CI{"Pobřeží slonoviny"} + CI{"Côte d’Ivoire"} CK{"Cookovy ostrovy"} CL{"Chile"} CM{"Kamerun"} @@ -306,7 +306,7 @@ cs{ Countries%variant{ CD{"Kongo (DRK)"} CG{"Kongo (republika)"} - CI{"Côte d’Ivoire"} + CI{"Pobřeží slonoviny"} CZ{"Česká republika"} FK{"Falklandské ostrovy (Malvíny)"} } diff --git a/icuSources/data/region/da.txt b/icuSources/data/region/da.txt index 376e4772..e186afb6 100644 --- a/icuSources/data/region/da.txt +++ b/icuSources/data/region/da.txt @@ -77,7 +77,7 @@ da{ CF{"Den Centralafrikanske Republik"} CG{"Congo-Brazzaville"} CH{"Schweiz"} - CI{"Elfenbenskysten"} + CI{"Côte d’Ivoire"} CK{"Cookøerne"} CL{"Chile"} CM{"Cameroun"} @@ -304,6 +304,7 @@ da{ Countries%variant{ CD{"Den Demokratiske Republik Congo (DRC)"} CG{"Republikken Congo"} + CI{"Elfenbenskysten"} CZ{"Den Tjekkiske Republik"} FK{"Falklandsøerne (Islas Malvinas)"} SZ{"Swaziland"} diff --git a/icuSources/data/region/de.txt b/icuSources/data/region/de.txt index f8d2b4ca..5fe60e71 100644 --- a/icuSources/data/region/de.txt +++ b/icuSources/data/region/de.txt @@ -77,7 +77,7 @@ de{ CF{"Zentralafrikanische Republik"} CG{"Kongo-Brazzaville"} CH{"Schweiz"} - CI{"Elfenbeinküste"} + CI{"Côte d’Ivoire"} CK{"Cookinseln"} CL{"Chile"} CM{"Kamerun"} diff --git a/icuSources/data/region/es.txt b/icuSources/data/region/es.txt index ce822fdb..64889966 100644 --- a/icuSources/data/region/es.txt +++ b/icuSources/data/region/es.txt @@ -77,7 +77,7 @@ es{ CF{"República Centroafricana"} CG{"Congo"} CH{"Suiza"} - CI{"Costa de Marfil"} + CI{"Côte d’Ivoire"} CK{"Islas Cook"} CL{"Chile"} CM{"Camerún"} @@ -303,7 +303,7 @@ es{ Countries%variant{ CD{"Congo (RDC)"} CG{"Congo (República)"} - CI{"Côte d’Ivoire"} + CI{"Costa de Marfil"} CZ{"República Checa"} FK{"Islas Malvinas (Islas Falkland)"} SZ{"Suazilandia"} diff --git a/icuSources/data/region/es_419.txt b/icuSources/data/region/es_419.txt index ba652fa8..348816ff 100644 --- a/icuSources/data/region/es_419.txt +++ b/icuSources/data/region/es_419.txt @@ -18,7 +18,6 @@ es_419{ AC{"Isla Ascensión"} BA{"Bosnia-Herzegovina"} CG{"República del Congo"} - CI{"Costa de Marfil"} EZ{"Eurozona"} GG{"Guernesey"} HK{"Hong-Kong"} diff --git a/icuSources/data/region/fi.txt b/icuSources/data/region/fi.txt index 83a3d6ce..22f620c6 100644 --- a/icuSources/data/region/fi.txt +++ b/icuSources/data/region/fi.txt @@ -77,7 +77,7 @@ fi{ CF{"Keski-Afrikan tasavalta"} CG{"Kongon tasavalta"} CH{"Sveitsi"} - CI{"Norsunluurannikko"} + CI{"Côte d’Ivoire"} CK{"Cookinsaaret"} CL{"Chile"} CM{"Kamerun"} @@ -304,7 +304,7 @@ fi{ Countries%variant{ CD{"Kongo-Kinshasa"} CG{"Kongo-Brazzaville"} - CI{"Côte d’Ivoire"} + CI{"Norsunluurannikko"} CZ{"Tšekinmaa"} FK{"Falklandinsaaret (Malvinassaaret)"} TL{"Timor-Leste"} diff --git a/icuSources/data/region/hr.txt b/icuSources/data/region/hr.txt index 5cd70e54..e016483a 100644 --- a/icuSources/data/region/hr.txt +++ b/icuSources/data/region/hr.txt @@ -77,7 +77,7 @@ hr{ CF{"Srednjoafrička Republika"} CG{"Kongo - Brazzaville"} CH{"Švicarska"} - CI{"Obala Bjelokosti"} + CI{"Côte d’Ivoire"} CK{"Cookovi Otoci"} CL{"Čile"} CM{"Kamerun"} @@ -306,7 +306,7 @@ hr{ Countries%variant{ CD{"Kongo (DRK)"} CG{"Kongo (RK)"} - CI{"Bjelokosna Obala"} + CI{"Obala Bjelokosti"} CZ{"Češka Republika"} FK{"Falklandski otoci (Malvini)"} TL{"Istočni Timor"} diff --git a/icuSources/data/region/hu.txt b/icuSources/data/region/hu.txt index f13eac3c..7bd33ea2 100644 --- a/icuSources/data/region/hu.txt +++ b/icuSources/data/region/hu.txt @@ -77,7 +77,7 @@ hu{ CF{"Közép-afrikai Köztársaság"} CG{"Kongó - Brazzaville"} CH{"Svájc"} - CI{"Elefántcsontpart"} + CI{"Côte d’Ivoire"} CK{"Cook-szigetek"} CL{"Chile"} CM{"Kamerun"} @@ -306,7 +306,7 @@ hu{ Countries%variant{ CD{"Kongó (KDK)"} CG{"Kongó (Köztársaság)"} - CI{"CI"} + CI{"Elefántcsontpart"} CZ{"Cseh Köztársaság"} FK{"Falkland-szigetek (Malvin-szigetek)"} TL{"Timor-Leste"} diff --git a/icuSources/data/region/id.txt b/icuSources/data/region/id.txt index cc1a47c8..61413053 100644 --- a/icuSources/data/region/id.txt +++ b/icuSources/data/region/id.txt @@ -77,7 +77,7 @@ id{ CF{"Republik Afrika Tengah"} CG{"Kongo - Brazzaville"} CH{"Swiss"} - CI{"Pantai Gading"} + CI{"Côte d’Ivoire"} CK{"Kepulauan Cook"} CL{"Cile"} CM{"Kamerun"} @@ -306,7 +306,7 @@ id{ Countries%variant{ CD{"Kongo (RDK)"} CG{"Kongo (Republik)"} - CI{"Pantai Gading (Ivory Coast)"} + CI{"Pantai Gading"} CZ{"Republik Ceko"} FK{"Kepulauan Malvinas (Falkland)"} SZ{"Swaziland"} diff --git a/icuSources/data/region/it.txt b/icuSources/data/region/it.txt index ee39d465..05d244fc 100644 --- a/icuSources/data/region/it.txt +++ b/icuSources/data/region/it.txt @@ -77,7 +77,7 @@ it{ CF{"Repubblica Centrafricana"} CG{"Congo-Brazzaville"} CH{"Svizzera"} - CI{"Costa d’Avorio"} + CI{"Côte d’Ivoire"} CK{"Isole Cook"} CL{"Cile"} CM{"Camerun"} @@ -306,7 +306,7 @@ it{ Countries%variant{ CD{"Congo (RDC)"} CG{"Congo (Repubblica)"} - CI{"Côte d’Ivoire"} + CI{"Costa d’Avorio"} CZ{"Repubblica Ceca"} FK{"Isole Falkland (Isole Malvine)"} SZ{"Regno di eSwatini"} diff --git a/icuSources/data/region/ms.txt b/icuSources/data/region/ms.txt index 53702fc1..baa5c4ea 100644 --- a/icuSources/data/region/ms.txt +++ b/icuSources/data/region/ms.txt @@ -77,7 +77,7 @@ ms{ CF{"Republik Afrika Tengah"} CG{"Congo - Brazzaville"} CH{"Switzerland"} - CI{"Cote d’Ivoire"} + CI{"Côte d’Ivoire"} CK{"Kepulauan Cook"} CL{"Chile"} CM{"Cameroon"} diff --git a/icuSources/data/region/nb.txt b/icuSources/data/region/nb.txt index 8a8ec470..3c806aa6 100644 --- a/icuSources/data/region/nb.txt +++ b/icuSources/data/region/nb.txt @@ -77,7 +77,7 @@ nb{ CF{"Den sentralafrikanske republikk"} CG{"Kongo-Brazzaville"} CH{"Sveits"} - CI{"Elfenbenskysten"} + CI{"Côte d’Ivoire"} CK{"Cookøyene"} CL{"Chile"} CM{"Kamerun"} @@ -304,6 +304,7 @@ nb{ Countries%variant{ CD{"Den demokratiske republikken Kongo"} CG{"Republikken Kongo"} + CI{"Elfenbenskysten"} CZ{"Den tsjekkiske republikk"} FK{"Falklandsøyene (Islas Malvinas)"} SZ{"Swaziland"} diff --git a/icuSources/data/region/nl.txt b/icuSources/data/region/nl.txt index 85df9ca8..fdff035f 100644 --- a/icuSources/data/region/nl.txt +++ b/icuSources/data/region/nl.txt @@ -77,7 +77,7 @@ nl{ CF{"Centraal-Afrikaanse Republiek"} CG{"Congo-Brazzaville"} CH{"Zwitserland"} - CI{"Ivoorkust"} + CI{"Côte d’Ivoire"} CK{"Cookeilanden"} CL{"Chili"} CM{"Kameroen"} diff --git a/icuSources/data/region/nn.txt b/icuSources/data/region/nn.txt index f2b2e2a6..2ffaeeae 100644 --- a/icuSources/data/region/nn.txt +++ b/icuSources/data/region/nn.txt @@ -76,7 +76,7 @@ nn{ CF{"Den sentralafrikanske republikken"} CG{"Kongo-Brazzaville"} CH{"Sveits"} - CI{"Elfenbeinskysten"} + CI{"Côte d’Ivoire"} CK{"Cookøyane"} CL{"Chile"} CM{"Kamerun"} @@ -302,6 +302,7 @@ nn{ Countries%variant{ CD{"Den demokratiske republikken Kongo"} CG{"Republikken Kongo"} + CI{"Elfenbeinskysten"} FK{"Falklandsøyane (Islas Malvinas)"} TL{"Aust-Timor"} } diff --git a/icuSources/data/region/pt.txt b/icuSources/data/region/pt.txt index 8c5adf57..8f7dda81 100644 --- a/icuSources/data/region/pt.txt +++ b/icuSources/data/region/pt.txt @@ -77,7 +77,7 @@ pt{ CF{"República Centro-Africana"} CG{"República do Congo"} CH{"Suíça"} - CI{"Costa do Marfim"} + CI{"Côte d’Ivoire"} CK{"Ilhas Cook"} CL{"Chile"} CM{"Camarões"} @@ -306,7 +306,7 @@ pt{ Countries%variant{ CD{"República Democrática do Congo"} CG{"Congo"} - CI{"Côte d’Ivoire"} + CI{"Costa do Marfim"} CZ{"República Tcheca"} FK{"Ilhas Falkland (Ilhas Malvinas)"} TL{"República Democrática de Timor-Leste"} diff --git a/icuSources/data/region/pt_PT.txt b/icuSources/data/region/pt_PT.txt index 54e7cbcf..a9487647 100644 --- a/icuSources/data/region/pt_PT.txt +++ b/icuSources/data/region/pt_PT.txt @@ -19,7 +19,6 @@ pt_PT{ CC{"Ilhas dos Cocos (Keeling)"} CD{"Congo-Kinshasa"} CG{"Congo-Brazzaville"} - CI{"Côte d’Ivoire (Costa do Marfim)"} CW{"Curaçau"} CX{"Ilha do Natal"} CZ{"Chéquia"} @@ -78,7 +77,6 @@ pt_PT{ } Countries%variant{ CG{"República do Congo"} - CI{"Costa do Marfim"} CZ{"República Checa"} FK{"Ilhas Falkland (Malvinas)"} } diff --git a/icuSources/data/region/sk.txt b/icuSources/data/region/sk.txt index efbdfad1..1077bbf8 100644 --- a/icuSources/data/region/sk.txt +++ b/icuSources/data/region/sk.txt @@ -77,7 +77,7 @@ sk{ CF{"Stredoafrická republika"} CG{"Konžská republika"} CH{"Švajčiarsko"} - CI{"Pobrežie Slonoviny"} + CI{"Côte d’Ivoire"} CK{"Cookove ostrovy"} CL{"Čile"} CM{"Kamerun"} @@ -302,6 +302,7 @@ sk{ US{"USA"} } Countries%variant{ + CI{"Pobrežie Slonoviny"} CZ{"Česká republika"} FK{"Falklandy (Malvíny)"} } diff --git a/icuSources/data/region/sv.txt b/icuSources/data/region/sv.txt index 764ab8e5..70ba309b 100644 --- a/icuSources/data/region/sv.txt +++ b/icuSources/data/region/sv.txt @@ -77,7 +77,7 @@ sv{ CF{"Centralafrikanska republiken"} CG{"Kongo-Brazzaville"} CH{"Schweiz"} - CI{"Elfenbenskusten"} + CI{"Côte d’Ivoire"} CK{"Cooköarna"} CL{"Chile"} CM{"Kamerun"} @@ -306,7 +306,7 @@ sv{ Countries%variant{ CD{"Demokratiska republiken Kongo"} CG{"Republiken Kongo"} - CI{"Côte d’Ivoire"} + CI{"Elfenbenskusten"} TL{"Timor-Leste"} } Version{"2.1.48.90"} diff --git a/icuSources/data/region/tr.txt b/icuSources/data/region/tr.txt index 7480e715..b4d9add5 100644 --- a/icuSources/data/region/tr.txt +++ b/icuSources/data/region/tr.txt @@ -77,7 +77,7 @@ tr{ CF{"Orta Afrika Cumhuriyeti"} CG{"Kongo - Brazavil"} CH{"İsviçre"} - CI{"Fildişi Sahili"} + CI{"Côte d’Ivoire"} CK{"Cook Adaları"} CL{"Şili"} CM{"Kamerun"} @@ -304,6 +304,7 @@ tr{ Countries%variant{ CD{"Kongo Demokratik Cumhuriyeti"} CG{"Kongo Cumhuriyeti"} + CI{"Fildişi Sahili"} CZ{"Çek Cumhuriyeti"} FK{"Falkland Adaları (Malvinas Adaları)"} SZ{"Svaziland"} diff --git a/icuSources/i18n/number_formatimpl.cpp b/icuSources/i18n/number_formatimpl.cpp index b036b6ef..4ae75e18 100644 --- a/icuSources/i18n/number_formatimpl.cpp +++ b/icuSources/i18n/number_formatimpl.cpp @@ -492,6 +492,12 @@ int32_t NumberFormatterImpl::writeNumber(const MicroProps& micros, DecimalQuanti // Add the fraction digits length += writeFractionDigits(micros, quantity, string, length + index, status); + + if (length == 0) { + // Force output of the digit for value 0 + length += utils::insertDigitFromSymbols( + string, index, 0, *micros.symbols, UNUM_INTEGER_FIELD, status); + } } return length; diff --git a/icuSources/i18n/number_mapper.cpp b/icuSources/i18n/number_mapper.cpp index 47867490..c66be526 100644 --- a/icuSources/i18n/number_mapper.cpp +++ b/icuSources/i18n/number_mapper.cpp @@ -126,11 +126,8 @@ MacroProps NumberPropertyMapper::oldToNew(const DecimalFormatProperties& propert } // Validate min/max int/frac. // For backwards compatibility, minimum overrides maximum if the two conflict. - // The following logic ensures that there is always a minimum of at least one digit. - // Except that we allow minInt=0, minFrac=0 if maxInt!=0 - rdar://54569257 if (minInt == 0 && maxFrac != 0) { - // Force a digit after the decimal point. - minFrac = (minFrac < 0 || (minFrac==0 && maxInt==0)) ? 1 : minFrac; // rdar://54569257 + minFrac = (minFrac < 0 || (minFrac == 0 && maxInt == 0)) ? 1 : minFrac; // rdar://54569257 maxFrac = maxFrac < 0 ? -1 : maxFrac < minFrac ? minFrac : maxFrac; minInt = 0; maxInt = maxInt < 0 ? -1 : maxInt > kMaxIntFracSig ? -1 : maxInt; diff --git a/icuSources/test/cintltst/cnumtst.c b/icuSources/test/cintltst/cnumtst.c index cbf090ed..773d626a 100644 --- a/icuSources/test/cintltst/cnumtst.c +++ b/icuSources/test/cintltst/cnumtst.c @@ -3202,7 +3202,7 @@ static const FieldsData fields_en_CURR[] = { { UNUM_FRACTION_FIELD /*1*/, 9, 11 }, { -1, -1, -1 }, }; -/* "en_US", UNUM_PERCENT, -34 : "#,##0%" => "-34%" */ +/* "en_US"/"es_US/MX" , UNUM_PERCENT, -34 : "#,##0%" => "-34%" */ static const FieldsData fields_en_PRCT[] = { { UNUM_SIGN_FIELD /*10*/, 0, 1 }, { UNUM_INTEGER_FIELD /*0*/, 1, 3 }, @@ -3227,6 +3227,8 @@ static const FieldsData fields_en_PATN[] = { static const FormatForFieldsItem fffItems[] = { { "en_US", UNUM_CURRENCY_STANDARD, 123456.0, fields_en_CURR }, { "en_US", UNUM_PERCENT, -0.34, fields_en_PRCT }, + { "es_US", UNUM_PERCENT, -0.34, fields_en_PRCT }, // rdar://57000745 + { "es_MX", UNUM_PERCENT, -0.34, fields_en_PRCT }, // rdar://42948387 { "fr_FR", UNUM_CURRENCY_STANDARD, 123456.0, fields_fr_CURR }, { "en_US", UNUM_PATTERN_DECIMAL, 12.0, fields_en_PATN }, { NULL, (UNumberFormatStyle)0, 0, NULL }, @@ -4254,15 +4256,15 @@ static void TestCurrForUnkRegion(void) { } static void TestMinIntMinFracZero(void) { + UChar ubuf[kUBufMax]; + char bbuf[kBBufMax]; + int minInt, minFrac, maxFrac, ulen; + UErrorCode status = U_ZERO_ERROR; UNumberFormat* unum = unum_open(UNUM_DECIMAL, NULL, 0, "en_US", NULL, &status); if ( U_FAILURE(status) ) { log_data_err("unum_open UNUM_DECIMAL for en_US fails with %s\n", u_errorName(status)); } else { - UChar ubuf[kUBufMax]; - char bbuf[kBBufMax]; - int minInt, minFrac, ulen; - unum_setAttribute(unum, UNUM_MIN_INTEGER_DIGITS, 0); unum_setAttribute(unum, UNUM_MIN_FRACTION_DIGITS, 0); minInt = unum_getAttribute(unum, UNUM_MIN_INTEGER_DIGITS); @@ -4270,10 +4272,13 @@ static void TestMinIntMinFracZero(void) { if (minInt != 0 || minFrac != 0) { log_err("after setting minInt=minFrac=0, get minInt %d, minFrac %d\n", minInt, minFrac); } + ulen = unum_toPattern(unum, FALSE, ubuf, kUBufMax, &status); - if ( U_SUCCESS(status) ) { + if ( U_FAILURE(status) ) { + log_err("unum_toPattern fails with %s\n", u_errorName(status)); + } else if (ulen < 3 || u_strstr(ubuf, u"#.#")==NULL) { u_strToUTF8(bbuf, kBBufMax, NULL, ubuf, ulen, &status); - log_info("after setting minInt=minFrac=0, pattern (%d): %s\n", ulen, bbuf); + log_err("after setting minInt=minFrac=0, expect pattern to contain \"#.#\", but get (%d): \"%s\"\n", ulen, bbuf); } status = U_ZERO_ERROR; @@ -4305,6 +4310,75 @@ static void TestMinIntMinFracZero(void) { unum_close(unum); } + + status = U_ZERO_ERROR; + unum = unum_open(UNUM_CURRENCY, NULL, 0, "en_US", NULL, &status); + if ( U_FAILURE(status) ) { + log_data_err("unum_open UNUM_CURRENCY for en_US fails with %s\n", u_errorName(status)); + } else { + unum_setAttribute(unum, UNUM_MIN_INTEGER_DIGITS, 0); + unum_setAttribute(unum, UNUM_MIN_FRACTION_DIGITS, 0); + minInt = unum_getAttribute(unum, UNUM_MIN_INTEGER_DIGITS); + minFrac = unum_getAttribute(unum, UNUM_MIN_FRACTION_DIGITS); + if (minInt != 0 || minFrac != 0) { + log_err("after setting CURRENCY minInt=minFrac=0, get minInt %d, minFrac %d\n", minInt, minFrac); + } + + status = U_ZERO_ERROR; + ulen = unum_formatDouble(unum, 10.0, ubuf, kUBufMax, NULL, &status); + if ( U_FAILURE(status) ) { + log_err("unum_formatDouble (CURRRENCY) 10.0 ulen %d fails with %s\n", ulen, u_errorName(status)); + } else if (u_strcmp(ubuf, u"$10") != 0) { + u_strToUTF8(bbuf, kBBufMax, NULL, ubuf, ulen, &status); + log_err("unum_formatDouble (CURRRENCY) 10.0 expected \"$10\", got \"%s\"\n", bbuf); + } + + status = U_ZERO_ERROR; + ulen = unum_formatDouble(unum, 0.9, ubuf, kUBufMax, NULL, &status); + if ( U_FAILURE(status) ) { + log_err("unum_formatDouble (CURRRENCY) 0.9 ulen %d fails with %s\n", ulen, u_errorName(status)); + } else if (u_strcmp(ubuf, u"$.9") != 0) { + u_strToUTF8(bbuf, kBBufMax, NULL, ubuf, ulen, &status); + log_err("unum_formatDouble (CURRRENCY) 0.9 expected \"$.9\", got \"%s\"\n", bbuf); + } + + status = U_ZERO_ERROR; + ulen = unum_formatDouble(unum, 0.0, ubuf, kUBufMax, NULL, &status); + if ( U_FAILURE(status) ) { + log_err("unum_formatDouble (CURRRENCY) 0.0 ulen %d fails with %s\n", ulen, u_errorName(status)); + } else if (u_strcmp(ubuf, u"$0") != 0) { + u_strToUTF8(bbuf, kBBufMax, NULL, ubuf, ulen, &status); + log_err("unum_formatDouble (CURRRENCY) 0.0 expected \"$0\", got \"%s\"\n", bbuf); + } + + unum_close(unum); + } + + // addition for rdar://57291456 + status = U_ZERO_ERROR; + unum = unum_open(UNUM_PATTERN_DECIMAL, NULL, 0, "en_IE", NULL, &status); + if ( U_FAILURE(status) ) { + log_data_err("unum_open UNUM_DECIMAL for en_US fails with %s\n", u_errorName(status)); + } else { + unum_setAttribute(unum, UNUM_MIN_INTEGER_DIGITS, 0); + unum_setAttribute(unum, UNUM_MAX_FRACTION_DIGITS, 1); + minInt = unum_getAttribute(unum, UNUM_MIN_INTEGER_DIGITS); + maxFrac = unum_getAttribute(unum, UNUM_MAX_FRACTION_DIGITS); + if (minInt != 0 || maxFrac != 1) { + log_err("after setting minInt=0, maxFrac=1, get minInt %d, maxFrac %d\n", minInt, maxFrac); + } + + status = U_ZERO_ERROR; + ulen = unum_formatDouble(unum, 0.0, ubuf, kUBufMax, NULL, &status); + if ( U_FAILURE(status) ) { + log_err("unum_formatDouble (maxFrac 1) 0.0 ulen %d fails with %s\n", ulen, u_errorName(status)); + } else if (u_strcmp(ubuf, u".0") != 0) { + u_strToUTF8(bbuf, kBBufMax, NULL, ubuf, ulen, &status); + log_err("unum_formatDouble (maxFrac 1) 0.0 expected \".0\", got \"%s\"\n", bbuf); + } + + unum_close(unum); + } } #if APPLE_ADDITIONS diff --git a/icuSources/test/intltest/numbertest_api.cpp b/icuSources/test/intltest/numbertest_api.cpp index f0d941d3..fde8e137 100644 --- a/icuSources/test/intltest/numbertest_api.cpp +++ b/icuSources/test/intltest/numbertest_api.cpp @@ -1613,7 +1613,7 @@ void NumberFormatterApiTest::integerWidth() { u".8765", u".08765", u".008765", - u""); // TODO: Avoid the empty string here? + u"0"); // see ICU-20844 assertFormatDescending( u"Integer Width Zero Fill 3", -- 2.45.2