From 62b974ace28da22f59f40730d32248bfc84cffba Mon Sep 17 00:00:00 2001 From: Alan Liu Date: Fri, 13 Feb 2004 01:56:38 +0000 Subject: [PATCH] ICU-3399 add UErrorCode to setCurrency X-SVN-Rev: 14511 --- icu4c/source/i18n/unicode/decimfmt.h | 8 +++++--- icu4c/source/i18n/unicode/numfmt.h | 7 ++++--- icu4c/source/i18n/unum.cpp | 2 +- icu4c/source/test/intltest/numfmtst.cpp | 8 +++----- 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/icu4c/source/i18n/unicode/decimfmt.h b/icu4c/source/i18n/unicode/decimfmt.h index c88b8a302f6..282d3f2bf23 100644 --- a/icu4c/source/i18n/unicode/decimfmt.h +++ b/icu4c/source/i18n/unicode/decimfmt.h @@ -1096,10 +1096,12 @@ public: * the currency is used if and when this object becomes a * currency format through the application of a new pattern. * @param theCurrency a 3-letter ISO code indicating new currency - * to use. It need not be null-terminated. - * @stable ICU 2.2 + * to use. It need not be null-terminated. May be the empty + * string or NULL to indicate no currency. + * @param ec input-output error code + * @draft ICU 3.0 */ - virtual void setCurrency(const UChar* theCurrency); + virtual void setCurrency(const UChar* theCurrency, UErrorCode& ec); /** * The resource tags we use to retrieve decimal format data from diff --git a/icu4c/source/i18n/unicode/numfmt.h b/icu4c/source/i18n/unicode/numfmt.h index d410dca97ec..8a171676356 100644 --- a/icu4c/source/i18n/unicode/numfmt.h +++ b/icu4c/source/i18n/unicode/numfmt.h @@ -603,9 +603,10 @@ public: * @param theCurrency a 3-letter ISO code indicating new currency * to use. It need not be null-terminated. May be the empty * string or NULL to indicate no currency. - * @draft ICU 2.6 + * @param ec input-output error code + * @draft ICU 3.0 */ - virtual void setCurrency(const UChar* theCurrency); + virtual void setCurrency(const UChar* theCurrency, UErrorCode& ec); /** * Gets the currency used to display currency @@ -695,7 +696,7 @@ private: UBool fParseIntegerOnly; // ISO currency code - UChar currency[4]; + UChar fCurrency[4]; friend class ICUNumberFormatFactory; // access to makeInstance, EStyles friend class ICUNumberFormatService; diff --git a/icu4c/source/i18n/unum.cpp b/icu4c/source/i18n/unum.cpp index bac114dc134..e31fdacc509 100644 --- a/icu4c/source/i18n/unum.cpp +++ b/icu4c/source/i18n/unum.cpp @@ -544,7 +544,7 @@ unum_setTextAttribute( UNumberFormat* fmt, break; case UNUM_CURRENCY_CODE: - ((DecimalFormat*)fmt)->setCurrency(newValue); + ((DecimalFormat*)fmt)->setCurrency(newValue, *status); break; default: diff --git a/icu4c/source/test/intltest/numfmtst.cpp b/icu4c/source/test/intltest/numfmtst.cpp index 711e69a3604..24190d73adf 100644 --- a/icu4c/source/test/intltest/numfmtst.cpp +++ b/icu4c/source/test/intltest/numfmtst.cpp @@ -1617,11 +1617,9 @@ void NumberFormatTest::expectCurrency(NumberFormat& nf, const Locale& locale, u_strcpy(curr, DEFAULT_CURR); if (*locale.getLanguage() != 0) { ucurr_forLocale(locale.getName(), curr, 4, &ec); - if (U_FAILURE(ec)) { - errln("FAIL: UCurrency::forLocale"); - return; - } - fmt.setCurrency(curr); + assertSuccess("ucurr_forLocale", ec); + fmt.setCurrency(curr, ec); + assertSuccess("DecimalFormat::setCurrency", ec); } UnicodeString s; fmt.format(value, s);