]> git.saurik.com Git - apple/icu.git/blame - icuSources/test/intltest/encoll.cpp
ICU-511.32.tar.gz
[apple/icu.git] / icuSources / test / intltest / encoll.cpp
CommitLineData
b75a7d8f
A
1/********************************************************************
2 * COPYRIGHT:
729e4ab9 3 * Copyright (c) 1997-2009, International Business Machines Corporation and
b75a7d8f
A
4 * others. All Rights Reserved.
5 ********************************************************************/
6
7#include "unicode/utypes.h"
8
9#if !UCONFIG_NO_COLLATION
10
11#include "unicode/coll.h"
12#include "unicode/tblcoll.h"
13#include "unicode/unistr.h"
14#include "unicode/sortkey.h"
15#include "encoll.h"
16
17CollationEnglishTest::CollationEnglishTest()
18: myCollation(0)
19{
20 UErrorCode status = U_ZERO_ERROR;
21 myCollation = Collator::createInstance(Locale::getEnglish(), status);
22}
23
24CollationEnglishTest::~CollationEnglishTest()
25{
26 delete myCollation;
27}
28
46f4442e 29static const UChar testSourceCases[][CollationEnglishTest::MAX_TOKEN_LEN] = {
b75a7d8f
A
30 {(UChar)0x0061 /* 'a' */, (UChar)0x0062 /* 'b' */, 0},
31 {(UChar)0x0062 /* 'b' */, (UChar)0x006C /* 'l' */, (UChar)0x0061 /* 'a' */, (UChar)0x0063 /* 'c' */, (UChar)0x006B /* 'k' */, (UChar)0x002D /* '-' */, (UChar)0x0062 /* 'b' */, (UChar)0x0069 /* 'i' */, (UChar)0x0072 /* 'r' */, (UChar)0x0064 /* 'd' */, 0},
32 {(UChar)0x0062 /* 'b' */, (UChar)0x006C /* 'l' */, (UChar)0x0061 /* 'a' */, (UChar)0x0063 /* 'c' */, (UChar)0x006B /* 'k' */, (UChar)0x0020 /* ' ' */, (UChar)0x0062 /* 'b' */, (UChar)0x0069 /* 'i' */, (UChar)0x0072 /* 'r' */, (UChar)0x0064 /* 'd' */, 0},
33 {(UChar)0x0062 /* 'b' */, (UChar)0x006C /* 'l' */, (UChar)0x0061 /* 'a' */, (UChar)0x0063 /* 'c' */, (UChar)0x006B /* 'k' */, (UChar)0x002D /* '-' */, (UChar)0x0062 /* 'b' */, (UChar)0x0069 /* 'i' */, (UChar)0x0072 /* 'r' */, (UChar)0x0064 /* 'd' */, 0},
34 {(UChar)0x0048 /* 'H' */, (UChar)0x0065 /* 'e' */, (UChar)0x006C /* 'l' */, (UChar)0x006C /* 'l' */, (UChar)0x006F /* 'o' */, 0},
35 {(UChar)0x0041 /* 'A' */, (UChar)0x0042 /* 'B' */, (UChar)0x0043 /* 'C' */, 0},
36 {(UChar)0x0061 /* 'a' */, (UChar)0x0062 /* 'b' */, (UChar)0x0063 /* 'c' */, 0},
37 {(UChar)0x0062 /* 'b' */, (UChar)0x006C /* 'l' */, (UChar)0x0061 /* 'a' */, (UChar)0x0063 /* 'c' */, (UChar)0x006B /* 'k' */, (UChar)0x0062 /* 'b' */, (UChar)0x0069 /* 'i' */, (UChar)0x0072 /* 'r' */, (UChar)0x0064 /* 'd' */, 0},
38 {(UChar)0x0062 /* 'b' */, (UChar)0x006C /* 'l' */, (UChar)0x0061 /* 'a' */, (UChar)0x0063 /* 'c' */, (UChar)0x006B /* 'k' */, (UChar)0x002D /* '-' */, (UChar)0x0062 /* 'b' */, (UChar)0x0069 /* 'i' */, (UChar)0x0072 /* 'r' */, (UChar)0x0064 /* 'd' */, 0},
39 {(UChar)0x0062 /* 'b' */, (UChar)0x006C /* 'l' */, (UChar)0x0061 /* 'a' */, (UChar)0x0063 /* 'c' */, (UChar)0x006B /* 'k' */, (UChar)0x002D /* '-' */, (UChar)0x0062 /* 'b' */, (UChar)0x0069 /* 'i' */, (UChar)0x0072 /* 'r' */, (UChar)0x0064 /* 'd' */, 0},
40 {(UChar)0x0070 /* 'p' */, 0x00EA, (UChar)0x0063 /* 'c' */, (UChar)0x0068 /* 'h' */, (UChar)0x0065 /* 'e' */, 0},
41 {(UChar)0x0070 /* 'p' */, 0x00E9, (UChar)0x0063 /* 'c' */, (UChar)0x0068 /* 'h' */, 0x00E9, 0},
42 {0x00C4, (UChar)0x0042 /* 'B' */, 0x0308, (UChar)0x0043 /* 'C' */, 0x0308, 0},
43 {(UChar)0x0061 /* 'a' */, 0x0308, (UChar)0x0062 /* 'b' */, (UChar)0x0063 /* 'c' */, 0},
44 {(UChar)0x0070 /* 'p' */, 0x00E9, (UChar)0x0063 /* 'c' */, (UChar)0x0068 /* 'h' */, (UChar)0x0065 /* 'e' */, (UChar)0x0072 /* 'r' */, 0},
45 {(UChar)0x0072 /* 'r' */, (UChar)0x006F /* 'o' */, (UChar)0x006C /* 'l' */, (UChar)0x0065 /* 'e' */, (UChar)0x0073 /* 's' */, 0},
46 {(UChar)0x0061 /* 'a' */, (UChar)0x0062 /* 'b' */, (UChar)0x0063 /* 'c' */, 0},
47 {(UChar)0x0041 /* 'A' */, 0},
48 {(UChar)0x0041 /* 'A' */, 0},
49 {(UChar)0x0061 /* 'a' */, (UChar)0x0062 /* 'b' */, 0},
50 {(UChar)0x0074 /* 't' */, (UChar)0x0063 /* 'c' */, (UChar)0x006F /* 'o' */, (UChar)0x006D /* 'm' */, (UChar)0x0070 /* 'p' */, (UChar)0x0061 /* 'a' */, (UChar)0x0072 /* 'r' */, (UChar)0x0065 /* 'e' */, (UChar)0x0070 /* 'p' */, (UChar)0x006C /* 'l' */, (UChar)0x0061 /* 'a' */, (UChar)0x0069 /* 'i' */, (UChar)0x006E /* 'n' */, 0},
51 {(UChar)0x0061 /* 'a' */, (UChar)0x0062 /* 'b' */, 0},
52 {(UChar)0x0061 /* 'a' */, (UChar)0x0023 /* '#' */, (UChar)0x0062 /* 'b' */, 0},
53 {(UChar)0x0061 /* 'a' */, (UChar)0x0023 /* '#' */, (UChar)0x0062 /* 'b' */, 0},
54 {(UChar)0x0061 /* 'a' */, (UChar)0x0062 /* 'b' */, (UChar)0x0063 /* 'c' */, 0},
55 {(UChar)0x0041 /* 'A' */, (UChar)0x0062 /* 'b' */, (UChar)0x0063 /* 'c' */, (UChar)0x0064 /* 'd' */, (UChar)0x0061 /* 'a' */, 0},
56 {(UChar)0x0061 /* 'a' */, (UChar)0x0062 /* 'b' */, (UChar)0x0063 /* 'c' */, (UChar)0x0064 /* 'd' */, (UChar)0x0061 /* 'a' */, 0},
57 {(UChar)0x0061 /* 'a' */, (UChar)0x0062 /* 'b' */, (UChar)0x0063 /* 'c' */, (UChar)0x0064 /* 'd' */, (UChar)0x0061 /* 'a' */, 0},
58 {0x00E6, (UChar)0x0062 /* 'b' */, (UChar)0x0063 /* 'c' */, (UChar)0x0064 /* 'd' */, (UChar)0x0061 /* 'a' */, 0},
59 {0x00E4, (UChar)0x0062 /* 'b' */, (UChar)0x0063 /* 'c' */, (UChar)0x0064 /* 'd' */, (UChar)0x0061 /* 'a' */, 0},
60 {(UChar)0x0061 /* 'a' */, (UChar)0x0062 /* 'b' */, (UChar)0x0063 /* 'c' */, 0},
61 {(UChar)0x0061 /* 'a' */, (UChar)0x0062 /* 'b' */, (UChar)0x0063 /* 'c' */, 0},
62 {(UChar)0x0061 /* 'a' */, (UChar)0x0062 /* 'b' */, (UChar)0x0063 /* 'c' */, 0},
63 {(UChar)0x0061 /* 'a' */, (UChar)0x0062 /* 'b' */, (UChar)0x0063 /* 'c' */, 0},
64 {(UChar)0x0061 /* 'a' */, (UChar)0x0062 /* 'b' */, (UChar)0x0063 /* 'c' */, 0},
65 {(UChar)0x0061 /* 'a' */, (UChar)0x0063 /* 'c' */, (UChar)0x0048 /* 'H' */, (UChar)0x0063 /* 'c' */, 0},
66 {(UChar)0x0061 /* 'a' */, 0x0308, (UChar)0x0062 /* 'b' */, (UChar)0x0063 /* 'c' */, 0},
67 {(UChar)0x0074 /* 't' */, (UChar)0x0068 /* 'h' */, (UChar)0x0069 /* 'i' */, 0x0302, (UChar)0x0073 /* 's' */, 0},
68 {(UChar)0x0070 /* 'p' */, 0x00EA, (UChar)0x0063 /* 'c' */, (UChar)0x0068 /* 'h' */, (UChar)0x0065 /* 'e' */},
69 {(UChar)0x0061 /* 'a' */, (UChar)0x0062 /* 'b' */, (UChar)0x0063 /* 'c' */, 0},
70 {(UChar)0x0061 /* 'a' */, (UChar)0x0062 /* 'b' */, (UChar)0x0063 /* 'c' */, 0},
71 {(UChar)0x0061 /* 'a' */, (UChar)0x0062 /* 'b' */, (UChar)0x0063 /* 'c' */, 0},
72 {(UChar)0x0061 /* 'a' */, 0x00E6, (UChar)0x0063 /* 'c' */, 0},
73 {(UChar)0x0061 /* 'a' */, (UChar)0x0062 /* 'b' */, (UChar)0x0063 /* 'c' */, 0},
74 {(UChar)0x0061 /* 'a' */, (UChar)0x0062 /* 'b' */, (UChar)0x0063 /* 'c' */, 0},
75 {(UChar)0x0061 /* 'a' */, 0x00E6, (UChar)0x0063 /* 'c' */, 0},
76 {(UChar)0x0061 /* 'a' */, (UChar)0x0062 /* 'b' */, (UChar)0x0063 /* 'c' */, 0},
77 {(UChar)0x0061 /* 'a' */, (UChar)0x0062 /* 'b' */, (UChar)0x0063 /* 'c' */, 0},
78 {(UChar)0x0070 /* 'p' */, 0x00E9, (UChar)0x0063 /* 'c' */, (UChar)0x0068 /* 'h' */, 0x00E9, 0} // 49
79};
80
46f4442e 81static const UChar testTargetCases[][CollationEnglishTest::MAX_TOKEN_LEN] = {
b75a7d8f
A
82 {(UChar)0x0061 /* 'a' */, (UChar)0x0062 /* 'b' */, (UChar)0x0063 /* 'c' */, 0},
83 {(UChar)0x0062 /* 'b' */, (UChar)0x006C /* 'l' */, (UChar)0x0061 /* 'a' */, (UChar)0x0063 /* 'c' */, (UChar)0x006B /* 'k' */, (UChar)0x0062 /* 'b' */, (UChar)0x0069 /* 'i' */, (UChar)0x0072 /* 'r' */, (UChar)0x0064 /* 'd' */, 0},
84 {(UChar)0x0062 /* 'b' */, (UChar)0x006C /* 'l' */, (UChar)0x0061 /* 'a' */, (UChar)0x0063 /* 'c' */, (UChar)0x006B /* 'k' */, (UChar)0x002D /* '-' */, (UChar)0x0062 /* 'b' */, (UChar)0x0069 /* 'i' */, (UChar)0x0072 /* 'r' */, (UChar)0x0064 /* 'd' */, 0},
85 {(UChar)0x0062 /* 'b' */, (UChar)0x006C /* 'l' */, (UChar)0x0061 /* 'a' */, (UChar)0x0063 /* 'c' */, (UChar)0x006B /* 'k' */, 0},
86 {(UChar)0x0068 /* 'h' */, (UChar)0x0065 /* 'e' */, (UChar)0x006C /* 'l' */, (UChar)0x006C /* 'l' */, (UChar)0x006F /* 'o' */, 0},
87 {(UChar)0x0041 /* 'A' */, (UChar)0x0042 /* 'B' */, (UChar)0x0043 /* 'C' */, 0},
88 {(UChar)0x0041 /* 'A' */, (UChar)0x0042 /* 'B' */, (UChar)0x0043 /* 'C' */, 0},
89 {(UChar)0x0062 /* 'b' */, (UChar)0x006C /* 'l' */, (UChar)0x0061 /* 'a' */, (UChar)0x0063 /* 'c' */, (UChar)0x006B /* 'k' */, (UChar)0x0062 /* 'b' */, (UChar)0x0069 /* 'i' */, (UChar)0x0072 /* 'r' */, (UChar)0x0064 /* 'd' */, (UChar)0x0073 /* 's' */, 0},
90 {(UChar)0x0062 /* 'b' */, (UChar)0x006C /* 'l' */, (UChar)0x0061 /* 'a' */, (UChar)0x0063 /* 'c' */, (UChar)0x006B /* 'k' */, (UChar)0x0062 /* 'b' */, (UChar)0x0069 /* 'i' */, (UChar)0x0072 /* 'r' */, (UChar)0x0064 /* 'd' */, (UChar)0x0073 /* 's' */, 0},
91 {(UChar)0x0062 /* 'b' */, (UChar)0x006C /* 'l' */, (UChar)0x0061 /* 'a' */, (UChar)0x0063 /* 'c' */, (UChar)0x006B /* 'k' */, (UChar)0x0062 /* 'b' */, (UChar)0x0069 /* 'i' */, (UChar)0x0072 /* 'r' */, (UChar)0x0064 /* 'd' */, 0},
92 {(UChar)0x0070 /* 'p' */, 0x00E9, (UChar)0x0063 /* 'c' */, (UChar)0x0068 /* 'h' */, 0x00E9, 0},
93 {(UChar)0x0070 /* 'p' */, 0x00E9, (UChar)0x0063 /* 'c' */, (UChar)0x0068 /* 'h' */, (UChar)0x0065 /* 'e' */, (UChar)0x0072 /* 'r' */, 0},
94 {0x00C4, (UChar)0x0042 /* 'B' */, 0x0308, (UChar)0x0043 /* 'C' */, 0x0308, 0},
95 {(UChar)0x0041 /* 'A' */, 0x0308, (UChar)0x0062 /* 'b' */, (UChar)0x0063 /* 'c' */, 0},
96 {(UChar)0x0070 /* 'p' */, 0x00E9, (UChar)0x0063 /* 'c' */, (UChar)0x0068 /* 'h' */, (UChar)0x0065 /* 'e' */, 0},
97 {(UChar)0x0072 /* 'r' */, (UChar)0x006F /* 'o' */, 0x0302, (UChar)0x006C /* 'l' */, (UChar)0x0065 /* 'e' */, 0},
98 {(UChar)0x0041 /* 'A' */, 0x00E1, (UChar)0x0063 /* 'c' */, (UChar)0x0064 /* 'd' */, 0},
99 {(UChar)0x0041 /* 'A' */, 0x00E1, (UChar)0x0063 /* 'c' */, (UChar)0x0064 /* 'd' */, 0},
100 {(UChar)0x0061 /* 'a' */, (UChar)0x0062 /* 'b' */, (UChar)0x0063 /* 'c' */, 0},
101 {(UChar)0x0061 /* 'a' */, (UChar)0x0062 /* 'b' */, (UChar)0x0063 /* 'c' */, 0},
102 {(UChar)0x0054 /* 'T' */, (UChar)0x0043 /* 'C' */, (UChar)0x006F /* 'o' */, (UChar)0x006D /* 'm' */, (UChar)0x0070 /* 'p' */, (UChar)0x0061 /* 'a' */, (UChar)0x0072 /* 'r' */, (UChar)0x0065 /* 'e' */, (UChar)0x0050 /* 'P' */, (UChar)0x006C /* 'l' */, (UChar)0x0061 /* 'a' */, (UChar)0x0069 /* 'i' */, (UChar)0x006E /* 'n' */, 0},
103 {(UChar)0x0061 /* 'a' */, (UChar)0x0042 /* 'B' */, (UChar)0x0063 /* 'c' */, 0},
104 {(UChar)0x0061 /* 'a' */, (UChar)0x0023 /* '#' */, (UChar)0x0042 /* 'B' */, 0},
105 {(UChar)0x0061 /* 'a' */, (UChar)0x0026 /* '&' */, (UChar)0x0062 /* 'b' */, 0},
106 {(UChar)0x0061 /* 'a' */, (UChar)0x0023 /* '#' */, (UChar)0x0063 /* 'c' */, 0},
107 {(UChar)0x0061 /* 'a' */, (UChar)0x0062 /* 'b' */, (UChar)0x0063 /* 'c' */, (UChar)0x0064 /* 'd' */, (UChar)0x0061 /* 'a' */, 0},
108 {0x00C4, (UChar)0x0062 /* 'b' */, (UChar)0x0063 /* 'c' */, (UChar)0x0064 /* 'd' */, (UChar)0x0061 /* 'a' */, 0},
109 {0x00E4, (UChar)0x0062 /* 'b' */, (UChar)0x0063 /* 'c' */, (UChar)0x0064 /* 'd' */, (UChar)0x0061 /* 'a' */, 0},
110 {0x00C4, (UChar)0x0062 /* 'b' */, (UChar)0x0063 /* 'c' */, (UChar)0x0064 /* 'd' */, (UChar)0x0061 /* 'a' */, 0},
111 {0x00C4, (UChar)0x0062 /* 'b' */, (UChar)0x0063 /* 'c' */, (UChar)0x0064 /* 'd' */, (UChar)0x0061 /* 'a' */, 0},
112 {(UChar)0x0061 /* 'a' */, (UChar)0x0062 /* 'b' */, (UChar)0x0023 /* '#' */, (UChar)0x0063 /* 'c' */, 0},
113 {(UChar)0x0061 /* 'a' */, (UChar)0x0062 /* 'b' */, (UChar)0x0063 /* 'c' */, 0},
114 {(UChar)0x0061 /* 'a' */, (UChar)0x0062 /* 'b' */, (UChar)0x003D /* '=' */, (UChar)0x0063 /* 'c' */, 0},
115 {(UChar)0x0061 /* 'a' */, (UChar)0x0062 /* 'b' */, (UChar)0x0064 /* 'd' */, 0},
116 {0x00E4, (UChar)0x0062 /* 'b' */, (UChar)0x0063 /* 'c' */, 0},
117 {(UChar)0x0061 /* 'a' */, (UChar)0x0043 /* 'C' */, (UChar)0x0048 /* 'H' */, (UChar)0x0063 /* 'c' */, 0},
118 {0x00E4, (UChar)0x0062 /* 'b' */, (UChar)0x0063 /* 'c' */, 0},
119 {(UChar)0x0074 /* 't' */, (UChar)0x0068 /* 'h' */, 0x00EE, (UChar)0x0073 /* 's' */, 0},
120 {(UChar)0x0070 /* 'p' */, 0x00E9, (UChar)0x0063 /* 'c' */, (UChar)0x0068 /* 'h' */, 0x00E9, 0},
121 {(UChar)0x0061 /* 'a' */, (UChar)0x0042 /* 'B' */, (UChar)0x0043 /* 'C' */, 0},
122 {(UChar)0x0061 /* 'a' */, (UChar)0x0062 /* 'b' */, (UChar)0x0064 /* 'd' */, 0},
123 {0x00E4, (UChar)0x0062 /* 'b' */, (UChar)0x0063 /* 'c' */, 0},
124 {(UChar)0x0061 /* 'a' */, 0x00C6, (UChar)0x0063 /* 'c' */, 0},
125 {(UChar)0x0061 /* 'a' */, (UChar)0x0042 /* 'B' */, (UChar)0x0064 /* 'd' */, 0},
126 {0x00E4, (UChar)0x0062 /* 'b' */, (UChar)0x0063 /* 'c' */, 0},
127 {(UChar)0x0061 /* 'a' */, 0x00C6, (UChar)0x0063 /* 'c' */, 0},
128 {(UChar)0x0061 /* 'a' */, (UChar)0x0042 /* 'B' */, (UChar)0x0064 /* 'd' */, 0},
129 {0x00E4, (UChar)0x0062 /* 'b' */, (UChar)0x0063 /* 'c' */, 0},
130 {(UChar)0x0070 /* 'p' */, 0x00EA, (UChar)0x0063 /* 'c' */, (UChar)0x0068 /* 'h' */, (UChar)0x0065 /* 'e' */, 0} // 49
131};
132
46f4442e 133static const Collator::EComparisonResult results[] = {
b75a7d8f
A
134 Collator::LESS,
135 Collator::LESS, /*Collator::GREATER,*/
136 Collator::LESS,
137 Collator::GREATER,
138 Collator::GREATER,
139 Collator::EQUAL,
140 Collator::LESS,
141 Collator::LESS,
142 Collator::LESS,
143 Collator::LESS, /*Collator::GREATER,*/ /* 10 */
144 Collator::GREATER,
145 Collator::LESS,
146 Collator::EQUAL,
147 Collator::LESS,
148 Collator::GREATER,
149 Collator::GREATER,
150 Collator::GREATER,
151 Collator::LESS,
152 Collator::LESS,
153 Collator::LESS, /* 20 */
154 Collator::LESS,
155 Collator::LESS,
156 Collator::LESS,
157 Collator::GREATER,
158 Collator::GREATER,
159 Collator::GREATER,
160 /* Test Tertiary > 26 */
161 Collator::LESS,
162 Collator::LESS,
163 Collator::GREATER,
164 Collator::LESS, /* 30 */
165 Collator::GREATER,
166 Collator::EQUAL,
167 Collator::GREATER,
168 Collator::LESS,
169 Collator::LESS,
170 Collator::LESS,
171 /* test identical > 36 */
172 Collator::EQUAL,
173 Collator::EQUAL,
174 /* test primary > 38 */
175 Collator::EQUAL,
176 Collator::EQUAL, /* 40 */
177 Collator::LESS,
178 Collator::EQUAL,
179 Collator::EQUAL,
180 /* test secondary > 43 */
181 Collator::LESS,
182 Collator::LESS,
183 Collator::EQUAL,
184 Collator::LESS,
185 Collator::LESS,
186 Collator::LESS // 49
187};
188
46f4442e 189static const UChar testBugs[][CollationEnglishTest::MAX_TOKEN_LEN] = {
b75a7d8f
A
190 {0x61, 0},
191 {0x41, 0},
192 {0x65, 0},
193 {0x45, 0},
194 {0x00e9, 0},
195 {0x00e8, 0},
196 {0x00ea, 0},
197 {0x00eb, 0},
198 {0x65, 0x61, 0},
199 {0x78, 0}
200};
201
202// 0x0300 is grave, 0x0301 is acute
203// the order of elements in this array must be different than the order in CollationFrenchTest
46f4442e 204static const UChar testAcute[][CollationEnglishTest::MAX_TOKEN_LEN] = {
b75a7d8f
A
205 {0x65, 0x65, 0},
206 {0x65, 0x65, 0x0301, 0},
207 {0x65, 0x65, 0x0301, 0x0300, 0},
208 {0x65, 0x65, 0x0300, 0},
209 {0x65, 0x65, 0x0300, 0x0301, 0},
210 {0x65, 0x0301, 0x65, 0},
211 {0x65, 0x0301, 0x65, 0x0301, 0},
212 {0x65, 0x0301, 0x65, 0x0301, 0x0300, 0},
213 {0x65, 0x0301, 0x65, 0x0300, 0},
214 {0x65, 0x0301, 0x65, 0x0300, 0x0301, 0},
215 {0x65, 0x0301, 0x0300, 0x65, 0},
216 {0x65, 0x0301, 0x0300, 0x65, 0x0301, 0},
217 {0x65, 0x0301, 0x0300, 0x65, 0x0301, 0x0300, 0},
218 {0x65, 0x0301, 0x0300, 0x65, 0x0300, 0},
219 {0x65, 0x0301, 0x0300, 0x65, 0x0300, 0x0301, 0},
220 {0x65, 0x0300, 0x65, 0},
221 {0x65, 0x0300, 0x65, 0x0301, 0},
222 {0x65, 0x0300, 0x65, 0x0301, 0x0300, 0},
223 {0x65, 0x0300, 0x65, 0x0300, 0},
224 {0x65, 0x0300, 0x65, 0x0300, 0x0301, 0},
225 {0x65, 0x0300, 0x0301, 0x65, 0},
226 {0x65, 0x0300, 0x0301, 0x65, 0x0301, 0},
227 {0x65, 0x0300, 0x0301, 0x65, 0x0301, 0x0300, 0},
228 {0x65, 0x0300, 0x0301, 0x65, 0x0300, 0},
229 {0x65, 0x0300, 0x0301, 0x65, 0x0300, 0x0301, 0}
230};
231
232static const UChar testMore[][CollationEnglishTest::MAX_TOKEN_LEN] = {
233 {(UChar)0x0061 /* 'a' */, (UChar)0x0065 /* 'e' */, 0},
b75a7d8f
A
234 { 0x00E6, 0},
235 { 0x00C6, 0},
374ca955 236 {(UChar)0x0061 /* 'a' */, (UChar)0x0066 /* 'f' */, 0},
b75a7d8f
A
237 {(UChar)0x006F /* 'o' */, (UChar)0x0065 /* 'e' */, 0},
238 { 0x0153, 0},
239 { 0x0152, 0},
240 {(UChar)0x006F /* 'o' */, (UChar)0x0066 /* 'f' */, 0},
241};
242
243void CollationEnglishTest::TestTertiary(/* char* par */)
244{
245 int32_t i = 0;
246 myCollation->setStrength(Collator::TERTIARY);
247 for (i = 0; i < 38 ; i++)
248 {
249 doTest(myCollation, testSourceCases[i], testTargetCases[i], results[i]);
250 }
251
252 int32_t j = 0;
253 for (i = 0; i < 10; i++)
254 {
255 for (j = i+1; j < 10; j++)
256 {
257 doTest(myCollation, testBugs[i], testBugs[j], Collator::LESS);
258 }
259 }
260
261 //test more interesting cases
262 Collator::EComparisonResult expected;
263 const int32_t testMoreSize = (int32_t)(sizeof(testMore) / sizeof(testMore[0]));
264 for (i = 0; i < testMoreSize; i++)
265 {
266 for (j = 0; j < testMoreSize; j++)
267 {
268 if (i < j)
269 expected = Collator::LESS;
270 else if (i == j)
271 expected = Collator::EQUAL;
272 else // (i > j)
273 expected = Collator::GREATER;
274 doTest(myCollation, testMore[i], testMore[j], expected );
275 }
276 }
277
278}
279
280void CollationEnglishTest::TestPrimary(/* char* par */)
281{
282 int32_t i;
283 myCollation->setStrength(Collator::PRIMARY);
284 for (i = 38; i < 43 ; i++)
285 {
286 doTest(myCollation, testSourceCases[i], testTargetCases[i], results[i]);
287 }
288}
289
290void CollationEnglishTest::TestSecondary(/* char* par */)
291{
292 int32_t i;
293 myCollation->setStrength(Collator::SECONDARY);
294 for (i = 43; i < 49 ; i++)
295 {
296 doTest(myCollation, testSourceCases[i], testTargetCases[i], results[i]);
297 }
298
299 //test acute and grave ordering (compare to french collation)
300 int32_t j;
301 Collator::EComparisonResult expected;
302 const int32_t testAcuteSize = (int32_t)(sizeof(testAcute) / sizeof(testAcute[0]));
303 for (i = 0; i < testAcuteSize; i++)
304 {
305 for (j = 0; j < testAcuteSize; j++)
306 {
307 if (i < j)
308 expected = Collator::LESS;
309 else if (i == j)
310 expected = Collator::EQUAL;
311 else // (i > j)
312 expected = Collator::GREATER;
313 doTest(myCollation, testAcute[i], testAcute[j], expected );
314 }
315 }
316}
317
318void CollationEnglishTest::runIndexedTest( int32_t index, UBool exec, const char* &name, char* /*par*/ )
319{
320 if (exec) logln("TestSuite CollationEnglishTest: ");
321 if(myCollation) {
322 switch (index) {
323 case 0: name = "TestPrimary"; if (exec) TestPrimary(/* par */); break;
324 case 1: name = "TestSecondary"; if (exec) TestSecondary(/* par */); break;
325 case 2: name = "TestTertiary"; if (exec) TestTertiary(/* par */); break;
326 default: name = ""; break;
327 }
328 } else {
729e4ab9 329 dataerrln("Collator couldn't be instantiated!");
b75a7d8f
A
330 name = "";
331 }
332}
333
334#endif /* #if !UCONFIG_NO_COLLATION */