mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-21 12:40:02 +00:00
ICU-9936 Decimal Format, auto-enable SignificantDigitsUsed when setting significant digits.
X-SVN-Rev: 33833
This commit is contained in:
parent
7322ddac17
commit
5ea9cb88a5
3 changed files with 41 additions and 0 deletions
|
@ -5225,6 +5225,7 @@ void DecimalFormat::setMinimumSignificantDigits(int32_t min) {
|
|||
int32_t max = _max(fMaxSignificantDigits, min);
|
||||
fMinSignificantDigits = min;
|
||||
fMaxSignificantDigits = max;
|
||||
fUseSignificantDigits = TRUE;
|
||||
#if UCONFIG_FORMAT_FASTPATHS_49
|
||||
handleChanged();
|
||||
#endif
|
||||
|
@ -5239,6 +5240,7 @@ void DecimalFormat::setMaximumSignificantDigits(int32_t max) {
|
|||
int32_t min = _min(fMinSignificantDigits, max);
|
||||
fMinSignificantDigits = min;
|
||||
fMaxSignificantDigits = max;
|
||||
fUseSignificantDigits = TRUE;
|
||||
#if UCONFIG_FORMAT_FASTPATHS_49
|
||||
handleChanged();
|
||||
#endif
|
||||
|
|
|
@ -123,6 +123,7 @@ void NumberFormatTest::runIndexedTest( int32_t index, UBool exec, const char* &n
|
|||
TESTCASE_AUTO(TestSignificantDigits);
|
||||
TESTCASE_AUTO(TestShowZero);
|
||||
TESTCASE_AUTO(TestCompatibleCurrencies);
|
||||
TESTCASE_AUTO(TestBug9936);
|
||||
TESTCASE_AUTO_END;
|
||||
}
|
||||
|
||||
|
@ -6793,4 +6794,40 @@ void NumberFormatTest::TestShowZero() {
|
|||
}
|
||||
}
|
||||
|
||||
void NumberFormatTest::TestBug9936() {
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
Locale locale("en_US");
|
||||
LocalPointer<DecimalFormat> numberFormat(static_cast<DecimalFormat*>(
|
||||
NumberFormat::createInstance(locale, status)));
|
||||
if (U_FAILURE(status)) {
|
||||
errln("File %s, Line %d: status = %s.\n", __FILE__, __LINE__, u_errorName(status));
|
||||
return;
|
||||
}
|
||||
|
||||
if (numberFormat->areSignificantDigitsUsed() == TRUE) {
|
||||
errln("File %s, Line %d: areSignificantDigitsUsed() was TRUE, expected FALSE.\n", __FILE__, __LINE__);
|
||||
}
|
||||
numberFormat->setSignificantDigitsUsed(TRUE);
|
||||
if (numberFormat->areSignificantDigitsUsed() == FALSE) {
|
||||
errln("File %s, Line %d: areSignificantDigitsUsed() was FALSE, expected TRUE.\n", __FILE__, __LINE__);
|
||||
}
|
||||
|
||||
numberFormat->setSignificantDigitsUsed(FALSE);
|
||||
if (numberFormat->areSignificantDigitsUsed() == TRUE) {
|
||||
errln("File %s, Line %d: areSignificantDigitsUsed() was TRUE, expected FALSE.\n", __FILE__, __LINE__);
|
||||
}
|
||||
|
||||
numberFormat->setMinimumSignificantDigits(3);
|
||||
if (numberFormat->areSignificantDigitsUsed() == FALSE) {
|
||||
errln("File %s, Line %d: areSignificantDigitsUsed() was FALSE, expected TRUE.\n", __FILE__, __LINE__);
|
||||
}
|
||||
|
||||
numberFormat->setSignificantDigitsUsed(FALSE);
|
||||
numberFormat->setMaximumSignificantDigits(6);
|
||||
if (numberFormat->areSignificantDigitsUsed() == FALSE) {
|
||||
errln("File %s, Line %d: areSignificantDigitsUsed() was FALSE, expected TRUE.\n", __FILE__, __LINE__);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif /* #if !UCONFIG_NO_FORMATTING */
|
||||
|
|
|
@ -166,6 +166,8 @@ class NumberFormatTest: public CalendarTimeZoneTest {
|
|||
void TestShowZero();
|
||||
|
||||
void TestCompatibleCurrencies();
|
||||
void TestBug9936();
|
||||
|
||||
private:
|
||||
void expectParseCurrency(const NumberFormat &fmt, const UChar* currency, const char *text);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue