]> granicus.if.org Git - icu/commitdiff
ICU-11739 Adding ICU4C test for parse long currency.
authorShane Carr <shane@unicode.org>
Mon, 7 May 2018 21:47:09 +0000 (21:47 +0000)
committerShane Carr <shane@unicode.org>
Mon, 7 May 2018 21:47:09 +0000 (21:47 +0000)
X-SVN-Rev: 41334

icu4c/source/test/intltest/numfmtst.cpp
icu4c/source/test/intltest/numfmtst.h

index 30ef7e6dac0e72c3d5a0f265192af0944facdd50..754679b6d7e6b7899f77b0f30a3af0d25d578631 100644 (file)
@@ -647,6 +647,7 @@ void NumberFormatTest::runIndexedTest( int32_t index, UBool exec, const char* &n
   TESTCASE_AUTO(TestFractionalDigitsForCurrency);
   TESTCASE_AUTO(TestFormatCurrencyPlural);
   TESTCASE_AUTO(Test11868);
+  TESTCASE_AUTO(Test11739_ParseLongCurrency);
   TESTCASE_AUTO(Test10727_RoundingZero);
   TESTCASE_AUTO(Test11376_getAndSetPositivePrefix);
   TESTCASE_AUTO(Test11475_signRecognition);
@@ -8748,6 +8749,17 @@ void NumberFormatTest::Test10727_RoundingZero() {
     assertTrue("", dq.isNegative());
 }
 
+void NumberFormatTest::Test11739_ParseLongCurrency() {
+    IcuTestErrorCode status(*this, "Test11739_ParseLongCurrency");
+    LocalPointer<NumberFormat> nf(NumberFormat::createCurrencyInstance("sr_BA", status));
+    ((DecimalFormat*) nf.getAlias())->applyPattern(u"#,##0.0 ¤¤¤", status);
+    ParsePosition ppos(0);
+    CurrencyAmount* result = nf->parseCurrency(u"1.500 амерички долар", ppos);
+    assertEquals("Should parse to 1500 USD", -1, ppos.getErrorIndex());
+    assertEquals("Should parse to 1500 USD", 1500LL, result->getNumber().getInt64(status));
+    assertEquals("Should parse to 1500 USD", u"USD", result->getISOCurrency());
+}
+
 void NumberFormatTest::Test11376_getAndSetPositivePrefix() {
     {
         const UChar USD[] = {0x55, 0x53, 0x44, 0x0};
index 45c68d030e6a701e91b885a748ce5354060ed744..af0bd5bf11d59b85b28262fc38ebdb7f17ff8971 100644 (file)
@@ -211,6 +211,7 @@ class NumberFormatTest: public CalendarTimeZoneTest {
     void TestFractionalDigitsForCurrency();
     void TestFormatCurrencyPlural();
     void Test11868();
+    void Test11739_ParseLongCurrency();
     void Test10727_RoundingZero();
     void Test11376_getAndSetPositivePrefix();
     void Test11475_signRecognition();