ICU-856 at least don't crash if collation isn't working
X-SVN-Rev: 3669
This commit is contained in:
parent
900403dd5f
commit
00cd7c0b17
@ -31,6 +31,13 @@ CollationDanishTest::CollationDanishTest()
|
||||
{
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
myCollation = Collator::createInstance(Locale("da", "DK", ""),status);
|
||||
if(!myCollation || U_FAILURE(status)) {
|
||||
errln(__FILE__ "failed to create! err " + UnicodeString(u_errorName(status)));
|
||||
/* if it wasn't already: */
|
||||
delete myCollation;
|
||||
myCollation = NULL;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
CollationDanishTest::~CollationDanishTest()
|
||||
@ -236,6 +243,12 @@ void CollationDanishTest::TestPrimary(/* char* par */)
|
||||
void CollationDanishTest::runIndexedTest( int32_t index, UBool exec, const char* &name, char* /*par*/ )
|
||||
{
|
||||
if (exec) logln("TestSuite CollationDanishTest: ");
|
||||
|
||||
if((!myCollation) && exec) {
|
||||
errln(__FILE__ " cannot test - failed to create collator.");
|
||||
name = "";
|
||||
return;
|
||||
}
|
||||
switch (index) {
|
||||
case 0: name = "TestPrimary"; if (exec) TestPrimary(/* par */); break;
|
||||
case 1: name = "TestTertiary"; if (exec) TestTertiary(/* par */); break;
|
||||
|
@ -32,6 +32,12 @@ CollationGermanTest::CollationGermanTest()
|
||||
{
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
myCollation = Collator::createInstance(Locale::GERMANY, status);
|
||||
if(!myCollation || U_FAILURE(status)) {
|
||||
errln(__FILE__ "failed to create! err " + UnicodeString(u_errorName(status)));
|
||||
/* if it wasn't already: */
|
||||
delete myCollation;
|
||||
myCollation = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
CollationGermanTest::~CollationGermanTest()
|
||||
@ -90,6 +96,10 @@ const Collator::EComparisonResult CollationGermanTest::results[][2] =
|
||||
|
||||
void CollationGermanTest::doTest( UnicodeString source, UnicodeString target, Collator::EComparisonResult result)
|
||||
{
|
||||
if(myCollation == NULL ) {
|
||||
errln("decoll: cannot start test, collator is null\n");
|
||||
return;
|
||||
}
|
||||
Collator::EComparisonResult compareResult = myCollation->compare(source, target);
|
||||
SimpleFwdCharIterator src(source);
|
||||
SimpleFwdCharIterator trg(target);
|
||||
@ -110,6 +120,11 @@ void CollationGermanTest::doTest( UnicodeString source, UnicodeString target, Co
|
||||
|
||||
void CollationGermanTest::TestTertiary(/* char* par */)
|
||||
{
|
||||
if(myCollation == NULL ) {
|
||||
errln("decoll: cannot start test, collator is null\n");
|
||||
return;
|
||||
}
|
||||
|
||||
int32_t i = 0;
|
||||
myCollation->setStrength(Collator::TERTIARY);
|
||||
for (i = 0; i < 12 ; i++)
|
||||
@ -119,6 +134,10 @@ void CollationGermanTest::TestTertiary(/* char* par */)
|
||||
}
|
||||
void CollationGermanTest::TestPrimary(/* char* par */)
|
||||
{
|
||||
if(myCollation == NULL ) {
|
||||
errln("decoll: cannot start test, collator is null\n");
|
||||
return;
|
||||
}
|
||||
int32_t i;
|
||||
myCollation->setStrength(Collator::PRIMARY);
|
||||
for (i = 0; i < 12 ; i++)
|
||||
|
@ -114,6 +114,12 @@ void CollationSpanishTest::TestPrimary(/* char* par */)
|
||||
void CollationSpanishTest::runIndexedTest( int32_t index, UBool exec, const char* &name, char* /*par */)
|
||||
{
|
||||
if (exec) logln("TestSuite CollationSpanishTest: ");
|
||||
|
||||
if((!myCollation) && exec) {
|
||||
errln(__FILE__ " cannot test - failed to create collator.");
|
||||
name = "";
|
||||
return;
|
||||
}
|
||||
switch (index) {
|
||||
case 0: name = "TestPrimary"; if (exec) TestPrimary(/* par */); break;
|
||||
case 1: name = "TestTertiary"; if (exec) TestTertiary(/* par */); break;
|
||||
|
@ -101,6 +101,12 @@ void CollationFinnishTest::TestPrimary(/* char* par */)
|
||||
void CollationFinnishTest::runIndexedTest( int32_t index, UBool exec, const char* &name, char* /*par*/ )
|
||||
{
|
||||
if (exec) logln("TestSuite CollationFinnishTest: ");
|
||||
|
||||
if((!myCollation) && exec) {
|
||||
errln(__FILE__ " cannot test - failed to create collator.");
|
||||
name = "";
|
||||
return;
|
||||
}
|
||||
switch (index) {
|
||||
case 0: name = "TestPrimary"; if (exec) TestPrimary(/* par */); break;
|
||||
case 1: name = "TestTertiary"; if (exec) TestTertiary(/* par */); break;
|
||||
|
@ -38,6 +38,13 @@ CollationFrenchTest::CollationFrenchTest()
|
||||
{
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
myCollation = Collator::createInstance(Locale::FRANCE, status);
|
||||
if(!myCollation || U_FAILURE(status)) {
|
||||
errln(__FILE__ "failed to create! err " + UnicodeString(u_errorName(status)));
|
||||
/* if it wasn't already: */
|
||||
delete myCollation;
|
||||
myCollation = NULL;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
CollationFrenchTest::~CollationFrenchTest()
|
||||
@ -247,6 +254,13 @@ void CollationFrenchTest::TestExtra(/* char* par */)
|
||||
void CollationFrenchTest::runIndexedTest( int32_t index, UBool exec, const char* &name, char* /*par*/ )
|
||||
{
|
||||
if (exec) logln("TestSuite CollationFrenchTest: ");
|
||||
|
||||
if((!myCollation) && exec) {
|
||||
errln(__FILE__ " cannot test - failed to create collator.");
|
||||
name = "";
|
||||
return;
|
||||
}
|
||||
|
||||
switch (index) {
|
||||
case 0: name = "TestSecondary"; if (exec) TestSecondary(/* par */); break;
|
||||
case 1: name = "TestTertiary"; if (exec) TestTertiary(/* par */); break;
|
||||
|
@ -30,6 +30,14 @@ CollationKanaTest::CollationKanaTest()
|
||||
{
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
myCollation = Collator::createInstance(Locale::JAPAN, status);
|
||||
if(!myCollation || U_FAILURE(status)) {
|
||||
errln(__FILE__ "failed to create! err " + UnicodeString(u_errorName(status)));
|
||||
/* if it wasn't already: */
|
||||
delete myCollation;
|
||||
myCollation = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
myCollation->setDecomposition(Normalizer::DECOMP);
|
||||
}
|
||||
|
||||
|
@ -55,6 +55,13 @@ CollationThaiTest::~CollationThaiTest() {
|
||||
|
||||
void CollationThaiTest::runIndexedTest(int32_t index, UBool exec, const char* &name,
|
||||
char* /*par*/) {
|
||||
|
||||
if((!coll) && exec) {
|
||||
errln(__FILE__ " cannot test - failed to create collator.");
|
||||
name = "";
|
||||
return;
|
||||
}
|
||||
|
||||
switch (index) {
|
||||
CASE(0,TestDictionary)
|
||||
CASE(1,TestCornerCases)
|
||||
|
@ -118,6 +118,12 @@ void CollationTurkishTest::TestPrimary(/* char* par */)
|
||||
void CollationTurkishTest::runIndexedTest( int32_t index, UBool exec, const char* &name, char* /*par*/ )
|
||||
{
|
||||
if (exec) logln("TestSuite CollationTurkishTest: ");
|
||||
|
||||
if((!myCollation) && exec) {
|
||||
errln(__FILE__ " cannot test - failed to create collator.");
|
||||
name = "";
|
||||
return;
|
||||
}
|
||||
switch (index) {
|
||||
case 0: name = "TestPrimary"; if (exec) TestPrimary(/* par */); break;
|
||||
case 1: name = "TestTertiary"; if (exec) TestTertiary(/* par */); break;
|
||||
|
Loading…
Reference in New Issue
Block a user