ICU-4587 test for C++ wrappers for ucol_cloneBinary and ucol_openBinary
X-SVN-Rev: 18070
This commit is contained in:
parent
acdf5b9f54
commit
d2a68eaa18
@ -1,6 +1,6 @@
|
||||
/********************************************************************
|
||||
* COPYRIGHT:
|
||||
* Copyright (c) 1997-2004, International Business Machines Corporation and
|
||||
* Copyright (c) 1997-2005, International Business Machines Corporation and
|
||||
* others. All Rights Reserved.
|
||||
********************************************************************/
|
||||
|
||||
@ -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 */)
|
||||
@ -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;
|
||||
@ -201,7 +203,20 @@ DataDrivenCollatorTest::processTest(TestData *testData) {
|
||||
errln("No collator definition!");
|
||||
}
|
||||
}
|
||||
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);
|
||||
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 +224,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 +239,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;
|
||||
|
@ -1,6 +1,6 @@
|
||||
/********************************************************************
|
||||
* COPYRIGHT:
|
||||
* Copyright (c) 2002-2004, International Business Machines Corporation and
|
||||
* Copyright (c) 2002-2005, International Business Machines Corporation and
|
||||
* others. All Rights Reserved.
|
||||
********************************************************************/
|
||||
|
||||
@ -51,6 +51,7 @@ private:
|
||||
TestDataModule *driver;
|
||||
UErrorCode status;
|
||||
UVector sequences;
|
||||
RuleBasedCollator *UCA; // needed for opening collators from binary images
|
||||
};
|
||||
|
||||
#endif /* #if !UCONFIG_NO_COLLATION */
|
||||
|
Loading…
Reference in New Issue
Block a user