Skip to content

Commit a6e5975

Browse files
authored
CLDR-18446 currency RSD should have cashDigits=0, not use DEFAULT; add test (#5215)
1 parent 19265d1 commit a6e5975

File tree

2 files changed

+52
-1
lines changed

2 files changed

+52
-1
lines changed

common/supplemental/supplementalData.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ For terms of use, see https://www.unicode.org/copyright.html
5757
<info iso4217="OMR" digits="3" rounding="0"/>
5858
<info iso4217="PKR" digits="0" rounding="0"/>
5959
<info iso4217="PYG" digits="0" rounding="0"/>
60+
<info iso4217="RSD" digits="2" rounding="0" cashDigits="0" cashRounding="0"/>
6061
<info iso4217="RWF" digits="0" rounding="0"/>
6162
<info iso4217="SEK" digits="2" rounding="0" cashDigits="0" cashRounding="0"/>
6263
<info iso4217="SLE" digits="2" rounding="0"/>

tools/cldr-code/src/test/java/org/unicode/cldr/unittest/TestSupplementalInfo.java

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1747,15 +1747,65 @@ private void showCountries(
17471747
}
17481748
}
17491749

1750+
private static Map<String, List<Integer>> createCurrencyDecimalCasesMap() {
1751+
Map<String, List<Integer>> currencyDecimalCasesMap = new HashMap<>();
1752+
// currency: digits, rounding, cashDigits, cashRounding
1753+
currencyDecimalCasesMap.put("ADP", Arrays.asList(0, 0, 0, 0));
1754+
currencyDecimalCasesMap.put("AMD", Arrays.asList(2, 0, 0, 0));
1755+
currencyDecimalCasesMap.put("BHD", Arrays.asList(3, 0, 3, 0));
1756+
currencyDecimalCasesMap.put("CAD", Arrays.asList(2, 0, 2, 5));
1757+
currencyDecimalCasesMap.put("CHF", Arrays.asList(2, 0, 2, 5));
1758+
currencyDecimalCasesMap.put("CLF", Arrays.asList(4, 0, 4, 0));
1759+
currencyDecimalCasesMap.put("CZK", Arrays.asList(2, 0, 0, 0));
1760+
currencyDecimalCasesMap.put("DKK", Arrays.asList(2, 0, 2, 50));
1761+
currencyDecimalCasesMap.put("HUF", Arrays.asList(0, 0, 0, 5));
1762+
currencyDecimalCasesMap.put("RSD", Arrays.asList(2, 0, 0, 0));
1763+
currencyDecimalCasesMap.put("TWD", Arrays.asList(2, 0, 0, 0));
1764+
currencyDecimalCasesMap.put("USD", Arrays.asList(2, 0, 2, 0)); // per DEFAULT
1765+
return Collections.unmodifiableMap(currencyDecimalCasesMap);
1766+
}
1767+
17501768
public void TestCurrencyDecimalPlaces() {
17511769
IsoCurrencyParser isoCodes = IsoCurrencyParser.getInstance();
17521770
Relation<String, IsoCurrencyParser.Data> codeList = isoCodes.getCodeList();
1771+
Map<String, List<Integer>> currencyDecimalCasesMap = createCurrencyDecimalCasesMap();
17531772
Set<String> currencyCodes = STANDARD_CODES.getGoodAvailableCodes("currency");
17541773
for (String cc : currencyCodes) {
1774+
CurrencyNumberInfo cni = SUPPLEMENTAL.getCurrencyNumberInfo(cc);
1775+
List<Integer> expectedValues = currencyDecimalCasesMap.get(cc);
1776+
if (expectedValues != null) {
1777+
int expectedDigits = expectedValues.get(0).intValue();
1778+
int expectedRounding = expectedValues.get(1).intValue();
1779+
int expectedCashDigits = expectedValues.get(2).intValue();
1780+
int expectedCashRounding = expectedValues.get(3).intValue();
1781+
if (expectedDigits != cni.digits
1782+
|| expectedRounding != cni.rounding
1783+
|| expectedCashDigits != cni.cashDigits
1784+
|| expectedCashRounding != cni.cashRounding) {
1785+
errln(
1786+
"Error in CLDR currency decimal values for "
1787+
+ cc
1788+
+ "; expected digits/rounding/cashDigits/cashRounding "
1789+
+ expectedDigits
1790+
+ "/"
1791+
+ expectedRounding
1792+
+ "/"
1793+
+ expectedCashDigits
1794+
+ "/"
1795+
+ expectedCashRounding
1796+
+ "; got "
1797+
+ cni.digits
1798+
+ "/"
1799+
+ cni.rounding
1800+
+ "/"
1801+
+ cni.cashDigits
1802+
+ "/"
1803+
+ cni.cashRounding);
1804+
}
1805+
}
17551806
Set<IsoCurrencyParser.Data> d = codeList.get(cc);
17561807
if (d != null) {
17571808
for (IsoCurrencyParser.Data x : d) {
1758-
CurrencyNumberInfo cni = SUPPLEMENTAL.getCurrencyNumberInfo(cc);
17591809
if (cni.digits != x.getMinorUnit()) {
17601810
logln(
17611811
"Mismatch between ISO/CLDR for decimal places for currency => "

0 commit comments

Comments
 (0)