dadrcoll.cpp revision 50294ead5e5d23f5bbfed76e00e6b510bd41eee1
1b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/******************************************************************** 2b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * COPYRIGHT: 36d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru * Copyright (c) 1997-2009, International Business Machines Corporation and 4b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * others. All Rights Reserved. 5b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru ********************************************************************/ 6b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 7b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/** 8b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * IntlTestCollator is the medium level test class for everything in the directory "collate". 9b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 10b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 11b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/*********************************************************************** 12b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru* Modification history 13b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru* Date Name Description 14b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru* 02/14/2001 synwee Compare with cintltst and commented away tests 15b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru* that are not run. 16b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru***********************************************************************/ 17b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 18b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/utypes.h" 19b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 2050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho#if !UCONFIG_NO_COLLATION && !UCONFIG_NO_FILE_IO 21b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 22b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/uchar.h" 23b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/tstdtmod.h" 24b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "cstring.h" 25b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "ucol_tok.h" 26b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "tscoll.h" 27b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "dadrcoll.h" 28b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 29b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_CDECL_BEGIN 30b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Querustatic void U_CALLCONV deleteSeqElement(void *elem) { 31b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru delete((SeqElement *)elem); 32b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru} 33b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_CDECL_END 34b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 35b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruDataDrivenCollatorTest::DataDrivenCollatorTest() 36b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru: seq(StringCharacterIterator("")), 37b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Querustatus(U_ZERO_ERROR), 38b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Querusequences(status) 39b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{ 40b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru driver = TestDataModule::getTestDataModule("DataDrivenCollationTest", *this, status); 41b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru sequences.setDeleter(deleteSeqElement); 42b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UCA = (RuleBasedCollator*)Collator::createInstance("root", status); 43b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru} 44b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 45b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruDataDrivenCollatorTest::~DataDrivenCollatorTest() 46b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{ 47b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru delete driver; 48b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru delete UCA; 49b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru} 50b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 51b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruvoid DataDrivenCollatorTest::runIndexedTest( int32_t index, UBool exec, const char* &name, char* /*par */) 52b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru{ 53b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru if(driver != NULL) { 54b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru if (exec) 55b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru { 56b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru logln("TestSuite Collator: "); 57b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru } 58b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const DataMap *info = NULL; 59b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru TestData *testData = driver->createTestData(index, status); 60b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru if(U_SUCCESS(status)) { 61b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru name = testData->getName(); 62b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru if(testData->getInfo(info, status)) { 63b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru log(info->getString("Description", status)); 64b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru } 65b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru if(exec) { 66b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru log(name); 67b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru logln("---"); 68b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru logln(""); 69b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru processTest(testData); 70b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru } 71b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru delete testData; 72b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru } else { 73b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru name = ""; 74b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru } 75b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru } else { 766d5deb12725f146643d443090dfa11b206df528aJean-Baptiste Queru dataerrln("collate/DataDrivenTest data not initialized!"); 77b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru name = ""; 78b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru } 79b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 80b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 81b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru} 82b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 83b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUBool 84b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruDataDrivenCollatorTest::setTestSequence(const UnicodeString &setSequence, SeqElement &el) { 85b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru seq.setText(setSequence); 86b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru return getNextInSequence(el); 87b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru} 88b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 89b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru// Parses the sequence to be tested 90b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruUBool 91b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruDataDrivenCollatorTest::getNextInSequence(SeqElement &el) { 92b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru el.source.truncate(0); 93b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UBool quoted = FALSE; 94b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UBool quotedsingle = FALSE; 95b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UChar32 currChar = 0; 96b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 97b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru while(currChar != CharacterIterator::DONE) { 98b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru currChar= seq.next32PostInc(); 99b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru if(!quoted) { 100b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru if(u_isWhitespace(currChar)) { 101b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru continue; 102b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru } 103b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru switch(currChar) { 104b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru case CharacterIterator::DONE: 105b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru break; 106b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru case 0x003C /* < */: 107b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru el.relation = Collator::LESS; 108b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru currChar = CharacterIterator::DONE; 109b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru break; 110b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru case 0x003D /* = */: 111b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru el.relation = Collator::EQUAL; 112b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru currChar = CharacterIterator::DONE; 113b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru break; 114b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru case 0x003E /* > */: 115b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru el.relation = Collator::GREATER; 116b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru currChar = CharacterIterator::DONE; 117b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru break; 118b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru case 0x0027 /* ' */: /* very basic quoting */ 119b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru quoted = TRUE; 120b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru quotedsingle = FALSE; 121b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru break; 122b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru case 0x005c /* \ */: /* single quote */ 123b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru quoted = TRUE; 124b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru quotedsingle = TRUE; 125b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru break; 126b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru default: 127b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru el.source.append(currChar); 128b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru } 129b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru } else { 130b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru if(currChar == CharacterIterator::DONE) { 131b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru status = U_ILLEGAL_ARGUMENT_ERROR; 132b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru errln("Quote in sequence not closed!"); 133b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru return FALSE; 134b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru } else if(currChar == 0x0027) { 135b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru quoted = FALSE; 136b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru } else { 137b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru el.source.append(currChar); 138b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru } 139b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru if(quotedsingle) { 140b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru quoted = FALSE; 141b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru } 142b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru } 143b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru } 144b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru return seq.hasNext(); 145b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru} 146b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 147b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru// Reads the options string and sets appropriate attributes in collator 148b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruvoid 149b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruDataDrivenCollatorTest::processArguments(Collator *col, const UChar *start, int32_t optLen) { 150b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UChar *end = start+optLen; 151b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UColAttribute attrib; 152b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UColAttributeValue value; 153b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 154b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru if(optLen == 0) { 155b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru return; 156b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru } 157b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 158b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru start = ucol_tok_getNextArgument(start, end, &attrib, &value, &status); 159b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru while(start != NULL) { 160b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru if(U_SUCCESS(status)) { 161b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru col->setAttribute(attrib, value, status); 162b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru } 163b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru start = ucol_tok_getNextArgument(start, end, &attrib, &value, &status); 164b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru } 165b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru} 166b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 167b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruvoid 168b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruDataDrivenCollatorTest::processTest(TestData *testData) { 169b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru Collator *col = NULL; 170b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UChar *arguments = NULL; 171b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t argLen = 0; 172b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const DataMap *settings = NULL; 173b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const DataMap *currentCase = NULL; 174b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UErrorCode intStatus = U_ZERO_ERROR; 175b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UnicodeString testSetting; 176b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru while(testData->nextSettings(settings, status)) { 177b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru intStatus = U_ZERO_ERROR; 178b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru // try to get a locale 179b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru testSetting = settings->getString("TestLocale", intStatus); 180b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru if(U_SUCCESS(intStatus)) { 181b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru char localeName[256]; 182b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru testSetting.extract(0, testSetting.length(), localeName, ""); 183b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru col = Collator::createInstance(localeName, status); 184b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru if(U_SUCCESS(status)) { 185b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru logln("Testing collator for locale "+testSetting); 186b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru } else { 187b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru errln("Unable to instantiate collator for locale "+testSetting); 188b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru return; 189b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru } 190b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru } else { 191b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru // if no locale, try from rules 192b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru intStatus = U_ZERO_ERROR; 193b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru testSetting = settings->getString("Rules", intStatus); 194b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru if(U_SUCCESS(intStatus)) { 195b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru col = new RuleBasedCollator(testSetting, status); 196b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru if(U_SUCCESS(status)) { 197b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru logln("Testing collator for rules "+testSetting); 198b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru } else { 199b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru errln("Unable to instantiate collator for rules "+testSetting); 200b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru return; 201b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru } 202b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru } else { 203b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru errln("No collator definition!"); 204b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru } 205b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru } 206b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 207b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t cloneSize = 0; 208b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru uint8_t* cloneBuf = NULL; 209b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru RuleBasedCollator* clone = NULL; 210b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru if(col != NULL){ 211b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru RuleBasedCollator* rbc = (RuleBasedCollator*)col; 212b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru cloneSize = rbc->cloneBinary(NULL, 0, intStatus); 213b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru intStatus = U_ZERO_ERROR; 214b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru cloneBuf = (uint8_t*) malloc(cloneSize); 215b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru cloneSize = rbc->cloneBinary(cloneBuf, cloneSize, intStatus); 216b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru clone = new RuleBasedCollator(cloneBuf, cloneSize, UCA, intStatus); 217b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru if(U_FAILURE(intStatus)){ 218b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru errln("Could not clone the RuleBasedCollator. Error: %s", u_errorName(intStatus)); 219b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru intStatus= U_ZERO_ERROR; 220b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru } 221b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru // get attributes 222b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru testSetting = settings->getString("Arguments", intStatus); 223b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru if(U_SUCCESS(intStatus)) { 224b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru logln("Arguments: "+testSetting); 225b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru argLen = testSetting.length(); 226b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru arguments = testSetting.getBuffer(); 227b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru processArguments(col, arguments, argLen); 228b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru if(clone != NULL){ 229b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru processArguments(clone, arguments, argLen); 230b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru } 231b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru if(U_FAILURE(status)) { 232b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru errln("Couldn't process arguments"); 233b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru break; 234b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru } 235b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru } else { 236b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru intStatus = U_ZERO_ERROR; 237b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru } 238b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru // Start the processing 239b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru while(testData->nextCase(currentCase, status)) { 240b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UnicodeString sequence = currentCase->getString("sequence", status); 241b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru if(U_SUCCESS(status)) { 242b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru processSequence(col, sequence); 243b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru if(clone != NULL){ 244b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru processSequence(clone, sequence); 245b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru } 246b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru } 247b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru } 248b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru } else { 249b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru errln("Couldn't instantiate a collator!"); 250b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru } 251b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru delete clone; 252b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru free(cloneBuf); 253b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru delete col; 254b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru col = NULL; 255b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru } 256b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru} 257b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 258b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 259b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruvoid 260b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruDataDrivenCollatorTest::processSequence(Collator* col, const UnicodeString &sequence) { 261b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru Collator::EComparisonResult relation = Collator::EQUAL; 262b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UBool hasNext; 263b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru SeqElement *source = NULL; 264b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru SeqElement *target = NULL; 265b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t j = 0; 266b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 267b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru sequences.removeAllElements(); 268b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 269b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru target = new SeqElement(); 270b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 271b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru setTestSequence(sequence, *target); 272b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru sequences.addElement(target, status); 273b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 274b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru do { 275b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru relation = Collator::EQUAL; 276b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru target = new SeqElement(); 277b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru hasNext = getNextInSequence(*target); 278b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru for(j = sequences.size(); j > 0; j--) { 279b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru source = (SeqElement *)sequences.elementAt(j-1); 280b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru if(relation == Collator::EQUAL && source->relation != Collator::EQUAL) { 281b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru relation = source->relation; 282b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru } 283b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru doTest(col, source->source, target->source, relation); 284b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru } 285b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru sequences.addElement(target, status); 286b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru source = target; 287b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru } while(hasNext); 288b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru} 289b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 290b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#endif /* #if !UCONFIG_NO_COLLATION */ 291