mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-08 06:53:45 +00:00
ICU-4536 return default on fallback to root
X-SVN-Rev: 17780
This commit is contained in:
parent
ca9292b97d
commit
da83c2f563
2 changed files with 11 additions and 0 deletions
|
@ -489,6 +489,10 @@ ucurr_getName(const UChar* currency,
|
|||
// If we've succeeded we're done. Otherwise, try to fallback.
|
||||
// If that fails (because we are already at root) then exit.
|
||||
if (U_SUCCESS(ec2) || !fallback(loc)) {
|
||||
if (ec2 == U_USING_DEFAULT_WARNING
|
||||
|| (ec2 == U_USING_FALLBACK_WARNING && *ec != U_USING_DEFAULT_WARNING)) {
|
||||
*ec = ec2;
|
||||
}
|
||||
break;
|
||||
} else if (strlen(loc) == 0) {
|
||||
*ec = U_USING_DEFAULT_WARNING;
|
||||
|
|
|
@ -1420,6 +1420,7 @@ void NumberFormatTest::TestCurrencyNames(void) {
|
|||
UErrorCode ec = U_ZERO_ERROR;
|
||||
static const UChar USD[] = {85, 83, 68, 0}; /*USD*/
|
||||
static const UChar CAD[] = {0x43, 0x41, 0x44, 0}; /*CAD*/
|
||||
static const UChar ITL[] = {0x49, 0x54, 0x4C, 0}; /*ITL*/
|
||||
UBool isChoiceFormat;
|
||||
int32_t len;
|
||||
// Warning: HARD-CODED LOCALE DATA in this test. If it fails, CHECK
|
||||
|
@ -1446,6 +1447,12 @@ void NumberFormatTest::TestCurrencyNames(void) {
|
|||
assertTrue("ucurr_getName (default)",
|
||||
U_USING_DEFAULT_WARNING == ec, TRUE);
|
||||
|
||||
// Test that a default warning is being returned when falling back to root. JB 4536.
|
||||
(void) ucurr_getName(ITL, "cy", UCURR_LONG_NAME, &isChoiceFormat,
|
||||
&len, &ec);
|
||||
assertTrue("ucurr_getName (default to root)",
|
||||
U_USING_DEFAULT_WARNING == ec, TRUE);
|
||||
|
||||
// TODO add more tests later
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue