mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-08 06:53:45 +00:00
ICU-4985 currency rounding/fractions no longer ignored
X-SVN-Rev: 19604
This commit is contained in:
parent
abc39e0da4
commit
de8c6c14f3
3 changed files with 35 additions and 2 deletions
|
@ -335,6 +335,12 @@ DecimalFormat::construct(UErrorCode& status,
|
|||
}
|
||||
|
||||
applyPattern(*pattern, FALSE /*not localized*/,parseErr, status);
|
||||
|
||||
// If it was a currency format, apply the appropriate rounding by
|
||||
// resetting the currency. NOTE: this copies fCurrency on top of itself.
|
||||
if (fIsCurrencyFormat) {
|
||||
setCurrency(getCurrency(), status);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -646,7 +646,8 @@ static const char* testCases[][2]= {
|
|||
{"eu_ES_PREEURO", "\\u20A7 1.150" },
|
||||
{"gl_ES_PREEURO", "\\u20A7 1.150" },
|
||||
{"it_IT_PREEURO", "\\u20A4 1.150" },
|
||||
{"pt_PT_PREEURO", "1,150$50 Esc."}
|
||||
{"pt_PT_PREEURO", "1,150$50 Esc."},
|
||||
{"en_US@currency=JPY", "\\u00A51,150"}
|
||||
};
|
||||
/**
|
||||
* Test localized currency patterns.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/***********************************************************************
|
||||
* COPYRIGHT:
|
||||
* Copyright (c) 1997-2005, International Business Machines Corporation
|
||||
* Copyright (c) 1997-2006, International Business Machines Corporation
|
||||
* and others. All Rights Reserved.
|
||||
***********************************************************************/
|
||||
|
||||
|
@ -19,6 +19,7 @@
|
|||
#include "unicode/resbund.h"
|
||||
#include "unicode/calendar.h"
|
||||
#include "unicode/datefmt.h"
|
||||
#include "unicode/ucurr.h"
|
||||
#include "putilimp.h"
|
||||
|
||||
class MyNumberFormatTest : public NumberFormat
|
||||
|
@ -1683,6 +1684,20 @@ void NumberFormatRegressionTest::Test4122840(void)
|
|||
DecimalFormat *fmt2 = new DecimalFormat(buf, *symbols, status);
|
||||
failure(status, "new DecimalFormat");
|
||||
|
||||
// Get the currency so we can set the rounding and fraction
|
||||
UChar intlCurrencySymbol[4];
|
||||
(symbols->getSymbol(DecimalFormatSymbols::kIntlCurrencySymbol)).extract(intlCurrencySymbol, 4, status);
|
||||
double rounding = ucurr_getRoundingIncrement(intlCurrencySymbol, &status);
|
||||
int32_t frac = ucurr_getDefaultFractionDigits(intlCurrencySymbol, &status);
|
||||
if (U_SUCCESS(status)) {
|
||||
fmt2->setRoundingIncrement(rounding);
|
||||
fmt2->setMinimumFractionDigits(frac);
|
||||
fmt2->setMaximumFractionDigits(frac);
|
||||
}
|
||||
else {
|
||||
failure(status, "Fetching currency rounding/fractions");
|
||||
}
|
||||
|
||||
UnicodeString result2;
|
||||
fmt2->format(1.111, result2, pos);
|
||||
|
||||
|
@ -2385,6 +2400,17 @@ void NumberFormatRegressionTest::Test4212072(void) {
|
|||
if (U_FAILURE(status)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Make sure we set the currency attributes appropriately
|
||||
if (j == 1) { // Currency format
|
||||
f2.setCurrency(f2.getCurrency(), status);
|
||||
}
|
||||
failure(status,
|
||||
UnicodeString("setCurrency() for (") + pat + ")", avail[i]);
|
||||
if (U_FAILURE(status)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (*df != f2) {
|
||||
UnicodeString l, p;
|
||||
errln(UnicodeString("FAIL: ") + type[j] + avail[i].getDisplayName(l) +
|
||||
|
|
Loading…
Add table
Reference in a new issue