ICU-11713 Ensure that what getGroupingSize() returns doesn't change just because grouping is enabled.

X-SVN-Rev: 37472
This commit is contained in:
Travis Keep 2015-05-28 22:45:45 +00:00
parent 762078d2f1
commit 2cbff1ac8b
2 changed files with 10 additions and 2 deletions
icu4c/source
i18n
test/intltest

View file

@ -4128,7 +4128,7 @@ void DecimalFormat::setExponentSignAlwaysShown(UBool expSignAlways) {
int32_t
DecimalFormat::getGroupingSize() const
{
return isGroupingUsed() ? fGroupingSize : 0;
return fGroupingSize;
}
//------------------------------------------------------------------------------
@ -4985,6 +4985,9 @@ DecimalFormat::applyPatternWithoutExpandAffix(const UnicodeString& pattern,
if (out.fGroupingUsed) {
fGroupingSize = out.fGroupingSize;
fGroupingSize2 = out.fGroupingSize2;
} else {
fGroupingSize = 0;
fGroupingSize2 = 0;
}
setMultiplier(out.fMultiplier);
fDecimalSeparatorAlwaysShown = out.fDecimalSeparatorAlwaysShown;

View file

@ -1,6 +1,6 @@
/********************************************************************
* COPYRIGHT:
* Copyright (c) 1997-2014, International Business Machines Corporation and
* Copyright (c) 1997-2015, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************/
@ -113,6 +113,10 @@ void IntlTestDecimalFormatAPI::testAPI(/*char *par*/)
if (noGrouping.getGroupingSize() != 0) {
errln("Grouping size should be 0 for no grouping.");
}
noGrouping.setGroupingUsed(TRUE);
if (noGrouping.getGroupingSize() != 0) {
errln("Grouping size should still be 0.");
}
// end bug 10864
status = U_ZERO_ERROR;
@ -828,6 +832,7 @@ void IntlTestDecimalFormatAPI::TestBadFastpath() {
fmt.remove();
assertEquals("Format 1234", "1234", df->format(1234, fmt));
df->setGroupingUsed(TRUE);
df->setGroupingSize(3);
fmt.remove();
assertEquals("Format 1234 w/ grouping", "1,234", df->format(1234, fmt));
}