ICU-13055 Fix percentage rounding.

X-SVN-Rev: 41340
This commit is contained in:
Norbert Runge 2018-05-07 22:40:41 +00:00
parent cc5fca2744
commit 51f4b85f7c
2 changed files with 16 additions and 0 deletions

View File

@ -665,6 +665,7 @@ void NumberFormatTest::runIndexedTest( int32_t index, UBool exec, const char* &n
TESTCASE_AUTO(Test11646_Equality);
TESTCASE_AUTO(TestParseNaN);
TESTCASE_AUTO(Test11897_LocalizedPatternSeparator);
TESTCASE_AUTO(Test13055_PercentageRounding);
TESTCASE_AUTO(Test11839);
TESTCASE_AUTO(Test10354);
TESTCASE_AUTO(Test11645_ApplyPatternEquality);
@ -9219,6 +9220,20 @@ void NumberFormatTest::Test11897_LocalizedPatternSeparator() {
assertEquals("should apply the localized pattern", df.getNegativePrefix(result.remove()), "d");
}
void NumberFormatTest::Test13055_PercentageRounding() {
IcuTestErrorCode status(*this, "PercentageRounding");
UnicodeString actual;
NumberFormat *pFormat = NumberFormat::createPercentInstance("en_US", status);
if (U_FAILURE(status)) {
dataerrln("Failure creating DecimalFormat %s", u_errorName(status));
return;
}
pFormat->setMaximumFractionDigits(0);
pFormat->setRoundingMode(DecimalFormat::kRoundHalfEven);
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

View File

@ -230,6 +230,7 @@ class NumberFormatTest: public CalendarTimeZoneTest {
void Test11646_Equality();
void TestParseNaN();
void Test11897_LocalizedPatternSeparator();
void Test13055_PercentageRounding();
void Test11839();
void Test10354();
void Test11645_ApplyPatternEquality();