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