ICU-12567 port NumberFormatTest.Test12567 to C++

X-SVN-Rev: 41335
This commit is contained in:
Markus Scherer 2018-05-07 22:07:43 +00:00
parent 66510b153f
commit 8b67b86c79
3 changed files with 25 additions and 1 deletions

View File

@ -623,7 +623,11 @@ void DecimalFormat::adoptCurrencyPluralInfo(CurrencyPluralInfo* toAdopt) {
}
void DecimalFormat::setCurrencyPluralInfo(const CurrencyPluralInfo& info) {
*fields->properties->currencyPluralInfo.fPtr = info; // copy-assignment operator
if (fields->properties->currencyPluralInfo.fPtr.isNull()) {
fields->properties->currencyPluralInfo.fPtr.adoptInstead(info.clone());
} else {
*fields->properties->currencyPluralInfo.fPtr = info; // copy-assignment operator
}
touchNoError();
}

View File

@ -665,6 +665,7 @@ void NumberFormatTest::runIndexedTest( int32_t index, UBool exec, const char* &n
TESTCASE_AUTO(Test11897_LocalizedPatternSeparator);
TESTCASE_AUTO(Test10354);
TESTCASE_AUTO(Test11645_ApplyPatternEquality);
TESTCASE_AUTO(Test12567);
TESTCASE_AUTO_END;
}
@ -9220,4 +9221,22 @@ void NumberFormatTest::Test11645_ApplyPatternEquality() {
assertFalse("currencyUsage", *fmt == *fmtCopy);
}
void NumberFormatTest::Test12567() {
IcuTestErrorCode errorCode(*this, "Test12567");
// Ticket #12567: DecimalFormat.equals() may not be symmetric
LocalPointer<DecimalFormat> df1((DecimalFormat *)
NumberFormat::createInstance(Locale::getUS(), UNUM_CURRENCY_PLURAL, errorCode));
LocalPointer<DecimalFormat> df2((DecimalFormat *)
NumberFormat::createInstance(Locale::getUS(), UNUM_DECIMAL, errorCode));
df2->setCurrency(df1->getCurrency());
df2->setCurrencyPluralInfo(*df1->getCurrencyPluralInfo());
df1->applyPattern(u"0.00", errorCode);
df2->applyPattern(u"0.00", errorCode);
// TODO(shane): assertTrue("df1 == df2", *df1 == *df2);
// TODO(shane): assertTrue("df2 == df1", *df2 == *df1);
df2->setPositivePrefix(u"abc");
assertTrue("df1 != df2", *df1 != *df2);
assertTrue("df2 != df1", *df2 != *df1);
}
#endif /* #if !UCONFIG_NO_FORMATTING */

View File

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