From cee964917ad731d21bfaf64ae655b8b334b1f3fc Mon Sep 17 00:00:00 2001 From: Markus Scherer Date: Mon, 7 May 2018 22:32:05 +0000 Subject: [PATCH] ICU-11839 port NumberFormatTest.Test11839 to C++ X-SVN-Rev: 41337 --- icu4c/source/test/intltest/numfmtst.cpp | 18 ++++++++++++++++++ icu4c/source/test/intltest/numfmtst.h | 1 + 2 files changed, 19 insertions(+) diff --git a/icu4c/source/test/intltest/numfmtst.cpp b/icu4c/source/test/intltest/numfmtst.cpp index cc4478aba6a..1231af54094 100644 --- a/icu4c/source/test/intltest/numfmtst.cpp +++ b/icu4c/source/test/intltest/numfmtst.cpp @@ -663,6 +663,7 @@ void NumberFormatTest::runIndexedTest( int32_t index, UBool exec, const char* &n TESTCASE_AUTO(TestFastFormatInt32); TESTCASE_AUTO(TestParseNaN); TESTCASE_AUTO(Test11897_LocalizedPatternSeparator); + TESTCASE_AUTO(Test11839); TESTCASE_AUTO(Test10354); TESTCASE_AUTO(Test11645_ApplyPatternEquality); TESTCASE_AUTO(Test11648_ExpDecFormatMalPattern); @@ -9163,6 +9164,23 @@ void NumberFormatTest::Test11897_LocalizedPatternSeparator() { assertEquals("should apply the localized pattern", df.getNegativePrefix(result.remove()), "d"); } +void NumberFormatTest::Test11839() { + IcuTestErrorCode errorCode(*this, "Test11839"); + // Ticket #11839: DecimalFormat does not respect custom plus sign + LocalPointer dfs(new DecimalFormatSymbols(Locale::getEnglish(), errorCode)); + dfs->setSymbol(DecimalFormatSymbols::kMinusSignSymbol, u"a∸"); + dfs->setSymbol(DecimalFormatSymbols::kPlusSignSymbol, u"b∔"); // ∔ U+2214 DOT PLUS + DecimalFormat df(u"0.00+;0.00-", dfs.orphan(), errorCode); + UnicodeString result; + df.format(-1.234, result, errorCode); + assertEquals("Locale-specific minus sign should be used", u"1.23a∸", result); + df.format(1.234, result.remove(), errorCode); + assertEquals("Locale-specific plus sign should be used", u"1.23b∔", result); + // Test round-trip with parse + expect2(df, -456, u"456.00a∸"); + expect2(df, 456, u"456.00b∔"); +} + void NumberFormatTest::Test10354() { IcuTestErrorCode errorCode(*this, "Test10354"); // Ticket #10354: invalid FieldPositionIterator when formatting with empty NaN diff --git a/icu4c/source/test/intltest/numfmtst.h b/icu4c/source/test/intltest/numfmtst.h index 513c9c97039..68db4530a42 100644 --- a/icu4c/source/test/intltest/numfmtst.h +++ b/icu4c/source/test/intltest/numfmtst.h @@ -228,6 +228,7 @@ class NumberFormatTest: public CalendarTimeZoneTest { void TestFastFormatInt32(); void TestParseNaN(); void Test11897_LocalizedPatternSeparator(); + void Test11839(); void Test10354(); void Test11645_ApplyPatternEquality(); void Test11648_ExpDecFormatMalPattern(); -- 2.40.0