1ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/******************************************************************** 2ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * COPYRIGHT: 385bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho * Copyright (c) 1997-2009, International Business Machines Corporation and 4ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * others. All Rights Reserved. 5ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru ********************************************************************/ 6ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 7ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "unicode/unistr.h" 8ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 9ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#if !UCONFIG_NO_COLLATION 10ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 11ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "unicode/tstdtmod.h" 12ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "unicode/coll.h" 13ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "unicode/tblcoll.h" 14ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "unicode/sortkey.h" 15ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "trcoll.h" 16ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "sfwdchit.h" 17ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 18ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruCollationTurkishTest::CollationTurkishTest() 19ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru: myCollation(0) 20ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru{ 21ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UErrorCode status = U_ZERO_ERROR; 22ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru myCollation = Collator::createInstance(Locale("tr", "", ""),status); 23ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru} 24ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 25ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruCollationTurkishTest::~CollationTurkishTest() 26ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru{ 27ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru delete myCollation; 28ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru} 29ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 30ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruconst UChar CollationTurkishTest::testSourceCases[][CollationTurkishTest::MAX_TOKEN_LEN] = { 31ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru {0x73, 0x0327, 0}, 32ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru {0x76, 0x00E4, 0x74, 0}, 33ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru {0x6f, 0x6c, 0x64, 0}, 34ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru {0x00FC, 0x6f, 0x69, 0x64, 0}, 35ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru {0x68, 0x011E, 0x61, 0x6c, 0x74, 0}, 36ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru {0x73, 0x74, 0x72, 0x65, 0x73, 0x015E, 0}, 37ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru {0x76, 0x6f, 0x0131, 0x64, 0}, 38ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru {0x69, 0x64, 0x65, 0x61, 0}, 39ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru {0x00FC, 0x6f, 0x69, 0x64, 0}, 40ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru {0x76, 0x6f, 0x0131, 0x64, 0}, 41ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru {0x69, 0x64, 0x65, 0x61, 0} 42ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}; 43ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 44ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruconst UChar CollationTurkishTest::testTargetCases[][CollationTurkishTest::MAX_TOKEN_LEN] = { 45ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru {0x75, 0x0308, 0}, 46ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru {0x76, 0x62, 0x74, 0}, 47ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru {0x00D6, 0x61, 0x79, 0}, 48ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru {0x76, 0x6f, 0x69, 0x64, 0}, 49ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru {0x68, 0x61, 0x6c, 0x74, 0}, 50ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru {0x015E, 0x74, 0x72, 0x65, 0x015E, 0x73, 0}, 51ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru {0x76, 0x6f, 0x69, 0x64, 0}, 52ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru {0x49, 0x64, 0x65, 0x61, 0}, 53ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru {0x76, 0x6f, 0x69, 0x64, 0}, 54ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru {0x76, 0x6f, 0x69, 0x64, 0}, 55ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru {0x49, 0x64, 0x65, 0x61, 0} 56ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}; 57ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 58ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruconst Collator::EComparisonResult CollationTurkishTest::results[] = { 59ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru Collator::LESS, 60ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru Collator::LESS, 61ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru Collator::LESS, 62ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru Collator::LESS, 63ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru Collator::GREATER, 64ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru Collator::LESS, 65ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru Collator::LESS, 66ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru Collator::GREATER, 67ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru // test priamry > 8 68ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru Collator::LESS, 69ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru Collator::LESS, 70ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru Collator::GREATER 71ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}; 72ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 73ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruvoid CollationTurkishTest::TestTertiary(/* char* par */) 74ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru{ 75ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru int32_t i = 0; 76ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru myCollation->setStrength(Collator::TERTIARY); 77ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru for (i = 0; i < 8 ; i++) { 78ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru doTest(myCollation, testSourceCases[i], testTargetCases[i], results[i]); 79ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 80ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru} 81ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruvoid CollationTurkishTest::TestPrimary(/* char* par */) 82ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru{ 83ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru int32_t i; 84ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru myCollation->setStrength(Collator::PRIMARY); 85ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru for (i = 8; i < 11; i++) { 86ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru doTest(myCollation, testSourceCases[i], testTargetCases[i], results[i]); 87ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 88ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru} 89ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 90ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruvoid CollationTurkishTest::runIndexedTest( int32_t index, UBool exec, const char* &name, char* /*par*/ ) 91ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru{ 92ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru if (exec) logln("TestSuite CollationTurkishTest: "); 93ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 94ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru if((!myCollation) && exec) { 9585bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho dataerrln(__FILE__ " cannot test - failed to create collator."); 96ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru name = "some test"; 97ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru return; 98ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 99ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru switch (index) { 100ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru case 0: name = "TestPrimary"; if (exec) TestPrimary(/* par */); break; 101ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru case 1: name = "TestTertiary"; if (exec) TestTertiary(/* par */); break; 102ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru default: name = ""; break; 103ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 104ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru} 105ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 106ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#endif /* #if !UCONFIG_NO_COLLATION */ 107