X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/374ca955a76ecab1204ca8bfa63ff9238d998416..e4f10fab0c078f399c9deef476d9c9b73b47dff8:/icuSources/test/intltest/dadrcoll.cpp diff --git a/icuSources/test/intltest/dadrcoll.cpp b/icuSources/test/intltest/dadrcoll.cpp index 738ed133..62248096 100644 --- a/icuSources/test/intltest/dadrcoll.cpp +++ b/icuSources/test/intltest/dadrcoll.cpp @@ -1,6 +1,6 @@ /******************************************************************** * COPYRIGHT: - * Copyright (c) 1997-2004, International Business Machines Corporation and + * Copyright (c) 1997-2010, International Business Machines Corporation and * others. All Rights Reserved. ********************************************************************/ @@ -17,7 +17,7 @@ #include "unicode/utypes.h" -#if !UCONFIG_NO_COLLATION +#if !UCONFIG_NO_COLLATION && !UCONFIG_NO_FILE_IO #include "unicode/uchar.h" #include "unicode/tstdtmod.h" @@ -39,11 +39,13 @@ sequences(status) { driver = TestDataModule::getTestDataModule("DataDrivenCollationTest", *this, status); sequences.setDeleter(deleteSeqElement); + UCA = (RuleBasedCollator*)Collator::createInstance("root", status); } DataDrivenCollatorTest::~DataDrivenCollatorTest() { delete driver; + delete UCA; } void DataDrivenCollatorTest::runIndexedTest( int32_t index, UBool exec, const char* &name, char* /*par */) @@ -71,7 +73,7 @@ void DataDrivenCollatorTest::runIndexedTest( int32_t index, UBool exec, const ch name = ""; } } else { - errln("collate/DataDrivenTest data not initialized!"); + dataerrln("collate/DataDrivenTest data not initialized!"); name = ""; } @@ -162,7 +164,7 @@ DataDrivenCollatorTest::processArguments(Collator *col, const UChar *start, int3 } } -void +void DataDrivenCollatorTest::processTest(TestData *testData) { Collator *col = NULL; const UChar *arguments = NULL; @@ -194,14 +196,29 @@ DataDrivenCollatorTest::processTest(TestData *testData) { if(U_SUCCESS(status)) { logln("Testing collator for rules "+testSetting); } else { - errln("Unable to instantiate collator for rules "+testSetting); + errln("Unable to instantiate collator for rules "+testSetting+" - "+u_errorName(status)); return; } } else { errln("No collator definition!"); + return; } } - if(col != NULL) { + + int32_t cloneSize = 0; + uint8_t* cloneBuf = NULL; + RuleBasedCollator* clone = NULL; + if(col != NULL){ + RuleBasedCollator* rbc = (RuleBasedCollator*)col; + cloneSize = rbc->cloneBinary(NULL, 0, intStatus); + intStatus = U_ZERO_ERROR; + cloneBuf = (uint8_t*) malloc(cloneSize); + cloneSize = rbc->cloneBinary(cloneBuf, cloneSize, intStatus); + clone = new RuleBasedCollator(cloneBuf, cloneSize, UCA, intStatus); + if(U_FAILURE(intStatus)){ + errln("Could not clone the RuleBasedCollator. Error: %s", u_errorName(intStatus)); + intStatus= U_ZERO_ERROR; + } // get attributes testSetting = settings->getString("Arguments", intStatus); if(U_SUCCESS(intStatus)) { @@ -209,6 +226,9 @@ DataDrivenCollatorTest::processTest(TestData *testData) { argLen = testSetting.length(); arguments = testSetting.getBuffer(); processArguments(col, arguments, argLen); + if(clone != NULL){ + processArguments(clone, arguments, argLen); + } if(U_FAILURE(status)) { errln("Couldn't process arguments"); break; @@ -221,16 +241,22 @@ DataDrivenCollatorTest::processTest(TestData *testData) { UnicodeString sequence = currentCase->getString("sequence", status); if(U_SUCCESS(status)) { processSequence(col, sequence); + if(clone != NULL){ + processSequence(clone, sequence); + } } } } else { errln("Couldn't instantiate a collator!"); } + delete clone; + free(cloneBuf); delete col; col = NULL; } } + void DataDrivenCollatorTest::processSequence(Collator* col, const UnicodeString &sequence) { Collator::EComparisonResult relation = Collator::EQUAL;