ICU-10354 port NumberFormatTest.Test10354 to C++

X-SVN-Rev: 41332
This commit is contained in:
Markus Scherer 2018-05-07 21:21:18 +00:00
parent 1b4baff50e
commit 5cf4bdf6db
2 changed files with 16 additions and 0 deletions

View File

@ -662,6 +662,7 @@ void NumberFormatTest::runIndexedTest( int32_t index, UBool exec, const char* &n
TESTCASE_AUTO(TestFastFormatInt32); TESTCASE_AUTO(TestFastFormatInt32);
TESTCASE_AUTO(TestParseNaN); TESTCASE_AUTO(TestParseNaN);
TESTCASE_AUTO(Test11897_LocalizedPatternSeparator); TESTCASE_AUTO(Test11897_LocalizedPatternSeparator);
TESTCASE_AUTO(Test10354);
TESTCASE_AUTO_END; TESTCASE_AUTO_END;
} }
@ -9148,4 +9149,18 @@ void NumberFormatTest::Test11897_LocalizedPatternSeparator() {
assertEquals("should apply the localized pattern", df.getNegativePrefix(result.remove()), "d"); assertEquals("should apply the localized pattern", df.getNegativePrefix(result.remove()), "d");
} }
void NumberFormatTest::Test10354() {
IcuTestErrorCode errorCode(*this, "Test10354");
// Ticket #10354: invalid FieldPositionIterator when formatting with empty NaN
DecimalFormatSymbols dfs(errorCode);
UnicodeString empty;
dfs.setSymbol(DecimalFormatSymbols::kNaNSymbol, empty);
DecimalFormat df(errorCode);
df.setDecimalFormatSymbols(dfs);
UnicodeString result;
FieldPositionIterator positions;
df.format(NAN, result, &positions, errorCode);
errorCode.logIfFailureAndReset("DecimalFormat.format(NAN, FieldPositionIterator) failed");
}
#endif /* #if !UCONFIG_NO_FORMATTING */ #endif /* #if !UCONFIG_NO_FORMATTING */

View File

@ -227,6 +227,7 @@ class NumberFormatTest: public CalendarTimeZoneTest {
void TestFastFormatInt32(); void TestFastFormatInt32();
void TestParseNaN(); void TestParseNaN();
void Test11897_LocalizedPatternSeparator(); void Test11897_LocalizedPatternSeparator();
void Test10354();
private: private:
UBool testFormattableAsUFormattable(const char *file, int line, Formattable &f); UBool testFormattableAsUFormattable(const char *file, int line, Formattable &f);