From a89550fd7a1144c39bfde357a2f08216a04b697d Mon Sep 17 00:00:00 2001 From: Shane Carr Date: Wed, 16 May 2018 21:48:35 +0000 Subject: [PATCH] ICU-11897 Fixing testNumberingSystem in C and J. X-SVN-Rev: 41387 --- icu4c/source/test/intltest/tsdcfmsy.cpp | 33 ++++++++++--------- .../format/IntlTestDecimalFormatSymbols.java | 31 +++++++++-------- 2 files changed, 34 insertions(+), 30 deletions(-) diff --git a/icu4c/source/test/intltest/tsdcfmsy.cpp b/icu4c/source/test/intltest/tsdcfmsy.cpp index 3dcc68d4a6d..18a1ae863c1 100644 --- a/icu4c/source/test/intltest/tsdcfmsy.cpp +++ b/icu4c/source/test/intltest/tsdcfmsy.cpp @@ -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); } } diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/IntlTestDecimalFormatSymbols.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/IntlTestDecimalFormatSymbols.java index 0d6f7d0b1f5..1042d3f8298 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/IntlTestDecimalFormatSymbols.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/IntlTestDecimalFormatSymbols.java @@ -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); -- 2.40.0