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