From 16472502b5c9e9615d0373096520227e95cec3b0 Mon Sep 17 00:00:00 2001 From: Craig Cornelius Date: Mon, 7 May 2018 23:40:14 +0000 Subject: [PATCH] ICU-11649 Add test for Decimal Format of Currencies X-SVN-Rev: 41347 --- icu4c/source/test/intltest/numfmtst.cpp | 20 ++++++++++++++++++++ icu4c/source/test/intltest/numfmtst.h | 1 + 2 files changed, 21 insertions(+) diff --git a/icu4c/source/test/intltest/numfmtst.cpp b/icu4c/source/test/intltest/numfmtst.cpp index 1a047e42990..7531024c262 100644 --- a/icu4c/source/test/intltest/numfmtst.cpp +++ b/icu4c/source/test/intltest/numfmtst.cpp @@ -673,6 +673,7 @@ void NumberFormatTest::runIndexedTest( int32_t index, UBool exec, const char* &n TESTCASE_AUTO(Test12567); TESTCASE_AUTO(Test13056_GroupingSize); TESTCASE_AUTO(Test11648_ExpDecFormatMalPattern); + TESTCASE_AUTO(Test11649_DecFmtCurrencies); TESTCASE_AUTO_END; } @@ -9410,4 +9411,23 @@ void NumberFormatTest::Test11648_ExpDecFormatMalPattern() { assertSuccess("", status); } +void NumberFormatTest::Test11649_DecFmtCurrencies() { + UnicodeString pattern("\\u00a4\\u00a4\\u00a4 0.00"); + pattern = pattern.unescape(); + UErrorCode status = U_ZERO_ERROR; + DecimalFormat fmt(pattern, status); + UChar USD[] = {0x55, 0x53, 0x44, 0x0}; + fmt.setCurrency(USD); + UnicodeString appendTo; + + assertEquals("", "US dollars 12.34", fmt.format(12.34, appendTo)); + UnicodeString topattern; + + assertEquals("", pattern, fmt.toPattern(topattern)); + DecimalFormat fmt2(topattern, status); + fmt2.setCurrency(USD); + + appendTo.remove(); + assertEquals("", "US dollars 12.34", fmt2.format(12.34, appendTo)); +} #endif /* #if !UCONFIG_NO_FORMATTING */ diff --git a/icu4c/source/test/intltest/numfmtst.h b/icu4c/source/test/intltest/numfmtst.h index d675d1461b4..72e2739f048 100644 --- a/icu4c/source/test/intltest/numfmtst.h +++ b/icu4c/source/test/intltest/numfmtst.h @@ -238,6 +238,7 @@ class NumberFormatTest: public CalendarTimeZoneTest { void Test12567(); void Test13056_GroupingSize(); void Test11648_ExpDecFormatMalPattern(); + void Test11649_DecFmtCurrencies(); private: UBool testFormattableAsUFormattable(const char *file, int line, Formattable &f); -- 2.40.0