]> granicus.if.org Git - icu/commitdiff
ICU-20186 Adding test for semicolon behavior and spacing in DecimalFormat.
authorShane Carr <shane@unicode.org>
Mon, 1 Oct 2018 23:18:39 +0000 (16:18 -0700)
committerShane F. Carr <shane@unicode.org>
Tue, 27 Nov 2018 00:49:32 +0000 (18:49 -0600)
icu4c/source/test/intltest/numfmtst.cpp
icu4c/source/test/intltest/numfmtst.h
icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/NumberFormatTest.java

index fc3ca05652bdaab1887bd70f6194bbc1605fe044..6f008441c94e957d1a6726f1a54a8de38fd5399c 100644 (file)
@@ -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
index 9d255383243bda3fe733ff123f594514306d181e..5a07a9a1808ffe66969ad90c762fe70f5144613c 100644 (file)
@@ -98,6 +98,8 @@ class NumberFormatTest: public CalendarTimeZoneTest {
      **/
     //void TestDigitList(void);
 
+    void Test20186_SpacesAroundSemicolon(void);
+
     /**
      * Test localized currency patterns.
      */
index fe0d77cca29db6399ab3d67b75e8ac3451b793ca..8033e27a839f78cf3ddcfe9a317045e855240589 100644 (file)
@@ -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() {