ICU-11897 Fixing testNumberingSystem in C and J.

X-SVN-Rev: 41387
This commit is contained in:
Shane Carr 2018-05-16 21:48:35 +00:00
parent 523cbcd1dc
commit a89550fd7a
2 changed files with 34 additions and 30 deletions

View file

@ -354,16 +354,18 @@ void IntlTestDecimalFormatSymbols::testNumberingSystem() {
const char16_t* expected1; // Expected number format string
const char16_t* expected2; // Expected pattern separator
};
static const testcase cases[9] = {
{"en", "latn", u"1,234.56", u";"},
{"en", "arab", u"١٬٢٣٤٫٥٦", u"؛"},
{"en", "mathsanb", u"𝟭,𝟮𝟯𝟰.𝟱𝟲", u";"},
{"en", "mymr", u"၁,၂၃၄.၅၆", u";"},
{"my", "latn", u"1,234.56", u";"},
{"my", "arab", u"١٬٢٣٤٫٥٦", u"؛"},
{"my", "mathsanb", u"𝟭,𝟮𝟯𝟰.𝟱𝟲", u";"},
{"my", "mymr", u"၁,၂၃၄.၅၆", u""},
{"en@numbers=thai", "mymr", u"၁,၂၃၄.၅၆", u";"}, // conflicting numbering system
static const testcase cases[] = {
{"en", "latn", u"1,234.56", u"%"},
{"en", "arab", u"١٬٢٣٤٫٥٦", u"٪\u061C"},
{"en", "mathsanb", u"𝟭,𝟮𝟯𝟰.𝟱𝟲", u"%"},
{"en", "mymr", u"၁,၂၃၄.၅၆", u"%"},
{"my", "latn", u"1,234.56", u"%"},
{"my", "arab", u"١٬٢٣٤٫٥٦", u"٪\u061C"},
{"my", "mathsanb", u"𝟭,𝟮𝟯𝟰.𝟱𝟲", u"%"},
{"my", "mymr", u"၁,၂၃၄.၅၆", u"%"},
{"ar", "latn", u"1,234.56", u"\u200E%\u200E"},
{"ar", "arab", u"١٬٢٣٤٫٥٦", u"٪\u061C"},
{"en@numbers=thai", "mymr", u"၁,၂၃၄.၅၆", u"%"}, // conflicting numbering system
};
for (int i=0; i<8; i++) {
@ -380,12 +382,11 @@ void IntlTestDecimalFormatSymbols::testNumberingSystem() {
return;
}
Verify(1234.56, "#,##0.##", dfs, expected1);
// The pattern separator is something that differs by numbering system in my@numbers=mymr.
UnicodeString actual2 = dfs.getSymbol(DecimalFormatSymbols::kPatternSeparatorSymbol);
if (expected2 != actual2) {
errln((UnicodeString)"ERROR: DecimalFormatSymbols returned pattern separator " + actual2
+ " but we expected " + expected2);
}
// The percent sign differs by numbering system.
UnicodeString actual2 = dfs.getSymbol(DecimalFormatSymbols::kPercentSymbol);
assertEquals((UnicodeString) "Percent sign with " + cas.locid + " and " + cas.nsname,
expected2,
actual2);
}
}

View file

@ -365,32 +365,35 @@ public class IntlTestDecimalFormatSymbols extends TestFmwk
@Test
public void testNumberingSystem() {
Object[][] cases = {
{"en", "latn", "1,234.56", ';'},
{"en", "arab", "١٬٢٣٤٫٥٦", '؛'},
{"en", "mathsanb", "𝟭,𝟮𝟯𝟰.𝟱𝟲", ';'},
{"en", "mymr", "၁,၂၃၄.၅၆", ';'},
{"my", "latn", "1,234.56", ';'},
{"my", "arab", "١٬٢٣٤٫٥٦", '؛'},
{"my", "mathsanb", "𝟭,𝟮𝟯𝟰.𝟱𝟲", ';'},
{"my", "mymr", "၁,၂၃၄.၅၆", '၊'},
{"en@numbers=thai", "mymr", "၁,၂၃၄.၅၆", ';'}, // conflicting numbering system
{"en", "latn", "1,234.56", '%'},
{"en", "arab", "١٬٢٣٤٫٥٦", "٪\u061C"},
{"en", "mathsanb", "𝟭,𝟮𝟯𝟰.𝟱𝟲", '%'},
{"en", "mymr", "၁,၂၃၄.၅၆", '%'},
{"my", "latn", "1,234.56", '%'},
{"my", "arab", "١٬٢٣٤٫٥٦", "٪\u061C"},
{"my", "mathsanb", "𝟭,𝟮𝟯𝟰.𝟱𝟲", '%'},
{"my", "mymr", "၁,၂၃၄.၅၆", '%'},
{"ar", "latn", "1,234.56", "\u200E%\u200E"},
{"ar", "arab", "١٬٢٣٤٫٥٦", "٪\u061C"},
{"en@numbers=thai", "mymr", "၁,၂၃၄.၅၆", '%'}, // conflicting numbering system
};
for (Object[] cas : cases) {
ULocale loc = new ULocale((String) cas[0]);
NumberingSystem ns = NumberingSystem.getInstanceByName((String) cas[1]);
String expectedFormattedNumberString = (String) cas[2];
char expectedPatternSeparator = (Character) cas[3];
String expectedPercentSign = String.valueOf(cas[3]);
DecimalFormatSymbols dfs = DecimalFormatSymbols.forNumberingSystem(loc, ns);
DecimalFormat df = new DecimalFormat("#,##0.##", dfs);
String actual1 = df.format(1234.56);
assertEquals("1234.56 with " + loc + " and " + ns.getName(),
expectedFormattedNumberString, actual1);
// The pattern separator is something that differs by numbering system in my@numbers=mymr.
char actual2 = dfs.getPatternSeparator();
assertEquals("Pattern separator with " + loc + " and " + ns.getName(),
expectedPatternSeparator, actual2);
// The percent sign differs by numbering system.
String actual2 = dfs.getPercentString();
assertEquals("Percent sign with " + loc + " and " + ns.getName(),
expectedPercentSign, actual2);
// Coverage for JDK Locale overload
DecimalFormatSymbols dfs2 = DecimalFormatSymbols.forNumberingSystem(loc.toLocale(), ns);