ICU-8407 Use a case-insensitive compare when matching the exponent symbol.
X-SVN-Rev: 29551
This commit is contained in:
parent
42a1e6f4a4
commit
206c946267
@ -1961,7 +1961,7 @@ UBool DecimalFormat::subparse(const UnicodeString& text,
|
||||
else {
|
||||
const UnicodeString *tmp;
|
||||
tmp = &getConstSymbol(DecimalFormatSymbols::kExponentialSymbol);
|
||||
if (!text.compare(position, tmp->length(), *tmp)) // error code is set below if !sawDigit
|
||||
if (!text.caseCompare(position, tmp->length(), *tmp, U_FOLD_CASE_DEFAULT)) // error code is set below if !sawDigit
|
||||
{
|
||||
// Parse sign, if present
|
||||
int32_t pos = position + tmp->length();
|
||||
|
@ -1,6 +1,6 @@
|
||||
/********************************************************************
|
||||
* COPYRIGHT:
|
||||
* Copyright (c) 1997-2010, International Business Machines Corporation and
|
||||
* Copyright (c) 1997-2011, International Business Machines Corporation and
|
||||
* others. All Rights Reserved.
|
||||
********************************************************************/
|
||||
/********************************************************************************
|
||||
@ -1306,6 +1306,15 @@ static void TestInt64Format() {
|
||||
} else if (!withinErr(valDouble, doubleBig, 1e-15)) {
|
||||
log_err("parseDouble returned incorrect value, got: %g\n", valDouble);
|
||||
}
|
||||
}
|
||||
|
||||
u_uastrcpy(result, "5.06e-27");
|
||||
parsepos = 0;
|
||||
valDouble = unum_parseDouble(fmt, result, u_strlen(result), &parsepos, &status);
|
||||
if (U_FAILURE(status)) {
|
||||
log_err("parseDouble() returned error: %s\n", myErrorName(status));
|
||||
} else if (!withinErr(valDouble, 5.06e-27, 1e-15)) {
|
||||
log_err("parseDouble() returned incorrect value, got: %g\n", valDouble);
|
||||
}
|
||||
}
|
||||
unum_close(fmt);
|
||||
|
@ -6203,24 +6203,23 @@ void NumberFormatTest::TestExponentParse() {
|
||||
dataerrln((UnicodeString)"ERROR: Could not create DecimalFormatSymbols (Default)");
|
||||
return;
|
||||
}
|
||||
symbols->setSymbol(DecimalFormatSymbols::kExponentialSymbol,"e");
|
||||
|
||||
|
||||
// create format instance
|
||||
status = U_ZERO_ERROR;
|
||||
DecimalFormat fmt("#####", symbols, status);
|
||||
if(U_FAILURE(status)) {
|
||||
errln((UnicodeString)"ERROR: Could not create DecimalFormat (pattern, symbols*)");
|
||||
}
|
||||
|
||||
|
||||
// parse the text
|
||||
fmt.parse("123E4", result, parsePos);
|
||||
fmt.parse("5.06e-27", result, parsePos);
|
||||
if(result.getType() != Formattable::kDouble &&
|
||||
result.getDouble() != (double)123 &&
|
||||
parsePos.getIndex() != 3
|
||||
result.getDouble() != 5.06E-27 &&
|
||||
parsePos.getIndex() != 8
|
||||
)
|
||||
{
|
||||
errln("ERROR: parse failed - expected 123.0, 3 - returned %d, %i",
|
||||
result.getDouble(), parsePos.getIndex());
|
||||
errln("ERROR: parse failed - expected 5.06E-27, 8 - returned %d, %i",
|
||||
result.getDouble(), parsePos.getIndex());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
/***********************************************************************
|
||||
* COPYRIGHT:
|
||||
* Copyright (c) 1997-2009, International Business Machines Corporation
|
||||
* Copyright (c) 1997-2011, International Business Machines Corporation
|
||||
* and others. All Rights Reserved.
|
||||
***********************************************************************/
|
||||
|
||||
@ -93,6 +93,12 @@ IntlTestNumberFormat::testLocale(/* char* par, */const Locale& locale, const Uni
|
||||
fStatus = U_ZERO_ERROR;
|
||||
fFormat = NumberFormat::createPercentInstance(locale, fStatus);
|
||||
testFormat(/* par */);
|
||||
|
||||
name = "Scientific test";
|
||||
logln((UnicodeString)name + " (" + localeName + ")");
|
||||
fStatus = U_ZERO_ERROR;
|
||||
fFormat = NumberFormat::createScientificInstance(locale, fStatus);
|
||||
testFormat(/* par */);
|
||||
}
|
||||
|
||||
double IntlTestNumberFormat::randDouble()
|
||||
@ -210,6 +216,8 @@ IntlTestNumberFormat::testFormat(/* char* par */)
|
||||
tryIt(1.234e-50);
|
||||
tryIt(9.99999999999996);
|
||||
tryIt(9.999999999999996);
|
||||
|
||||
tryIt(5.06e-27);
|
||||
|
||||
tryIt((int32_t)INT32_MIN);
|
||||
tryIt((int32_t)INT32_MAX);
|
||||
|
Loading…
Reference in New Issue
Block a user