1 // Copyright (C) 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3 /********************************************************************
5 * Copyright (c) 1997-2009, International Business Machines Corporation and
6 * others. All Rights Reserved.
7 ********************************************************************/
9 #include "unicode/unistr.h"
11 #if !UCONFIG_NO_COLLATION
13 #include "unicode/tstdtmod.h"
14 #include "unicode/coll.h"
15 #include "unicode/tblcoll.h"
16 #include "unicode/sortkey.h"
20 CollationTurkishTest::CollationTurkishTest()
23 UErrorCode status = U_ZERO_ERROR;
24 myCollation = Collator::createInstance(Locale("tr", "", ""),status);
27 CollationTurkishTest::~CollationTurkishTest()
32 const UChar CollationTurkishTest::testSourceCases[][CollationTurkishTest::MAX_TOKEN_LEN] = {
34 {0x76, 0x00E4, 0x74, 0},
35 {0x6f, 0x6c, 0x64, 0},
36 {0x00FC, 0x6f, 0x69, 0x64, 0},
37 {0x68, 0x011E, 0x61, 0x6c, 0x74, 0},
38 {0x73, 0x74, 0x72, 0x65, 0x73, 0x015E, 0},
39 {0x76, 0x6f, 0x0131, 0x64, 0},
40 {0x69, 0x64, 0x65, 0x61, 0},
41 {0x00FC, 0x6f, 0x69, 0x64, 0},
42 {0x76, 0x6f, 0x0131, 0x64, 0},
43 {0x69, 0x64, 0x65, 0x61, 0}
46 const UChar CollationTurkishTest::testTargetCases[][CollationTurkishTest::MAX_TOKEN_LEN] = {
48 {0x76, 0x62, 0x74, 0},
49 {0x00D6, 0x61, 0x79, 0},
50 {0x76, 0x6f, 0x69, 0x64, 0},
51 {0x68, 0x61, 0x6c, 0x74, 0},
52 {0x015E, 0x74, 0x72, 0x65, 0x015E, 0x73, 0},
53 {0x76, 0x6f, 0x69, 0x64, 0},
54 {0x49, 0x64, 0x65, 0x61, 0},
55 {0x76, 0x6f, 0x69, 0x64, 0},
56 {0x76, 0x6f, 0x69, 0x64, 0},
57 {0x49, 0x64, 0x65, 0x61, 0}
60 const Collator::EComparisonResult CollationTurkishTest::results[] = {
75 void CollationTurkishTest::TestTertiary(/* char* par */)
78 myCollation->setStrength(Collator::TERTIARY);
79 for (i = 0; i < 8 ; i++) {
80 doTest(myCollation, testSourceCases[i], testTargetCases[i], results[i]);
83 void CollationTurkishTest::TestPrimary(/* char* par */)
86 myCollation->setStrength(Collator::PRIMARY);
87 for (i = 8; i < 11; i++) {
88 doTest(myCollation, testSourceCases[i], testTargetCases[i], results[i]);
92 void CollationTurkishTest::runIndexedTest( int32_t index, UBool exec, const char* &name, char* /*par*/ )
94 if (exec) logln("TestSuite CollationTurkishTest: ");
96 if((!myCollation) && exec) {
97 dataerrln(__FILE__ " cannot test - failed to create collator.");
102 case 0: name = "TestPrimary"; if (exec) TestPrimary(/* par */); break;
103 case 1: name = "TestTertiary"; if (exec) TestTertiary(/* par */); break;
104 default: name = ""; break;
108 #endif /* #if !UCONFIG_NO_COLLATION */