Index: source/test/intltest/apicoll.cpp |
diff --git a/source/test/intltest/apicoll.cpp b/source/test/intltest/apicoll.cpp |
index 9d87bf07ce515a46a214628cc3073e28be507cc0..31b16dd26249bfd579a946f0484275e102607198 100644 |
--- a/source/test/intltest/apicoll.cpp |
+++ b/source/test/intltest/apicoll.cpp |
@@ -1,6 +1,6 @@ |
/******************************************************************** |
* COPYRIGHT: |
- * Copyright (c) 1997-2014, International Business Machines Corporation and |
+ * Copyright (c) 1997-2015, International Business Machines Corporation and |
* others. All Rights Reserved. |
********************************************************************/ |
//=============================================================================== |
@@ -191,6 +191,7 @@ CollationAPITest::TestProperty(/* char* par */) |
doAssert((col->getStrength() == Collator::TERTIARY), "collation object's strength is not tertiary difference"); |
doAssert((col->getStrength() != Collator::PRIMARY), "collation object's strength is primary difference"); |
doAssert((col->getStrength() != Collator::SECONDARY), "collation object's strength is secondary difference"); |
+ delete col; |
logln("Create junk collation: "); |
Locale abcd("ab", "CD", ""); |
@@ -201,26 +202,15 @@ CollationAPITest::TestProperty(/* char* par */) |
if (U_FAILURE(success)) |
{ |
errln("Junk collation creation failed, should at least return default."); |
- delete col; |
- return; |
- } |
- |
- delete col; |
- col = Collator::createInstance(success); |
- if (U_FAILURE(success)) |
- { |
- errln("Creating default collator failed."); |
- delete junk; |
return; |
} |
- doAssert(((RuleBasedCollator *)col)->getRules() == ((RuleBasedCollator *)junk)->getRules(), |
- "The default collation should be returned."); |
+ doAssert(((RuleBasedCollator *)junk)->getRules().isEmpty(), |
+ "The root collation should be returned for an unsupported language."); |
Collator *frCol = Collator::createInstance(Locale::getCanadaFrench(), success); |
if (U_FAILURE(success)) |
{ |
errln("Creating fr_CA collator failed."); |
- delete col; |
delete junk; |
return; |
} |
@@ -234,7 +224,6 @@ CollationAPITest::TestProperty(/* char* par */) |
doAssert((*frCol == *aFrCol), "The cloning of a fr_CA collator failed."); |
logln("Collator property test ended."); |
- delete col; |
delete frCol; |
delete aFrCol; |
delete junk; |
@@ -1008,9 +997,6 @@ CollationAPITest::TestCompare(/* char* par */) |
void |
CollationAPITest::TestGetAll(/* char* par */) |
{ |
- if (logKnownIssue("10774","Side effects from utility/LocaleTest/TestGetLocale")) { |
- return; |
- } |
int32_t count1, count2; |
UErrorCode status = U_ZERO_ERROR; |
@@ -1551,7 +1537,10 @@ void CollationAPITest::TestVariableTopSetting() { |
status = U_ZERO_ERROR; |
vt[0] = 0x24; // dollar sign (currency symbol) |
uint32_t newVarTop = coll->setVariableTop(vt, 1, status); |
- |
+ if(U_FAILURE(status)) { |
+ errln("setVariableTop(dollar sign) failed: %s", u_errorName(status)); |
+ return; |
+ } |
if(newVarTop != coll->getVariableTop(status)) { |
errln("setVariableTop(dollar sign) != following getVariableTop()"); |
} |
@@ -1707,28 +1696,23 @@ void CollationAPITest::TestGetLocale() { |
delete coll; |
} |
- /* completely non-existant locale for collator should get a default collator */ |
+ /* completely non-existent locale for collator should get a root collator */ |
{ |
- Collator *defaultColl = Collator::createInstance((const Locale)NULL, status); |
- coll = Collator::createInstance("blahaha", status); |
+ LocalPointer<Collator> coll(Collator::createInstance("blahaha", status)); |
if(U_FAILURE(status)) { |
errln("Failed to open collator with %s", u_errorName(status)); |
- delete coll; |
- delete defaultColl; |
return; |
} |
- if(coll->getLocale(ULOC_VALID_LOCALE, status) != |
- defaultColl->getLocale(ULOC_VALID_LOCALE, status)) { |
- errln("Valid locale for nonexisting locale locale collator differs " |
- "from valid locale for default collator"); |
+ Locale valid = coll->getLocale(ULOC_VALID_LOCALE, status); |
+ const char *name = valid.getName(); |
+ if(*name != 0 && strcmp(name, "root") != 0) { |
+ errln("Valid locale for nonexisting-locale collator is \"%s\" not root", name); |
} |
- if(coll->getLocale(ULOC_ACTUAL_LOCALE, status) != |
- defaultColl->getLocale(ULOC_ACTUAL_LOCALE, status)) { |
- errln("Actual locale for nonexisting locale locale collator differs " |
- "from actual locale for default collator"); |
+ Locale actual = coll->getLocale(ULOC_ACTUAL_LOCALE, status); |
+ name = actual.getName(); |
+ if(*name != 0 && strcmp(name, "root") != 0) { |
+ errln("Actual locale for nonexisting-locale collator is \"%s\" not root", name); |
} |
- delete coll; |
- delete defaultColl; |
} |