diff --git a/icu4c/source/test/intltest/numfmtst.cpp b/icu4c/source/test/intltest/numfmtst.cpp index b1ea42e776..b0ecbfec29 100644 --- a/icu4c/source/test/intltest/numfmtst.cpp +++ b/icu4c/source/test/intltest/numfmtst.cpp @@ -108,6 +108,7 @@ void NumberFormatTest::runIndexedTest( int32_t index, UBool exec, const char* &n CASE(45,TestFormatAttributes); CASE(46,TestFieldPositionIterator); CASE(47,TestDecimal); + CASE(48,TestCurrencyFractionDigits); default: name = ""; break; } } @@ -6116,4 +6117,26 @@ void NumberFormatTest::TestDecimal() { } +void NumberFormatTest::TestCurrencyFractionDigits() { + UErrorCode status = U_ZERO_ERROR; + UnicodeString text1, text2; + double value = 99.12345; + + // Create currenct instance + NumberFormat* fmt = NumberFormat::createCurrencyInstance("ja_JP", status); + ASSERT_SUCCESS(status); + fmt->format(value, text1); + + // Reset the same currency and format the test value again + fmt->setCurrency(fmt->getCurrency(), status); + ASSERT_SUCCESS(status); + fmt->format(value, text2); + + if (text1 != text2) { + errln((UnicodeString)"NumberFormat::format() should return the same result - text1=" + + text1 + " text2=" + text2); + } + delete fmt; +} + #endif /* #if !UCONFIG_NO_FORMATTING */ diff --git a/icu4c/source/test/intltest/numfmtst.h b/icu4c/source/test/intltest/numfmtst.h index 8be28aa898..b7f761a9b9 100644 --- a/icu4c/source/test/intltest/numfmtst.h +++ b/icu4c/source/test/intltest/numfmtst.h @@ -146,6 +146,7 @@ class NumberFormatTest: public CalendarTimeZoneTest { void TestFieldPositionIterator(); void TestDecimal(); + void TestCurrencyFractionDigits(); private: