Skip to content

Commit

Permalink
CLDR-16857 add SLE to cov=80, add test (#3088)
Browse files Browse the repository at this point in the history
- add test that checks modern currencies
  • Loading branch information
srl295 authored Aug 15, 2023
1 parent 9f668ed commit 13252bb
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 1 deletion.
2 changes: 1 addition & 1 deletion common/supplemental/coverageLevels.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ For terms of use, see http://www.unicode.org/copyright.html
<coverageVariable key="%currency40" value="(BRL|CNY|EUR|GBP|INR|JPY|RUB|USD)"/>
<coverageVariable key="%currency60" value="(AUD|CAD|CHF|DKK|HKD|IDR|KRW|MXN|NOK|PLN|SAR|SEK|THB|TRY|TWD|ZAR)"/>
<coverageVariable key="%currency60_EU" value="(CZK|HUF)"/>
<coverageVariable key="%currency80" value="(AED|AFN|ALL|AMD|ANG|AOA|ARS|AWG|AZN|BAM|BBD|BDT|BGN|BHD|BIF|BMD|BND|BOB|BSD|BTN|BWP|BYN|BZD|CDF|CLP|CNH|COP|CRC|CUC|CUP|CVE|CZK|DJF|DOP|DZD|EGP|ERN|ETB|FJD|FKP|GEL|GHS|GIP|GMD|GNF|GTQ|GYD|HNL|HRK|HTG|HUF|ILS|IQD|IRR|ISK|JMD|JOD|KES|KGS|KHR|KMF|KPW|KWD|KYD|KZT|LAK|LBP|LKR|LRD|LSL|LYD|MAD|MDL|MGA|MKD|MMK|MNT|MOP|MRU|MUR|MVR|MWK|MYR|MZN|NAD|NGN|NIO|NPR|NZD|OMR|PAB|PEN|PGK|PHP|PKR|PYG|QAR|RON|RSD|RWF|SBD|SCR|SDG|SGD|SHP|SLL|SOS|SRD|SSP|STN|SYP|SZL|TJS|TMT|TND|TOP|TTD|TZS|UAH|UGX|UYU|UZS|VES|VND|VUV|WST|XCD|XAF|XOF|XPF|YER|ZMW)"/>
<coverageVariable key="%currency80" value="(AED|AFN|ALL|AMD|ANG|AOA|ARS|AWG|AZN|BAM|BBD|BDT|BGN|BHD|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0-9])"/>
<coverageVariable key="%d0Types80" value="(ascii|fwidth|hwidth|lower|title|upper)"/>
Expand Down
53 changes: 53 additions & 0 deletions tools/cldr-code/src/test/java/org/unicode/cldr/util/TestLevel.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
package org.unicode.cldr.util;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.params.provider.Arguments.arguments;

import java.util.Set;
import java.util.TreeSet;
import java.util.stream.Stream;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.CsvSource;
import org.junit.jupiter.params.provider.MethodSource;

public class TestLevel {
@ParameterizedTest(name = "{index}: min {0},{1}")
Expand Down Expand Up @@ -47,4 +55,49 @@ void testMax(final String a, final String b, final String c) {
actual,
() -> String.format("Expected Level.max(%s,%s) but was %s", aa, bb, actual));
}

static SupplementalDataInfo sdi = null;

@BeforeAll
public static void setUp() throws Exception {
sdi = CLDRConfig.getInstance().getSupplementalDataInfo();
}

/** walk through all currencies looking for modern ones */
static final Stream<Arguments> modernCurrencies() {
final Set<String> all = new TreeSet<String>();

sdi.getCurrencyTerritories()
.forEach(
(t) -> {
sdi.getCurrencyDateInfo(t).stream()
// TODO: should we use RECENT_HISTORY? CLDR-16316
.filter(
di ->
(di.isLegalTender()
&& (DateConstants.NOW.compareTo(
di.getStart())
>= 0)
&& (DateConstants.NOW.compareTo(
di.getEnd())
<= 0)))
.map(di -> di.getCurrency())
.forEach(c -> all.add(c));
});
return all.stream().map(c -> arguments(c));
}

@ParameterizedTest()
@MethodSource("modernCurrencies")
public void testModernCurrencies(final String code) {
Level l =
sdi.getCoverageLevel(
String.format(
"//ldml/numbers/currencies/currency[@type=\"%s\"]/symbol", code),
"und");
final Level expect = Level.MODERN;
assertTrue(
expect.isAtLeast(l),
() -> String.format("cov for %s is %s expected ≤ %s", code, l, expect));
}
}

0 comments on commit 13252bb

Please sign in to comment.