From e0edd4416869fe6058a87839e0dafd89a183dc45 Mon Sep 17 00:00:00 2001 From: Hugo van der Merwe <17109322+hugovdm@users.noreply.github.com> Date: Tue, 11 Aug 2020 17:54:10 +0200 Subject: [PATCH 1/3] Explore Usage-related error codes, address icu-units/icu#36. --- icu4c/source/i18n/number_formatimpl.cpp | 3 ++- icu4c/source/i18n/unitsdata.cpp | 10 ++++++--- icu4c/source/test/intltest/numbertest.h | 1 + icu4c/source/test/intltest/numbertest_api.cpp | 22 +++++++++++++++++++ 4 files changed, 32 insertions(+), 4 deletions(-) diff --git a/icu4c/source/i18n/number_formatimpl.cpp b/icu4c/source/i18n/number_formatimpl.cpp index 1480a907e64..ec03492fdbe 100644 --- a/icu4c/source/i18n/number_formatimpl.cpp +++ b/icu4c/source/i18n/number_formatimpl.cpp @@ -230,7 +230,8 @@ NumberFormatterImpl::macrosToMicroGenerator(const MacroProps& macros, bool safe, // Unit Preferences and Conversions as our first step if (macros.usage.isSet()) { if (!isCldrUnit) { - // We only support "usage" when the input unit is a CLDR Unit. + // We only support "usage" when the input unit is specified, and is + // a CLDR Unit. status = U_ILLEGAL_ARGUMENT_ERROR; return nullptr; } diff --git a/icu4c/source/i18n/unitsdata.cpp b/icu4c/source/i18n/unitsdata.cpp index 098c9f560bc..518c91aa13d 100644 --- a/icu4c/source/i18n/unitsdata.cpp +++ b/icu4c/source/i18n/unitsdata.cpp @@ -282,6 +282,8 @@ int32_t getPreferenceMetadataIndex(const MaybeStackVector= 0) { return idx; } if (!foundCategory) { + // TODO(units): maybe add a unit test to ensure all units have a + // category and all categories are present in the data? status = U_ILLEGAL_ARGUMENT_ERROR; return -1; } @@ -293,9 +295,9 @@ int32_t getPreferenceMetadataIndex(const MaybeStackVector Date: Tue, 11 Aug 2020 19:35:51 +0200 Subject: [PATCH 2/3] Remove three TODOs. --- icu4c/source/i18n/unitsdata.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/icu4c/source/i18n/unitsdata.cpp b/icu4c/source/i18n/unitsdata.cpp index 518c91aa13d..702c09aaaae 100644 --- a/icu4c/source/i18n/unitsdata.cpp +++ b/icu4c/source/i18n/unitsdata.cpp @@ -282,8 +282,6 @@ int32_t getPreferenceMetadataIndex(const MaybeStackVector= 0) { return idx; } if (!foundCategory) { - // TODO(units): maybe add a unit test to ensure all units have a - // category and all categories are present in the data? status = U_ILLEGAL_ARGUMENT_ERROR; return -1; } @@ -296,8 +294,6 @@ int32_t getPreferenceMetadataIndex(const MaybeStackVector Date: Tue, 11 Aug 2020 20:37:48 +0200 Subject: [PATCH 3/3] Add a note about "001" being expected. --- icu4c/source/i18n/unitsdata.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/icu4c/source/i18n/unitsdata.cpp b/icu4c/source/i18n/unitsdata.cpp index 702c09aaaae..d9f1015c94d 100644 --- a/icu4c/source/i18n/unitsdata.cpp +++ b/icu4c/source/i18n/unitsdata.cpp @@ -308,6 +308,7 @@ int32_t getPreferenceMetadataIndex(const MaybeStackVector