ICU-10477 drop already-marginal support for ULOC_REQUESTED_LOCALE

X-SVN-Rev: 36252
This commit is contained in:
Markus Scherer 2014-08-27 21:27:37 +00:00
parent ecd2a3a355
commit 725657cd3d
8 changed files with 25 additions and 20 deletions

View file

@ -1988,7 +1988,6 @@ ures_getLocaleByType(const UResourceBundle* resourceBundle,
case ULOC_VALID_LOCALE:
return resourceBundle->fTopLevelData->fName;
case ULOC_REQUESTED_LOCALE:
return NULL;
default:
*status = U_ILLEGAL_ARGUMENT_ERROR;
return NULL;

View file

@ -310,8 +310,8 @@ RuleBasedCollator::getLocale(ULocDataLocaleType type, UErrorCode& errorCode) con
case ULOC_ACTUAL_LOCALE:
return actualLocaleIsSameAsValid ? validLocale : tailoring->actualLocale;
case ULOC_VALID_LOCALE:
case ULOC_REQUESTED_LOCALE: // TODO: Drop this, see ticket #10477.
return validLocale;
case ULOC_REQUESTED_LOCALE:
default:
errorCode = U_ILLEGAL_ARGUMENT_ERROR;
return Locale::getRoot();
@ -329,9 +329,9 @@ RuleBasedCollator::internalGetLocaleID(ULocDataLocaleType type, UErrorCode &erro
result = actualLocaleIsSameAsValid ? &validLocale : &tailoring->actualLocale;
break;
case ULOC_VALID_LOCALE:
case ULOC_REQUESTED_LOCALE: // TODO: Drop this, see ticket #10477.
result = &validLocale;
break;
case ULOC_REQUESTED_LOCALE:
default:
errorCode = U_ILLEGAL_ARGUMENT_ERROR;
return NULL;

View file

@ -1432,9 +1432,11 @@ void TestGetLocale() {
* or may not be supported at all. See ticket #10477.
*/
locale = ucol_getLocaleByType(coll, ULOC_REQUESTED_LOCALE, &status);
if(strcmp(locale, testStruct[i].requestedLocale) != 0 && strcmp(locale, testStruct[i].validLocale) != 0) {
if(U_SUCCESS(status) &&
strcmp(locale, testStruct[i].requestedLocale) != 0 && strcmp(locale, testStruct[i].validLocale) != 0) {
log_err("[Coll %s]: Error in requested locale, expected %s, got %s\n", testStruct[i].requestedLocale, testStruct[i].requestedLocale, locale);
}
status = U_ZERO_ERROR;
locale = ucol_getLocaleByType(coll, ULOC_VALID_LOCALE, &status);
if(strcmp(locale, testStruct[i].validLocale) != 0) {
log_err("[Coll %s]: Error in valid locale, expected %s, got %s\n", testStruct[i].requestedLocale, testStruct[i].validLocale, locale);
@ -1477,9 +1479,10 @@ void TestGetLocale() {
/* collator instantiated from rules should have all three locales NULL */
coll = ucol_openRules(rlz, rlzLen, UCOL_DEFAULT, UCOL_DEFAULT, NULL, &status);
locale = ucol_getLocaleByType(coll, ULOC_REQUESTED_LOCALE, &status);
if(locale != NULL) {
if(U_SUCCESS(status) && locale != NULL) {
log_err("For collator instantiated from rules, requested locale returned %s instead of NULL\n", locale);
}
status = U_ZERO_ERROR;
locale = ucol_getLocaleByType(coll, ULOC_VALID_LOCALE, &status);
if(locale != NULL) {
log_err("For collator instantiated from rules, valid locale returned %s instead of NULL\n", locale);

View file

@ -2783,7 +2783,7 @@ static int32_t TestEqualsForCollator(const char* locName, UCollator *source, UCo
errorNo++;
}
ucol_close(target);
if(uprv_strcmp(ucol_getLocaleByType(source, ULOC_REQUESTED_LOCALE, &status), ucol_getLocaleByType(source, ULOC_ACTUAL_LOCALE, &status)) == 0) {
if(uprv_strcmp(locName, ucol_getLocaleByType(source, ULOC_ACTUAL_LOCALE, &status)) == 0) {
target = ucol_safeClone(source, NULL, NULL, &status);
if(U_FAILURE(status)) {
log_err("Error creating clone\n");
@ -2886,8 +2886,8 @@ static void TestEquals(void) {
if(!ucol_equals(source, source)) {
log_err("Same collator not equal\n");
}
if(TestEqualsForCollator(locName, source, target)) {
log_err("Errors for root\n", locName);
if(TestEqualsForCollator("root", source, target)) {
log_err("Errors for root\n");
}
ucol_close(source);

View file

@ -996,11 +996,12 @@ static void TestGetLocaleByType(void) {
status = U_ZERO_ERROR;
continue;
}
locale = ures_getLocaleByType(res, ULOC_REQUESTED_LOCALE, &status);
if(locale) {
if(U_SUCCESS(status) && locale != NULL) {
log_err("Requested locale should return NULL\n");
}
status = U_ZERO_ERROR;
locale = ures_getLocaleByType(res, ULOC_VALID_LOCALE, &status);
if(!locale || strcmp(locale, test[i].validLocale) != 0) {
log_err("Expected valid locale to be %s. Got %s\n", test[i].requestedLocale, locale);
@ -1013,4 +1014,3 @@ static void TestGetLocaleByType(void) {
}
ures_close(res);
}

View file

@ -1674,11 +1674,13 @@ void CollationAPITest::TestGetLocale() {
// The requested locale may be the same as the valid locale,
// or may not be supported at all. See ticket #10477.
locale = coll->getLocale(ULOC_REQUESTED_LOCALE, status);
if(locale != testStruct[i].requestedLocale && locale != testStruct[i].validLocale) {
if(U_SUCCESS(status) &&
locale != testStruct[i].requestedLocale && locale != testStruct[i].validLocale) {
errln("[Coll %s]: Error in requested locale, expected %s or %s, got %s",
testStruct[i].requestedLocale,
testStruct[i].requestedLocale, testStruct[i].validLocale, locale.getName());
}
status = U_ZERO_ERROR;
locale = coll->getLocale(ULOC_VALID_LOCALE, status);
if(locale != testStruct[i].validLocale) {
errln("[Coll %s]: Error in valid locale, expected %s, got %s",
@ -1736,9 +1738,10 @@ void CollationAPITest::TestGetLocale() {
/* collator instantiated from rules should have all three locales NULL */
coll = new RuleBasedCollator(rlz, status);
locale = coll->getLocale(ULOC_REQUESTED_LOCALE, status);
if(!locale.isBogus()) {
if(U_SUCCESS(status) && !locale.isBogus()) {
errln("For collator instantiated from rules, requested locale %s is not bogus", locale.getName());
}
status = U_ZERO_ERROR;
locale = coll->getLocale(ULOC_VALID_LOCALE, status);
if(!locale.isBogus()) {
errln("For collator instantiated from rules, valid locale %s is not bogus", locale.getName());

View file

@ -612,11 +612,12 @@ ResourceBundleTest::TestGetLocaleByType(void)
status = U_ZERO_ERROR;
continue;
}
locale = res.getLocale(ULOC_REQUESTED_LOCALE, status);
if(locale != Locale::getDefault()) {
if(U_SUCCESS(status) && locale != Locale::getDefault()) {
err("Expected requested locale to be %s. Got %s\n", test[i].requestedLocale, locale.getName());
}
status = U_ZERO_ERROR;
locale = res.getLocale(ULOC_VALID_LOCALE, status);
if(strcmp(locale.getName(), test[i].validLocale) != 0) {
err("Expected valid locale to be %s. Got %s\n", test[i].requestedLocale, locale.getName());
@ -627,6 +628,3 @@ ResourceBundleTest::TestGetLocaleByType(void)
}
}
}
//eof

View file

@ -62,9 +62,10 @@ void CollationServiceTest::TestRegister()
// The requested locale may be the same as the valid locale,
// or may not be supported at all. See ticket #10477.
Locale loc = ncol->getLocale(ULOC_REQUESTED_LOCALE, status);
if (loc != US_FOO && loc != US) {
if (U_SUCCESS(status) && loc != US_FOO && loc != US) {
errln(UnicodeString("requested locale for en_US_FOO is not en_US_FOO nor en_US but ") + loc.getName());
}
status = U_ZERO_ERROR;
loc = ncol->getLocale(ULOC_VALID_LOCALE, status);
if (loc != US) {
errln(UnicodeString("valid locale for en_US_FOO is not en_US but ") + loc.getName());
@ -413,9 +414,10 @@ void CollationServiceTest::TestRegisterFactory(void)
// The requested locale may be the same as the valid locale,
// or may not be supported at all. See ticket #10477.
Locale loc = ncol->getLocale(ULOC_REQUESTED_LOCALE, status);
if (loc != fu_FU_FOO && loc != fu_FU) {
if (U_SUCCESS(status) && loc != fu_FU_FOO && loc != fu_FU) {
errln(UnicodeString("requested locale for fu_FU_FOO is not fu_FU_FOO nor fu_FU but ") + loc.getName());
}
status = U_ZERO_ERROR;
loc = ncol->getLocale(ULOC_VALID_LOCALE, status);
if (loc != fu_FU) {
errln(UnicodeString("valid locale for fu_FU_FOO is not fu_FU but ") + loc.getName());