/********************************************************************
* COPYRIGHT:
- * Copyright (c) 1997-2004, International Business Machines Corporation and
+ * Copyright (c) 1997-2010, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************/
#include "unicode/utypes.h"
-#if !UCONFIG_NO_COLLATION
+#if !UCONFIG_NO_COLLATION && !UCONFIG_NO_FILE_IO
#include "unicode/uchar.h"
#include "unicode/tstdtmod.h"
{
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 */)
name = "";
}
} else {
- errln("collate/DataDrivenTest data not initialized!");
+ dataerrln("collate/DataDrivenTest data not initialized!");
name = "";
}
}
}
-void
+void
DataDrivenCollatorTest::processTest(TestData *testData) {
Collator *col = NULL;
const UChar *arguments = NULL;
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)) {
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;
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;