1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3 /********************************************************************
5 * Copyright (c) 1997-2016, International Business Machines Corporation and
6 * others. All Rights Reserved.
7 ********************************************************************/
9 #include "unicode/utypes.h"
11 #if !UCONFIG_NO_COLLATION
13 #include "unicode/coll.h"
14 #include "unicode/tblcoll.h"
15 #include "unicode/unistr.h"
16 #include "unicode/sortkey.h"
20 CollationEnglishTest::CollationEnglishTest()
23 UErrorCode status
= U_ZERO_ERROR
;
24 myCollation
= Collator::createInstance(Locale::getEnglish(), status
);
27 CollationEnglishTest::~CollationEnglishTest()
32 static const UChar testSourceCases
[][CollationEnglishTest::MAX_TOKEN_LEN
] = {
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
84 static const UChar testTargetCases
[][CollationEnglishTest::MAX_TOKEN_LEN
] = {
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
136 static const Collator::EComparisonResult results
[] = {
138 Collator::LESS
, /*Collator::GREATER,*/
146 Collator::LESS
, /*Collator::GREATER,*/ /* 10 */
156 Collator::LESS
, /* 20 */
163 /* Test Tertiary > 26 */
167 Collator::LESS
, /* 30 */
174 /* test identical > 36 */
177 /* test primary > 38 */
179 Collator::EQUAL
, /* 40 */
183 /* test secondary > 43 */
192 static const UChar testBugs
[][CollationEnglishTest::MAX_TOKEN_LEN
] = {
205 // 0x0300 is grave, 0x0301 is acute
206 // the order of elements in this array must be different than the order in CollationFrenchTest
207 static const UChar testAcute
[][CollationEnglishTest::MAX_TOKEN_LEN
] = {
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}
235 static const UChar testMore
[][CollationEnglishTest::MAX_TOKEN_LEN
] = {
236 {(UChar
)0x0061 /* 'a' */, (UChar
)0x0065 /* 'e' */, 0},
239 {(UChar
)0x0061 /* 'a' */, (UChar
)0x0066 /* 'f' */, 0},
240 {(UChar
)0x006F /* 'o' */, (UChar
)0x0065 /* 'e' */, 0},
243 {(UChar
)0x006F /* 'o' */, (UChar
)0x0066 /* 'f' */, 0},
246 void CollationEnglishTest::TestTertiary(/* char* par */)
249 myCollation
->setStrength(Collator::TERTIARY
);
250 for (i
= 0; i
< 38 ; i
++)
252 doTest(myCollation
, testSourceCases
[i
], testTargetCases
[i
], results
[i
]);
256 for (i
= 0; i
< 10; i
++)
258 for (j
= i
+1; j
< 10; j
++)
260 doTest(myCollation
, testBugs
[i
], testBugs
[j
], Collator::LESS
);
264 //test more interesting cases
265 Collator::EComparisonResult expected
;
266 const int32_t testMoreSize
= UPRV_LENGTHOF(testMore
);
267 for (i
= 0; i
< testMoreSize
; i
++)
269 for (j
= 0; j
< testMoreSize
; j
++)
272 expected
= Collator::LESS
;
274 expected
= Collator::EQUAL
;
276 expected
= Collator::GREATER
;
277 doTest(myCollation
, testMore
[i
], testMore
[j
], expected
);
283 void CollationEnglishTest::TestPrimary(/* char* par */)
286 myCollation
->setStrength(Collator::PRIMARY
);
287 for (i
= 38; i
< 43 ; i
++)
289 doTest(myCollation
, testSourceCases
[i
], testTargetCases
[i
], results
[i
]);
293 void CollationEnglishTest::TestSecondary(/* char* par */)
296 myCollation
->setStrength(Collator::SECONDARY
);
297 for (i
= 43; i
< 49 ; i
++)
299 doTest(myCollation
, testSourceCases
[i
], testTargetCases
[i
], results
[i
]);
302 //test acute and grave ordering (compare to french collation)
304 Collator::EComparisonResult expected
;
305 const int32_t testAcuteSize
= UPRV_LENGTHOF(testAcute
);
306 for (i
= 0; i
< testAcuteSize
; i
++)
308 for (j
= 0; j
< testAcuteSize
; j
++)
311 expected
= Collator::LESS
;
313 expected
= Collator::EQUAL
;
315 expected
= Collator::GREATER
;
316 doTest(myCollation
, testAcute
[i
], testAcute
[j
], expected
);
321 void CollationEnglishTest::runIndexedTest( int32_t index
, UBool exec
, const char* &name
, char* /*par*/ )
323 if (exec
) logln("TestSuite CollationEnglishTest: ");
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;
332 dataerrln("Collator couldn't be instantiated!");
337 #endif /* #if !UCONFIG_NO_COLLATION */