ICU-13529 Make some changes based on review feedback.

X-SVN-Rev: 40939
This commit is contained in:
George Rhoten 2018-02-16 18:07:32 +00:00
parent ef4ea3ab01
commit d06d12896c
7 changed files with 19 additions and 22 deletions

View file

@ -681,7 +681,7 @@ static void dumpUS(FILE* f, const UnicodeString& us) {
#endif
UBool
NFRuleSet::parse(const UnicodeString& text, ParsePosition& pos, double upperBound, int32_t nonNumericalExecutedRuleMask, Formattable& result) const
NFRuleSet::parse(const UnicodeString& text, ParsePosition& pos, double upperBound, uint32_t nonNumericalExecutedRuleMask, Formattable& result) const
{
// try matching each rule in the rule set against the text being
// parsed. Whichever one matches the most characters is the one

View file

@ -55,7 +55,7 @@ public:
void format(int64_t number, UnicodeString& toAppendTo, int32_t pos, int32_t recursionCount, UErrorCode& status) const;
void format(double number, UnicodeString& toAppendTo, int32_t pos, int32_t recursionCount, UErrorCode& status) const;
UBool parse(const UnicodeString& text, ParsePosition& pos, double upperBound, int32_t nonNumericalExecutedRuleMask, Formattable& result) const;
UBool parse(const UnicodeString& text, ParsePosition& pos, double upperBound, uint32_t nonNumericalExecutedRuleMask, Formattable& result) const;
void appendRules(UnicodeString& result) const; // toString

View file

@ -900,7 +900,7 @@ NFRule::doParse(const UnicodeString& text,
ParsePosition& parsePosition,
UBool isFractionRule,
double upperBound,
int32_t nonNumericalExecutedRuleMask,
uint32_t nonNumericalExecutedRuleMask,
Formattable& resVal) const
{
// internally we operate on a copy of the string being parsed
@ -1161,7 +1161,7 @@ NFRule::matchToDelimiter(const UnicodeString& text,
const UnicodeString& delimiter,
ParsePosition& pp,
const NFSubstitution* sub,
int32_t nonNumericalExecutedRuleMask,
uint32_t nonNumericalExecutedRuleMask,
double upperBound) const
{
UErrorCode status = U_ZERO_ERROR;

View file

@ -74,7 +74,7 @@ public:
ParsePosition& pos,
UBool isFractional,
double upperBound,
int32_t nonNumericalExecutedRuleMask,
uint32_t nonNumericalExecutedRuleMask,
Formattable& result) const;
UBool shouldRollBack(int64_t number) const;
@ -95,7 +95,7 @@ private:
int32_t indexOfAnyRulePrefix() const;
double matchToDelimiter(const UnicodeString& text, int32_t startPos, double baseValue,
const UnicodeString& delimiter, ParsePosition& pp, const NFSubstitution* sub,
int32_t nonNumericalExecutedRuleMask,
uint32_t nonNumericalExecutedRuleMask,
double upperBound) const;
void stripPrefix(UnicodeString& text, const UnicodeString& prefix, ParsePosition& pp) const;

View file

@ -155,7 +155,7 @@ public:
double baseValue,
double upperBound,
UBool lenientParse,
int32_t nonNumericalExecutedRuleMask,
uint32_t nonNumericalExecutedRuleMask,
Formattable& result) const;
virtual double composeRuleValue(double newRuleValue, double oldRuleValue) const {
@ -222,7 +222,7 @@ public:
double baseValue,
double upperBound,
UBool lenientParse,
int32_t nonNumericalExecutedRuleMask,
uint32_t nonNumericalExecutedRuleMask,
Formattable& result) const;
virtual double composeRuleValue(double newRuleValue, double oldRuleValue) const { return newRuleValue + oldRuleValue; }
@ -294,7 +294,7 @@ public:
double baseValue,
double upperBound,
UBool /*lenientParse*/,
int32_t nonNumericalExecutedRuleMask,
uint32_t nonNumericalExecutedRuleMask,
Formattable& result) const;
virtual double composeRuleValue(double newRuleValue, double oldRuleValue) const { return newRuleValue / oldRuleValue; }
@ -692,7 +692,7 @@ NFSubstitution::doParse(const UnicodeString& text,
double baseValue,
double upperBound,
UBool lenientParse,
int32_t nonNumericalExecutedRuleMask,
uint32_t nonNumericalExecutedRuleMask,
Formattable& result) const
{
#ifdef RBNF_DEBUG
@ -935,7 +935,7 @@ ModulusSubstitution::doParse(const UnicodeString& text,
double baseValue,
double upperBound,
UBool lenientParse,
int32_t nonNumericalExecutedRuleMask,
uint32_t nonNumericalExecutedRuleMask,
Formattable& result) const
{
// if this isn't a >>> substitution, we can just use the
@ -1123,7 +1123,7 @@ FractionalPartSubstitution::doParse(const UnicodeString& text,
double baseValue,
double /*upperBound*/,
UBool lenientParse,
int32_t nonNumericalExecutedRuleMask,
uint32_t nonNumericalExecutedRuleMask,
Formattable& resVal) const
{
// if we're not in byDigits mode, we can just use the inherited
@ -1255,7 +1255,7 @@ NumeratorSubstitution::doParse(const UnicodeString& text,
double baseValue,
double upperBound,
UBool /*lenientParse*/,
int32_t nonNumericalExecutedRuleMask,
uint32_t nonNumericalExecutedRuleMask,
Formattable& result) const
{
// we don't have to do anything special to do the parsing here,

View file

@ -191,7 +191,7 @@ public:
double baseValue,
double upperBound,
UBool lenientParse,
int32_t nonNumericalExecutedRuleMask,
uint32_t nonNumericalExecutedRuleMask,
Formattable& result) const;
/**

View file

@ -2287,18 +2287,15 @@ void IntlTestRBNF::TestCompactDecimalFormatStyle() {
void IntlTestRBNF::TestParseFailure() {
UErrorCode status = U_ZERO_ERROR;
RuleBasedNumberFormat rbnf(URBNF_SPELLOUT, Locale::getJapanese(), status);
static const char* testData[][1] = {
{ "\u30FB\u30FB\u30FB\u30FB\u30FB\u30FB\u30FB\u30FB\u30FB\u30FB\u30FB\u30FB\u30FB\u30FB\u30FB\u30FB\u30FB\u30FB\u30FB\u30FB\u30FB\u30FB\u30FB\u30FB" },
{ NULL }
static const UChar* testData[] = {
u"・・・・・・・・・・・・・・・・・・・・・・・・"
};
for (int i = 0; testData[i][0]; ++i) {
const char* spelledNumber = testData[i][0]; // spelled-out number
UnicodeString spelledNumberString = UnicodeString(spelledNumber).unescape();
for (int i = 0; i < UPRV_LENGTHOF(testData); ++i) {
UnicodeString spelledNumberString = UnicodeString(testData[i]).unescape();
Formattable actualNumber;
rbnf.parse(spelledNumberString, actualNumber, status);
if (status != U_INVALID_FORMAT_ERROR) { // I would have expected U_PARSE_ERROR, but NumberFormat::parse gives U_INVALID_FORMAT_ERROR
errln("FAIL: string should be unparseable %s %s", spelledNumber, u_errorName(status));
errln("FAIL: string should be unparseable index=%d %s", i, u_errorName(status));
}
}
}