| Index: source/test/intltest/svccoll.cpp
|
| diff --git a/source/test/intltest/svccoll.cpp b/source/test/intltest/svccoll.cpp
|
| index 565ef81b3051f01179fc22b728d5e7d83cc33ef7..20aeb41171e24862d94aabd2dfdbb88232518b05 100644
|
| --- a/source/test/intltest/svccoll.cpp
|
| +++ b/source/test/intltest/svccoll.cpp
|
| @@ -1,7 +1,7 @@
|
| /*
|
| *******************************************************************************
|
| - * Copyright (C) 2003-2013, International Business Machines Corporation and *
|
| - * others. All Rights Reserved. *
|
| + * Copyright (C) 2003-2014, International Business Machines Corporation and
|
| + * others. All Rights Reserved.
|
| *******************************************************************************
|
| */
|
|
|
| @@ -15,7 +15,6 @@
|
| #include "hash.h"
|
| #include "uassert.h"
|
|
|
| -#include "ucol_imp.h" // internal api needed to test ucollator equality
|
| #include "cstring.h" // internal api used to compare locale strings
|
|
|
| void CollationServiceTest::runIndexedTest(int32_t index, UBool exec, const char* &name, char* /*par */)
|
| @@ -49,26 +48,24 @@ void CollationServiceTest::TestRegister()
|
| }
|
|
|
| { // try override en_US collator
|
| + Collator *clone = frcol->clone();
|
| URegistryKey key = Collator::registerInstance(frcol, US, status);
|
| + // frcol has been adopted. We must not use it any more, nor rely on its attributes.
|
| + frcol = NULL;
|
|
|
| Collator* ncol = Collator::createInstance(US_FOO, status);
|
| - if (*frcol != *ncol) {
|
| + if (*clone != *ncol) {
|
| errln("register of french collator for en_US failed on request for en_US_FOO");
|
| }
|
| - // ensure original collator's params not touched
|
| - Locale loc = frcol->getLocale(ULOC_REQUESTED_LOCALE, status);
|
| - if (loc != FR) {
|
| - errln(UnicodeString("fr collator's requested locale changed to ") + loc.getName());
|
| - }
|
| - loc = frcol->getLocale(ULOC_VALID_LOCALE, status);
|
| - if (loc != FR) {
|
| - errln(UnicodeString("fr collator's valid locale changed to ") + loc.getName());
|
| - }
|
| + delete clone;
|
|
|
| - loc = ncol->getLocale(ULOC_REQUESTED_LOCALE, status);
|
| - if (loc != US_FOO) {
|
| - errln(UnicodeString("requested locale for en_US_FOO is not en_US_FOO but ") + loc.getName());
|
| + // 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 (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());
|
| @@ -82,7 +79,6 @@ void CollationServiceTest::TestRegister()
|
| if (!Collator::unregister(key, status)) {
|
| errln("failed to unregister french collator");
|
| }
|
| - // !!! frcol pointer is now invalid !!!
|
|
|
| ncol = Collator::createInstance(US, status);
|
| if (*uscol != *ncol) {
|
| @@ -101,11 +97,14 @@ void CollationServiceTest::TestRegister()
|
| Locale fu_FU("fu", "FU", "");
|
|
|
| Collator* fucol = Collator::createInstance(fu_FU, status);
|
| + Collator *clone = frcol->clone();
|
| URegistryKey key = Collator::registerInstance(frcol, fu_FU, status);
|
| + frcol = NULL; // frcol has been adopted.
|
| Collator* ncol = Collator::createInstance(fu_FU_FOO, status);
|
| - if (*frcol != *ncol) {
|
| + if (*clone != *ncol) {
|
| errln("register of fr collator for fu_FU failed");
|
| }
|
| + delete clone;
|
|
|
| UnicodeString locName = fu_FU.getName();
|
| StringEnumeration* localeEnum = Collator::getAvailableLocales();
|
| @@ -174,7 +173,8 @@ void CollationServiceTest::TestRegister()
|
| if (fufu.isNull()) {
|
| errln("could not open fu_FU_FOO with ucol_open");
|
| } else {
|
| - if (!ucol_equals(fufu.getAlias(), frFR.getAlias())) {
|
| + if (*Collator::fromUCollator(fufu.getAlias()) !=
|
| + *Collator::fromUCollator(frFR.getAlias())) {
|
| errln("collator fufu != collator frFR");
|
| }
|
| }
|
| @@ -227,6 +227,7 @@ CollatorInfo::CollatorInfo(const Locale& _locale, Collator* _collator, Hashtable
|
| , collator(_collator)
|
| , displayNames(_displayNames)
|
| {
|
| + collator->setLocales(locale, locale, locale);
|
| }
|
|
|
| CollatorInfo::~CollatorInfo() {
|
| @@ -410,10 +411,13 @@ void CollationServiceTest::TestRegisterFactory(void)
|
| errln("jpcol for fu_FU_FOO failed");
|
| }
|
|
|
| + // 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) {
|
| - errln(UnicodeString("requested locale for fu_FU_FOO is not fu_FU_FOO but ") + loc.getName());
|
| + 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());
|
| @@ -585,8 +589,8 @@ void CollationServiceTest::TestSeparateTree() {
|
| isAvailable, ec);
|
| assertSuccess("getFunctionalEquivalent", ec);
|
| assertEquals("getFunctionalEquivalent(de_DE)", "root", equiv.getName());
|
| - assertTrue("getFunctionalEquivalent(de_DE).isAvailable==TRUE",
|
| - isAvailable == TRUE);
|
| + assertTrue("getFunctionalEquivalent(de_DE).isAvailable==FALSE",
|
| + isAvailable == FALSE);
|
|
|
| equiv = Collator::getFunctionalEquivalent("collation",
|
| Locale::createFromName("sv"),
|
| @@ -601,8 +605,8 @@ void CollationServiceTest::TestSeparateTree() {
|
| isAvailable, ec);
|
| assertSuccess("getFunctionalEquivalent", ec);
|
| assertEquals("getFunctionalEquivalent(sv_SE)", "sv", equiv.getName());
|
| - assertTrue("getFunctionalEquivalent(sv_SE).isAvailable==TRUE",
|
| - isAvailable == TRUE);
|
| + assertTrue("getFunctionalEquivalent(sv_SE).isAvailable==FALSE",
|
| + isAvailable == FALSE);
|
| }
|
|
|
| #endif
|
|
|