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