mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-14 09:21:03 +00:00
ICU-6000 fix for RBNF in ICU4C
X-SVN-Rev: 22845
This commit is contained in:
parent
29af359e59
commit
fb2431bbdd
3 changed files with 38 additions and 2 deletions
|
@ -97,7 +97,11 @@ public:
|
|||
}
|
||||
|
||||
virtual double transformNumber(double number) const {
|
||||
return uprv_floor(number / divisor);
|
||||
if (getRuleSet()) {
|
||||
return uprv_floor(number / divisor);
|
||||
} else {
|
||||
return number/divisor;
|
||||
}
|
||||
}
|
||||
|
||||
virtual double composeRuleValue(double newRuleValue, double /*oldRuleValue*/) const {
|
||||
|
|
|
@ -65,6 +65,7 @@ void IntlTestRBNF::runIndexedTest(int32_t index, UBool exec, const char* &name,
|
|||
TESTCASE(15, TestAllLocales);
|
||||
TESTCASE(16, TestHebrewFraction);
|
||||
TESTCASE(17, TestPortugueseSpellout);
|
||||
TESTCASE(18, TestMultiplierSubstitution);
|
||||
#else
|
||||
TESTCASE(0, TestRBNFDisabled);
|
||||
#endif
|
||||
|
@ -1766,6 +1767,31 @@ IntlTestRBNF::TestAllLocales()
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
IntlTestRBNF::TestMultiplierSubstitution(void) {
|
||||
UnicodeString rules("=#,##0=;1,000,000: <##0.###< million;");
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
UParseError parse_error;
|
||||
RuleBasedNumberFormat *rbnf =
|
||||
new RuleBasedNumberFormat(rules, Locale::getUS(), parse_error, status);
|
||||
if (U_SUCCESS(status)) {
|
||||
UnicodeString res;
|
||||
FieldPosition pos;
|
||||
double n = 1234000.0;
|
||||
rbnf->format(n, res, pos);
|
||||
delete rbnf;
|
||||
|
||||
UnicodeString expected = UNICODE_STRING_SIMPLE("1.234 million");
|
||||
if (expected != res) {
|
||||
UnicodeString msg = "Expected: ";
|
||||
msg.append(expected);
|
||||
msg.append(" but got ");
|
||||
msg.append(res);
|
||||
errln(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
IntlTestRBNF::doTest(RuleBasedNumberFormat* formatter, const char* const testData[][2], UBool testParsing)
|
||||
{
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 1996-2006, International Business Machines Corporation and *
|
||||
* Copyright (C) 1996-2007, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
@ -122,6 +122,12 @@ class IntlTestRBNF : public IntlTest {
|
|||
*/
|
||||
virtual void TestHebrewFraction();
|
||||
|
||||
/**
|
||||
* Regression test, don't truncate
|
||||
* when doing multiplier substitution to a number format rule.
|
||||
*/
|
||||
virtual void TestMultiplierSubstitution();
|
||||
|
||||
protected:
|
||||
virtual void doTest(RuleBasedNumberFormat* formatter, const char* const testData[][2], UBool testParsing);
|
||||
virtual void doLenientParseTest(RuleBasedNumberFormat* formatter, const char* testData[][2]);
|
||||
|
|
Loading…
Add table
Reference in a new issue