]> granicus.if.org Git - icu/commitdiff
ICU-13035 Adding test to ICU4C for padding code point.
authorShane Carr <shane@unicode.org>
Mon, 7 May 2018 22:37:02 +0000 (22:37 +0000)
committerShane Carr <shane@unicode.org>
Mon, 7 May 2018 22:37:02 +0000 (22:37 +0000)
X-SVN-Rev: 41339

icu4c/source/i18n/number_padding.cpp
icu4c/source/test/intltest/numfmtst.cpp
icu4c/source/test/intltest/numfmtst.h

index f6abf9bd80e22ed6b1dd17b1733275a26fe903a6..97e7b6014f9aac5978f58d7dc33ee8c52916f8af 100644 (file)
@@ -29,6 +29,7 @@ addPaddingHelper(UChar32 paddingCp, int32_t requiredPadding, NumberStringBuilder
 }
 
 Padder::Padder(UChar32 cp, int32_t width, UNumberFormatPadPosition position) : fWidth(width) {
+    // TODO(13034): Consider making this a string instead of code point.
     fUnion.padding.fCp = cp;
     fUnion.padding.fPosition = position;
 }
index 0f2554ef5bf0d6496b75e4b5100df6ed168ac51d..243fc12d7b370f0ecaf136b0c3248a188668cd0a 100644 (file)
@@ -648,6 +648,7 @@ void NumberFormatTest::runIndexedTest( int32_t index, UBool exec, const char* &n
   TESTCASE_AUTO(TestFormatCurrencyPlural);
   TESTCASE_AUTO(Test11868);
   TESTCASE_AUTO(Test11739_ParseLongCurrency);
+  TESTCASE_AUTO(Test13035_MultiCodePointPaddingInPattern);
   TESTCASE_AUTO(Test10727_RoundingZero);
   TESTCASE_AUTO(Test11376_getAndSetPositivePrefix);
   TESTCASE_AUTO(Test11475_signRecognition);
@@ -8763,6 +8764,21 @@ void NumberFormatTest::Test11739_ParseLongCurrency() {
     assertEquals("Should parse to 1500 USD", u"USD", result->getISOCurrency());
 }
 
+void NumberFormatTest::Test13035_MultiCodePointPaddingInPattern() {
+    IcuTestErrorCode status(*this, "Test13035_MultiCodePointPaddingInPattern");
+    DecimalFormat df(u"a*'நி'###0b", status);
+    UnicodeString result;
+    df.format(12, result.remove());
+    // TODO(13034): Re-enable this test when support is added in ICU4C.
+    //assertEquals("Multi-codepoint padding should not be split", u"aநிநி12b", result);
+    df = DecimalFormat(u"a*\U0001F601###0b", status);
+    result = df.format(12, result.remove());
+    assertEquals("Single-codepoint padding should not be split", u"a\U0001F601\U0001F60112b", result);
+    df = DecimalFormat(u"a*''###0b", status);
+    result = df.format(12, result.remove());
+    assertEquals("Quote should be escapable in padding syntax", "a''12b", result);
+}
+
 void NumberFormatTest::Test11376_getAndSetPositivePrefix() {
     {
         const UChar USD[] = {0x55, 0x53, 0x44, 0x0};
index 5a9832285d43e2f2f7b62a7dfe129089a660f2b6..5090eef3a9e951de3e62cefe3e21c8b8d863a8e7 100644 (file)
@@ -212,6 +212,7 @@ class NumberFormatTest: public CalendarTimeZoneTest {
     void TestFormatCurrencyPlural();
     void Test11868();
     void Test11739_ParseLongCurrency();
+    void Test13035_MultiCodePointPaddingInPattern();
     void Test10727_RoundingZero();
     void Test11376_getAndSetPositivePrefix();
     void Test11475_signRecognition();