]> granicus.if.org Git - icu/commitdiff
ICU-11913 Port Test11913() from Java. Big Decimal formatting w more than 309 digits.
authorAndy Heninger <andy.heninger@gmail.com>
Sun, 13 May 2018 01:07:24 +0000 (01:07 +0000)
committerAndy Heninger <andy.heninger@gmail.com>
Sun, 13 May 2018 01:07:24 +0000 (01:07 +0000)
X-SVN-Rev: 41371

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

index fc061d9e3523fa513c91455a865c2b64bd1a60b8..2dde1cf1267cccf4a814676fbd56697790e82e38 100644 (file)
@@ -27,6 +27,7 @@
 #include "textfile.h"
 #include "tokiter.h"
 #include "charstr.h"
+#include "cstr.h"
 #include "putilimp.h"
 #include "winnmtst.h"
 #include <cmath>
@@ -680,6 +681,7 @@ void NumberFormatTest::runIndexedTest( int32_t index, UBool exec, const char* &n
   TESTCASE_AUTO(Test13148_ParseGroupingSeparators);
   TESTCASE_AUTO(Test12753_PatternDecimalPoint);
   TESTCASE_AUTO(Test11647_PatternCurrencySymbols);
+  TESTCASE_AUTO(Test11913_BigDecimal);
   TESTCASE_AUTO_END;
 }
 
@@ -9513,4 +9515,15 @@ void NumberFormatTest::Test12753_PatternDecimalPoint() {
     df.format(123, actual);
     assertEquals("Should replace 4 currency signs with U+FFFD", "\uFFFD123", actual);
 }
+
+void NumberFormatTest::Test11913_BigDecimal() {
+    UErrorCode status = U_ZERO_ERROR;
+    LocalPointer<NumberFormat> df(NumberFormat::createInstance(Locale::getEnglish(), status), status);
+    if (!assertSuccess("", status)) return;
+    UnicodeString result;
+    df->format(StringPiece("1.23456789E400"), result, nullptr, status);
+    assertSuccess("", status);
+    assertEquals("Should format more than 309 digits", u"12,345,678", UnicodeString(result, 0, 10));
+    assertEquals("Should format more than 309 digits", 534, result.length());
+}
 #endif /* #if !UCONFIG_NO_FORMATTING */
index 76feaa99c8acee7784b99ee6b6e6414291fc1a52..5f68d78a7002956cd8edd38a464c86d006c324da 100644 (file)
@@ -244,6 +244,7 @@ class NumberFormatTest: public CalendarTimeZoneTest {
     void Test13148_ParseGroupingSeparators();
     void Test12753_PatternDecimalPoint();
     void Test11647_PatternCurrencySymbols();
+    void Test11913_BigDecimal();
 
  private:
     UBool testFormattableAsUFormattable(const char *file, int line, Formattable &f);