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