ICU-13777 Adding tests to make sure currency long names round-trip through parsing.

X-SVN-Rev: 41446
This commit is contained in:
Shane Carr 2018-05-24 04:16:35 +00:00
parent 68b2d740d6
commit 58b7fe2e32
3 changed files with 17 additions and 0 deletions

View file

@ -213,6 +213,7 @@ void NumberFormatTest::runIndexedTest( int32_t index, UBool exec, const char* &n
TESTCASE_AUTO(Test11020_RoundingInScientificNotation);
TESTCASE_AUTO(Test11640_TripleCurrencySymbol);
TESTCASE_AUTO(Test13763_FieldPositionIteratorOffset);
TESTCASE_AUTO(Test13777_ParseLongNameNonCurrencyMode);
TESTCASE_AUTO_END;
}
@ -9067,4 +9068,12 @@ void NumberFormatTest::Test13763_FieldPositionIteratorOffset() {
expectPositions(fpi, expected, tupleCount, result);
}
void NumberFormatTest::Test13777_ParseLongNameNonCurrencyMode() {
IcuTestErrorCode status(*this, "Test13777_ParseLongNameNonCurrencyMode");
LocalPointer<NumberFormat> df(
NumberFormat::createInstance("en-us", UNumberFormatStyle::UNUM_CURRENCY_PLURAL, status));
expect2(*df, 1.5, u"1.50 US dollars");
}
#endif /* #if !UCONFIG_NO_FORMATTING */

View file

@ -277,6 +277,7 @@ class NumberFormatTest: public CalendarTimeZoneTest {
void Test11020_RoundingInScientificNotation();
void Test11640_TripleCurrencySymbol();
void Test13763_FieldPositionIteratorOffset();
void Test13777_ParseLongNameNonCurrencyMode();
private:
UBool testFormattableAsUFormattable(const char *file, int line, Formattable &f);

View file

@ -6154,4 +6154,11 @@ public class NumberFormatTest extends TestFmwk {
df.applyLocalizedPattern("c0!d0"); // should not throw
assertEquals("should apply the localized pattern", df.getNegativePrefix(), "d");
}
@Test
public void test13777_ParseLongNameNonCurrencyMode() {
// Currency long name should round-trip even when non-currency parsing is used.
NumberFormat df = NumberFormat.getInstance(ULocale.US, NumberFormat.PLURALCURRENCYSTYLE);
expect2(df, 1.5, "1.50 US dollars");
}
}