From a6da272f2d2d9ea7ae0b8dfcfc0fb34a3a9f55b7 Mon Sep 17 00:00:00 2001 From: Andy Heninger Date: Sun, 13 May 2018 01:07:24 +0000 Subject: [PATCH] ICU-11913 Port Test11913() from Java. Big Decimal formatting w more than 309 digits. X-SVN-Rev: 41371 --- icu4c/source/test/intltest/numfmtst.cpp | 13 +++++++++++++ icu4c/source/test/intltest/numfmtst.h | 1 + 2 files changed, 14 insertions(+) diff --git a/icu4c/source/test/intltest/numfmtst.cpp b/icu4c/source/test/intltest/numfmtst.cpp index fc061d9e352..2dde1cf1267 100644 --- a/icu4c/source/test/intltest/numfmtst.cpp +++ b/icu4c/source/test/intltest/numfmtst.cpp @@ -27,6 +27,7 @@ #include "textfile.h" #include "tokiter.h" #include "charstr.h" +#include "cstr.h" #include "putilimp.h" #include "winnmtst.h" #include @@ -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 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 */ diff --git a/icu4c/source/test/intltest/numfmtst.h b/icu4c/source/test/intltest/numfmtst.h index 76feaa99c8a..5f68d78a700 100644 --- a/icu4c/source/test/intltest/numfmtst.h +++ b/icu4c/source/test/intltest/numfmtst.h @@ -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); -- 2.40.0