ICU-11649 Add test for Decimal Format of Currencies

X-SVN-Rev: 41347
This commit is contained in:
Craig Cornelius 2018-05-07 23:40:14 +00:00
parent aeaeb8397b
commit 16472502b5
2 changed files with 21 additions and 0 deletions

View File

@ -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 */

View File

@ -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);