mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-06 22:15:31 +00:00
ICU-13734 Adding tests for DecimalFormat strict mode handling of flexible whitespace
This commit is contained in:
parent
bcd3f8b68f
commit
2b32778611
3 changed files with 45 additions and 0 deletions
|
@ -242,6 +242,7 @@ void NumberFormatTest::runIndexedTest( int32_t index, UBool exec, const char* &n
|
|||
TESTCASE_AUTO(Test13731_DefaultCurrency);
|
||||
TESTCASE_AUTO(Test20499_CurrencyVisibleDigitsPlural);
|
||||
TESTCASE_AUTO(Test13735_GroupingSizeGetter);
|
||||
TESTCASE_AUTO(Test13734_StrictFlexibleWhitespace);
|
||||
TESTCASE_AUTO_END;
|
||||
}
|
||||
|
||||
|
@ -9726,4 +9727,26 @@ void NumberFormatTest::Test13735_GroupingSizeGetter() {
|
|||
}
|
||||
}
|
||||
|
||||
void NumberFormatTest::Test13734_StrictFlexibleWhitespace() {
|
||||
IcuTestErrorCode status(*this, "Test13734_StrictFlexibleWhitespace");
|
||||
{
|
||||
DecimalFormat df("+0", {"en", status}, status);
|
||||
df.setLenient(FALSE);
|
||||
Formattable result;
|
||||
ParsePosition ppos;
|
||||
df.parse("+ 33", result, ppos);
|
||||
assertEquals("ppos : ", 0, ppos.getIndex());
|
||||
assertEquals("result : ", "0", result.getDecimalNumber(status).data());
|
||||
}
|
||||
{
|
||||
DecimalFormat df("+ 0", {"en", status}, status);
|
||||
df.setLenient(FALSE);
|
||||
Formattable result;
|
||||
ParsePosition ppos;
|
||||
df.parse("+ 33", result, ppos);
|
||||
assertEquals("ppos : ", 0, ppos.getIndex());
|
||||
assertEquals("result : ", "0", result.getDecimalNumber(status).data());
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* #if !UCONFIG_NO_FORMATTING */
|
||||
|
|
|
@ -298,6 +298,7 @@ class NumberFormatTest: public CalendarTimeZoneTest {
|
|||
void Test13731_DefaultCurrency();
|
||||
void Test20499_CurrencyVisibleDigitsPlural();
|
||||
void Test13735_GroupingSizeGetter();
|
||||
void Test13734_StrictFlexibleWhitespace();
|
||||
|
||||
private:
|
||||
UBool testFormattableAsUFormattable(const char *file, int line, Formattable &f);
|
||||
|
|
|
@ -6690,4 +6690,25 @@ public class NumberFormatTest extends TestFmwk {
|
|||
assertEquals("pat #,##0 then enabled: ", 3, df.getGroupingSize());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test13734_StrictFlexibleWhitespace() {
|
||||
DecimalFormatSymbols EN = DecimalFormatSymbols.getInstance(ULocale.ENGLISH);
|
||||
{
|
||||
DecimalFormat df = new DecimalFormat("+0", EN);
|
||||
df.setParseStrict(true);
|
||||
ParsePosition ppos = new ParsePosition(0);
|
||||
Number result = df.parse("+ 33", ppos);
|
||||
assertEquals("ppos: ", 0, ppos.getIndex());
|
||||
assertEquals("result: ", null, result);
|
||||
}
|
||||
{
|
||||
DecimalFormat df = new DecimalFormat("+ 0", EN);
|
||||
df.setParseStrict(true);
|
||||
ParsePosition ppos = new ParsePosition(0);
|
||||
Number result = df.parse("+ 33", ppos);
|
||||
assertEquals("ppos: ", 0, ppos.getIndex());
|
||||
assertEquals("result: ", null, result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue