diff --git a/icu4c/source/test/intltest/numfmtst.cpp b/icu4c/source/test/intltest/numfmtst.cpp index fc3ca05652b..6f008441c94 100644 --- a/icu4c/source/test/intltest/numfmtst.cpp +++ b/icu4c/source/test/intltest/numfmtst.cpp @@ -94,6 +94,7 @@ void NumberFormatTest::runIndexedTest( int32_t index, UBool exec, const char* &n TESTCASE_AUTO(TestQuotes); TESTCASE_AUTO(TestExponential); TESTCASE_AUTO(TestPatterns); + TESTCASE_AUTO(Test20186_SpacesAroundSemicolon); // Upgrade to alphaWorks - liu 5/99 TESTCASE_AUTO(TestExponent); @@ -397,6 +398,21 @@ NumberFormatTest::TestPatterns(void) } } +void NumberFormatTest::Test20186_SpacesAroundSemicolon() { + IcuTestErrorCode status(*this, "Test20186_SpacesAroundSemicolon"); + DecimalFormat df(u"0.00 ; -0.00", {"en-us", status}, status); + expect2(df, 1, u"1.00 "); + expect2(df, -1, u" -1.00"); + + df = DecimalFormat(u"0.00;", {"en-us", status}, status); + expect2(df, 1, u"1.00"); + expect2(df, -1, u"-1.00"); + + df = DecimalFormat(u"0.00;0.00", {"en-us", status}, status); + expect2(df, 1, u"1.00"); + expect(df, -1, u"1.00"); // parses as 1, not -1 +} + /* icu_2_4::DigitList::operator== 0 0 2 icuuc24d.dll digitlst.cpp Doug icu_2_4::DigitList::append 0 0 4 icuin24d.dll digitlst.h Doug diff --git a/icu4c/source/test/intltest/numfmtst.h b/icu4c/source/test/intltest/numfmtst.h index 9d255383243..5a07a9a1808 100644 --- a/icu4c/source/test/intltest/numfmtst.h +++ b/icu4c/source/test/intltest/numfmtst.h @@ -98,6 +98,8 @@ class NumberFormatTest: public CalendarTimeZoneTest { **/ //void TestDigitList(void); + void Test20186_SpacesAroundSemicolon(void); + /** * Test localized currency patterns. */ diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/NumberFormatTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/NumberFormatTest.java index fe0d77cca29..8033e27a839 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/NumberFormatTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/NumberFormatTest.java @@ -257,6 +257,21 @@ public class NumberFormatTest extends TestFmwk { } } + @Test + public void Test20186_SpacesAroundSemicolon() { + DecimalFormat df = new DecimalFormat("0.00 ; -0.00"); + expect2(df, 1, "1.00 "); + expect2(df, -1, " -1.00"); + + df = new DecimalFormat("0.00;"); + expect2(df, 1, "1.00"); + expect2(df, -1, "-1.00"); + + df = new DecimalFormat("0.00;0.00"); + expect2(df, 1, "1.00"); + expect(df, -1, "1.00"); // parses as 1, not -1 + } + // Test exponential pattern @Test public void TestExponential() {