mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-13 17:01:16 +00:00
ICU-10997 Port test case for 10997 currency formatting to icu4c
This commit is contained in:
parent
5a75375222
commit
0912b85193
2 changed files with 26 additions and 1 deletions
icu4c/source/test/intltest
|
@ -248,6 +248,7 @@ void NumberFormatTest::runIndexedTest( int32_t index, UBool exec, const char* &n
|
|||
TESTCASE_AUTO(Test21134_ToNumberFormatter);
|
||||
TESTCASE_AUTO(Test13733_StrictAndLenient);
|
||||
TESTCASE_AUTO(Test21232_ParseTimeout);
|
||||
TESTCASE_AUTO(Test10997_FormatCurrency);
|
||||
TESTCASE_AUTO_END;
|
||||
}
|
||||
|
||||
|
@ -9183,7 +9184,7 @@ void NumberFormatTest::Test13055_PercentageRounding() {
|
|||
pFormat->format(2.155, actual);
|
||||
assertEquals("Should round percent toward even number", "216%", actual);
|
||||
}
|
||||
|
||||
|
||||
void NumberFormatTest::Test11839() {
|
||||
IcuTestErrorCode errorCode(*this, "Test11839");
|
||||
// Ticket #11839: DecimalFormat does not respect custom plus sign
|
||||
|
@ -10063,4 +10064,27 @@ void NumberFormatTest::Test21232_ParseTimeout() {
|
|||
// Should not hang
|
||||
}
|
||||
|
||||
void NumberFormatTest::Test10997_FormatCurrency() {
|
||||
IcuTestErrorCode status(*this, "Test10997_FormatCurrency");
|
||||
|
||||
UErrorCode error = U_ZERO_ERROR;
|
||||
NumberFormat* fmt = NumberFormat::createCurrencyInstance(Locale::getUS(), error);
|
||||
fmt->setMinimumFractionDigits(4);
|
||||
fmt->setMaximumFractionDigits(4);
|
||||
|
||||
FieldPosition fp;
|
||||
|
||||
UnicodeString str;
|
||||
Formattable usdAmnt(new CurrencyAmount(123.45, u"USD", status));
|
||||
fmt->format(usdAmnt, str, fp, status);
|
||||
assertEquals("minFrac 4 should be respected in default currency", u"$123.4500", str);
|
||||
|
||||
UnicodeString str2;
|
||||
Formattable eurAmnt(new CurrencyAmount(123.45, u"EUR", status));
|
||||
fmt->format(eurAmnt, str2, fp, status);
|
||||
assertEquals("minFrac 4 should be respected in different currency", u"€123.4500", str2);
|
||||
|
||||
delete fmt;
|
||||
}
|
||||
|
||||
#endif /* #if !UCONFIG_NO_FORMATTING */
|
||||
|
|
|
@ -304,6 +304,7 @@ class NumberFormatTest: public CalendarTimeZoneTest {
|
|||
void Test21134_ToNumberFormatter();
|
||||
void Test13733_StrictAndLenient();
|
||||
void Test21232_ParseTimeout();
|
||||
void Test10997_FormatCurrency();
|
||||
|
||||
private:
|
||||
UBool testFormattableAsUFormattable(const char *file, int line, Formattable &f);
|
||||
|
|
Loading…
Add table
Reference in a new issue