From 66510b153fdd15d235458b8fe34363211a53fe82 Mon Sep 17 00:00:00 2001 From: Shane Carr Date: Mon, 7 May 2018 21:47:09 +0000 Subject: [PATCH] ICU-11739 Adding ICU4C test for parse long currency. X-SVN-Rev: 41334 --- icu4c/source/test/intltest/numfmtst.cpp | 12 ++++++++++++ icu4c/source/test/intltest/numfmtst.h | 1 + 2 files changed, 13 insertions(+) diff --git a/icu4c/source/test/intltest/numfmtst.cpp b/icu4c/source/test/intltest/numfmtst.cpp index 30ef7e6dac0..754679b6d7e 100644 --- a/icu4c/source/test/intltest/numfmtst.cpp +++ b/icu4c/source/test/intltest/numfmtst.cpp @@ -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 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}; diff --git a/icu4c/source/test/intltest/numfmtst.h b/icu4c/source/test/intltest/numfmtst.h index 45c68d030e6..af0bd5bf11d 100644 --- a/icu4c/source/test/intltest/numfmtst.h +++ b/icu4c/source/test/intltest/numfmtst.h @@ -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();