From 2cbff1ac8bcbadce2847dfc4c407252ac018b339 Mon Sep 17 00:00:00 2001 From: Travis Keep Date: Thu, 28 May 2015 22:45:45 +0000 Subject: [PATCH] ICU-11713 Ensure that what getGroupingSize() returns doesn't change just because grouping is enabled. X-SVN-Rev: 37472 --- icu4c/source/i18n/decimfmt.cpp | 5 ++++- icu4c/source/test/intltest/dcfmapts.cpp | 7 ++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/icu4c/source/i18n/decimfmt.cpp b/icu4c/source/i18n/decimfmt.cpp index 0478c07ccc4..c003932415e 100644 --- a/icu4c/source/i18n/decimfmt.cpp +++ b/icu4c/source/i18n/decimfmt.cpp @@ -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; diff --git a/icu4c/source/test/intltest/dcfmapts.cpp b/icu4c/source/test/intltest/dcfmapts.cpp index 9e66f3de986..c7dba5ca12c 100644 --- a/icu4c/source/test/intltest/dcfmapts.cpp +++ b/icu4c/source/test/intltest/dcfmapts.cpp @@ -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)); }