From 2b11611919bafe86ae245194d78ac6e97fdc4e69 Mon Sep 17 00:00:00 2001 From: Travis Keep Date: Tue, 17 Jun 2014 14:24:40 +0000 Subject: [PATCH] ICU-10046 Roubert's review comments. X-SVN-Rev: 35880 --- icu4c/source/i18n/scientificformathelper.cpp | 8 +++--- .../intltest/scientificformathelpertest.cpp | 27 ++++++++++++++----- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/icu4c/source/i18n/scientificformathelper.cpp b/icu4c/source/i18n/scientificformathelper.cpp index ee594f64aaf..6253ca7a536 100644 --- a/icu4c/source/i18n/scientificformathelper.cpp +++ b/icu4c/source/i18n/scientificformathelper.cpp @@ -15,14 +15,12 @@ #include "unicode/uniset.h" #include "decfmtst.h" -#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0])) - U_NAMESPACE_BEGIN -static UChar kSuperscriptDigits[] = {0x2070, 0xB9, 0xB2, 0xB3, 0x2074, 0x2075, 0x2076, 0x2077, 0x2078, 0x2079}; +static const UChar kSuperscriptDigits[] = {0x2070, 0xB9, 0xB2, 0xB3, 0x2074, 0x2075, 0x2076, 0x2077, 0x2078, 0x2079}; -static UChar kSuperscriptPlusSign = 0x207A; -static UChar kSuperscriptMinusSign = 0x207B; +static const UChar kSuperscriptPlusSign = 0x207A; +static const UChar kSuperscriptMinusSign = 0x207B; ScientificFormatHelper::ScientificFormatHelper( const DecimalFormatSymbols &dfs, UErrorCode &status) diff --git a/icu4c/source/test/intltest/scientificformathelpertest.cpp b/icu4c/source/test/intltest/scientificformathelpertest.cpp index 79c9f7d5262..7ca6d2ca021 100644 --- a/icu4c/source/test/intltest/scientificformathelpertest.cpp +++ b/icu4c/source/test/intltest/scientificformathelpertest.cpp @@ -8,8 +8,7 @@ * ******************************************************************************* */ -#include -#include +#include "unicode/utypes.h" #include "intltest.h" @@ -18,17 +17,14 @@ #include "unicode/scientificformathelper.h" #include "unicode/numfmt.h" #include "unicode/decimfmt.h" - -#define LENGTHOF(array) (int32_t)(sizeof(array) / sizeof((array)[0])) +#include "unicode/localpointer.h" class ScientificFormatHelperTest : public IntlTest { public: - ScientificFormatHelperTest() { - } - void runIndexedTest(int32_t index, UBool exec, const char *&name, char *par=0); private: void TestBasic(); + void TestFarsi(); void TestPlusSignInExponentMarkup(); void TestPlusSignInExponentSuperscript(); void TestFixedDecimalMarkup(); @@ -42,6 +38,7 @@ void ScientificFormatHelperTest::runIndexedTest( } TESTCASE_AUTO_BEGIN; TESTCASE_AUTO(TestBasic); + TESTCASE_AUTO(TestFarsi); TESTCASE_AUTO(TestPlusSignInExponentMarkup); TESTCASE_AUTO(TestPlusSignInExponentSuperscript); TESTCASE_AUTO(TestFixedDecimalMarkup); @@ -80,6 +77,22 @@ void ScientificFormatHelperTest::TestBasic() { } } +void ScientificFormatHelperTest::TestFarsi() { + UErrorCode status = U_ZERO_ERROR; + LocalPointer decfmt((DecimalFormat *) NumberFormat::createScientificInstance("fa", status)); + UnicodeString appendTo("String: "); + FieldPositionIterator fpositer; + decfmt->format(1.23456e-78, appendTo, &fpositer, status); + ScientificFormatHelper helper(*decfmt->getDecimalFormatSymbols(), status); + UnicodeString result; + const char *expected = "String: \\u06F1\\u066B\\u06F2\\u06F3\\u06F4\\u06F5\\u06F6\\u00d7\\u06F1\\u06F0\\u200E\\u2212\\u06F7\\u06F8"; + assertEquals( + "insertMarkup", + UnicodeString(expected).unescape(), + helper.insertMarkup(appendTo, fpositer, "", "", result, status)); + assertSuccess("", status); +} + void ScientificFormatHelperTest::TestPlusSignInExponentMarkup() { UErrorCode status = U_ZERO_ERROR; LocalPointer decfmt((DecimalFormat *) NumberFormat::createScientificInstance("en", status)); -- 2.40.0