1 /********************************************************************
3 * Copyright (c) 1997-2016, International Business Machines Corporation and
4 * others. All Rights Reserved.
5 ********************************************************************/
6 /********************************************************************************
10 * Modification History:
12 * Madhu Katragadda Ported for C API
13 *********************************************************************************/
15 * CollationEnglishTest is a third level test class. This tests the locale
16 * specific primary, secondary and tertiary rules. For example, the ignorable
17 * character '-' in string "black-bird". The en_US locale uses the default
18 * collation rules as its sorting sequence.
24 #include "unicode/utypes.h"
26 #if !UCONFIG_NO_COLLATION
28 #include "unicode/ucol.h"
29 #include "unicode/uloc.h"
35 #include "unicode/ustring.h"
37 static UCollator
*myCollation
= NULL
;
38 const static UChar testSourceCases
[][MAX_TOKEN_LEN
] = {
39 {(UChar
)0x0061 /* 'a' */, (UChar
)0x0062 /* 'b' */, 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
)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},
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
)0x0048 /* 'H' */, (UChar
)0x0065 /* 'e' */, (UChar
)0x006C /* 'l' */, (UChar
)0x006C /* 'l' */, (UChar
)0x006F /* 'o' */, 0},
44 {(UChar
)0x0041 /* 'A' */, (UChar
)0x0042 /* 'B' */, (UChar
)0x0043 /* 'C' */, 0},
45 {(UChar
)0x0061 /* 'a' */, (UChar
)0x0062 /* 'b' */, (UChar
)0x0063 /* 'c' */, 0},
46 {(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},
47 {(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},
48 {(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},
49 {(UChar
)0x0070 /* 'p' */, 0x00EA, (UChar
)0x0063 /* 'c' */, (UChar
)0x0068 /* 'h' */, (UChar
)0x0065 /* 'e' */, 0},
50 {(UChar
)0x0070 /* 'p' */, 0x00E9, (UChar
)0x0063 /* 'c' */, (UChar
)0x0068 /* 'h' */, 0x00E9, 0},
51 {0x00C4, (UChar
)0x0042 /* 'B' */, 0x0308, (UChar
)0x0043 /* 'C' */, 0x0308, 0},
52 {(UChar
)0x0061 /* 'a' */, 0x0308, (UChar
)0x0062 /* 'b' */, (UChar
)0x0063 /* 'c' */, 0},
53 {(UChar
)0x0070 /* 'p' */, 0x00E9, (UChar
)0x0063 /* 'c' */, (UChar
)0x0068 /* 'h' */, (UChar
)0x0065 /* 'e' */, (UChar
)0x0072 /* 'r' */, 0},
54 {(UChar
)0x0072 /* 'r' */, (UChar
)0x006F /* 'o' */, (UChar
)0x006C /* 'l' */, (UChar
)0x0065 /* 'e' */, (UChar
)0x0073 /* 's' */, 0},
55 {(UChar
)0x0061 /* 'a' */, (UChar
)0x0062 /* 'b' */, (UChar
)0x0063 /* 'c' */, 0},
56 {(UChar
)0x0041 /* 'A' */, 0},
57 {(UChar
)0x0041 /* 'A' */, 0},
58 {(UChar
)0x0061 /* 'a' */, (UChar
)0x0062 /* 'b' */, 0},
59 {(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},
60 {(UChar
)0x0061 /* 'a' */, (UChar
)0x0062 /* 'b' */, 0},
61 {(UChar
)0x0061 /* 'a' */, (UChar
)0x0023 /* '#' */, (UChar
)0x0062 /* 'b' */, 0},
62 {(UChar
)0x0061 /* 'a' */, (UChar
)0x0023 /* '#' */, (UChar
)0x0062 /* 'b' */, 0},
63 {(UChar
)0x0061 /* 'a' */, (UChar
)0x0062 /* 'b' */, (UChar
)0x0063 /* 'c' */, 0},
64 {(UChar
)0x0041 /* 'A' */, (UChar
)0x0062 /* 'b' */, (UChar
)0x0063 /* 'c' */, (UChar
)0x0064 /* 'd' */, (UChar
)0x0061 /* 'a' */, 0},
65 {(UChar
)0x0061 /* 'a' */, (UChar
)0x0062 /* 'b' */, (UChar
)0x0063 /* 'c' */, (UChar
)0x0064 /* 'd' */, (UChar
)0x0061 /* 'a' */, 0},
66 {(UChar
)0x0061 /* 'a' */, (UChar
)0x0062 /* 'b' */, (UChar
)0x0063 /* 'c' */, (UChar
)0x0064 /* 'd' */, (UChar
)0x0061 /* 'a' */, 0},
67 {0x00E6, (UChar
)0x0062 /* 'b' */, (UChar
)0x0063 /* 'c' */, (UChar
)0x0064 /* 'd' */, (UChar
)0x0061 /* 'a' */, 0},
68 {0x00E4, (UChar
)0x0062 /* 'b' */, (UChar
)0x0063 /* 'c' */, (UChar
)0x0064 /* 'd' */, (UChar
)0x0061 /* 'a' */, 0},
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' */, (UChar
)0x0062 /* 'b' */, (UChar
)0x0063 /* 'c' */, 0},
73 {(UChar
)0x0061 /* 'a' */, (UChar
)0x0062 /* 'b' */, (UChar
)0x0063 /* 'c' */, 0},
74 {(UChar
)0x0061 /* 'a' */, (UChar
)0x0063 /* 'c' */, (UChar
)0x0048 /* 'H' */, (UChar
)0x0063 /* 'c' */, 0},
75 {(UChar
)0x0061 /* 'a' */, 0x0308, (UChar
)0x0062 /* 'b' */, (UChar
)0x0063 /* 'c' */, 0},
76 {(UChar
)0x0074 /* 't' */, (UChar
)0x0068 /* 'h' */, (UChar
)0x0069 /* 'i' */, 0x0302, (UChar
)0x0073 /* 's' */, 0},
77 {(UChar
)0x0070 /* 'p' */, 0x00EA, (UChar
)0x0063 /* 'c' */, (UChar
)0x0068 /* 'h' */, (UChar
)0x0065 /* 'e' */},
78 {(UChar
)0x0061 /* 'a' */, (UChar
)0x0062 /* 'b' */, (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
)0x0061 /* 'a' */, 0x00E6, (UChar
)0x0063 /* 'c' */, 0},
82 {(UChar
)0x0061 /* 'a' */, (UChar
)0x0062 /* 'b' */, (UChar
)0x0063 /* 'c' */, 0},
83 {(UChar
)0x0061 /* 'a' */, (UChar
)0x0062 /* 'b' */, (UChar
)0x0063 /* 'c' */, 0},
84 {(UChar
)0x0061 /* 'a' */, 0x00E6, (UChar
)0x0063 /* 'c' */, 0},
85 {(UChar
)0x0061 /* 'a' */, (UChar
)0x0062 /* 'b' */, (UChar
)0x0063 /* 'c' */, 0},
86 {(UChar
)0x0061 /* 'a' */, (UChar
)0x0062 /* 'b' */, (UChar
)0x0063 /* 'c' */, 0},
87 {(UChar
)0x0070 /* 'p' */, 0x00E9, (UChar
)0x0063 /* 'c' */, (UChar
)0x0068 /* 'h' */, 0x00E9, 0}
90 const static UChar testTargetCases
[][MAX_TOKEN_LEN
] = {
91 {(UChar
)0x0061 /* 'a' */, (UChar
)0x0062 /* 'b' */, (UChar
)0x0063 /* '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' */, 0},
93 {(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},
94 {(UChar
)0x0062 /* 'b' */, (UChar
)0x006C /* 'l' */, (UChar
)0x0061 /* 'a' */, (UChar
)0x0063 /* 'c' */, (UChar
)0x006B /* 'k' */, 0},
95 {(UChar
)0x0068 /* 'h' */, (UChar
)0x0065 /* 'e' */, (UChar
)0x006C /* 'l' */, (UChar
)0x006C /* 'l' */, (UChar
)0x006F /* 'o' */, 0},
96 {(UChar
)0x0041 /* 'A' */, (UChar
)0x0042 /* 'B' */, (UChar
)0x0043 /* 'C' */, 0},
97 {(UChar
)0x0041 /* 'A' */, (UChar
)0x0042 /* 'B' */, (UChar
)0x0043 /* 'C' */, 0},
98 {(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},
99 {(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},
100 {(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},
101 {(UChar
)0x0070 /* 'p' */, 0x00E9, (UChar
)0x0063 /* 'c' */, (UChar
)0x0068 /* 'h' */, 0x00E9, 0},
102 {(UChar
)0x0070 /* 'p' */, 0x00E9, (UChar
)0x0063 /* 'c' */, (UChar
)0x0068 /* 'h' */, (UChar
)0x0065 /* 'e' */, (UChar
)0x0072 /* 'r' */, 0},
103 {0x00C4, (UChar
)0x0042 /* 'B' */, 0x0308, (UChar
)0x0043 /* 'C' */, 0x0308, 0},
104 {(UChar
)0x0041 /* 'A' */, 0x0308, (UChar
)0x0062 /* 'b' */, (UChar
)0x0063 /* 'c' */, 0},
105 {(UChar
)0x0070 /* 'p' */, 0x00E9, (UChar
)0x0063 /* 'c' */, (UChar
)0x0068 /* 'h' */, (UChar
)0x0065 /* 'e' */, 0},
106 {(UChar
)0x0072 /* 'r' */, (UChar
)0x006F /* 'o' */, 0x0302, (UChar
)0x006C /* 'l' */, (UChar
)0x0065 /* 'e' */, 0},
107 {(UChar
)0x0041 /* 'A' */, 0x00E1, (UChar
)0x0063 /* 'c' */, (UChar
)0x0064 /* 'd' */, 0},
108 {(UChar
)0x0041 /* 'A' */, 0x00E1, (UChar
)0x0063 /* 'c' */, (UChar
)0x0064 /* 'd' */, 0},
109 {(UChar
)0x0061 /* 'a' */, (UChar
)0x0062 /* 'b' */, (UChar
)0x0063 /* 'c' */, 0},
110 {(UChar
)0x0061 /* 'a' */, (UChar
)0x0062 /* 'b' */, (UChar
)0x0063 /* 'c' */, 0},
111 {(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},
112 {(UChar
)0x0061 /* 'a' */, (UChar
)0x0042 /* 'B' */, (UChar
)0x0063 /* 'c' */, 0},
113 {(UChar
)0x0061 /* 'a' */, (UChar
)0x0023 /* '#' */, (UChar
)0x0042 /* 'B' */, 0},
114 {(UChar
)0x0061 /* 'a' */, (UChar
)0x0026 /* '&' */, (UChar
)0x0062 /* 'b' */, 0},
115 {(UChar
)0x0061 /* 'a' */, (UChar
)0x0023 /* '#' */, (UChar
)0x0063 /* 'c' */, 0},
116 {(UChar
)0x0061 /* 'a' */, (UChar
)0x0062 /* 'b' */, (UChar
)0x0063 /* 'c' */, (UChar
)0x0064 /* 'd' */, (UChar
)0x0061 /* 'a' */, 0},
117 {0x00C4, (UChar
)0x0062 /* 'b' */, (UChar
)0x0063 /* 'c' */, (UChar
)0x0064 /* 'd' */, (UChar
)0x0061 /* 'a' */, 0},
118 {0x00E4, (UChar
)0x0062 /* 'b' */, (UChar
)0x0063 /* 'c' */, (UChar
)0x0064 /* 'd' */, (UChar
)0x0061 /* 'a' */, 0},
119 {0x00C4, (UChar
)0x0062 /* 'b' */, (UChar
)0x0063 /* 'c' */, (UChar
)0x0064 /* 'd' */, (UChar
)0x0061 /* 'a' */, 0},
120 {0x00C4, (UChar
)0x0062 /* 'b' */, (UChar
)0x0063 /* 'c' */, (UChar
)0x0064 /* 'd' */, (UChar
)0x0061 /* 'a' */, 0},
121 {(UChar
)0x0061 /* 'a' */, (UChar
)0x0062 /* 'b' */, (UChar
)0x0023 /* '#' */, (UChar
)0x0063 /* 'c' */, 0},
122 {(UChar
)0x0061 /* 'a' */, (UChar
)0x0062 /* 'b' */, (UChar
)0x0063 /* 'c' */, 0},
123 {(UChar
)0x0061 /* 'a' */, (UChar
)0x0062 /* 'b' */, (UChar
)0x003D /* '=' */, (UChar
)0x0063 /* 'c' */, 0},
124 {(UChar
)0x0061 /* 'a' */, (UChar
)0x0062 /* 'b' */, (UChar
)0x0064 /* 'd' */, 0},
125 {0x00E4, (UChar
)0x0062 /* 'b' */, (UChar
)0x0063 /* 'c' */, 0},
126 {(UChar
)0x0061 /* 'a' */, (UChar
)0x0043 /* 'C' */, (UChar
)0x0048 /* 'H' */, (UChar
)0x0063 /* 'c' */, 0},
127 {0x00E4, (UChar
)0x0062 /* 'b' */, (UChar
)0x0063 /* 'c' */, 0},
128 {(UChar
)0x0074 /* 't' */, (UChar
)0x0068 /* 'h' */, 0x00EE, (UChar
)0x0073 /* 's' */, 0},
129 {(UChar
)0x0070 /* 'p' */, 0x00E9, (UChar
)0x0063 /* 'c' */, (UChar
)0x0068 /* 'h' */, 0x00E9, 0},
130 {(UChar
)0x0061 /* 'a' */, (UChar
)0x0042 /* 'B' */, (UChar
)0x0043 /* 'C' */, 0},
131 {(UChar
)0x0061 /* 'a' */, (UChar
)0x0062 /* 'b' */, (UChar
)0x0064 /* 'd' */, 0},
132 {0x00E4, (UChar
)0x0062 /* 'b' */, (UChar
)0x0063 /* 'c' */, 0},
133 {(UChar
)0x0061 /* 'a' */, 0x00C6, (UChar
)0x0063 /* 'c' */, 0},
134 {(UChar
)0x0061 /* 'a' */, (UChar
)0x0042 /* 'B' */, (UChar
)0x0064 /* 'd' */, 0},
135 {0x00E4, (UChar
)0x0062 /* 'b' */, (UChar
)0x0063 /* 'c' */, 0},
136 {(UChar
)0x0061 /* 'a' */, 0x00C6, (UChar
)0x0063 /* 'c' */, 0},
137 {(UChar
)0x0061 /* 'a' */, (UChar
)0x0042 /* 'B' */, (UChar
)0x0064 /* 'd' */, 0},
138 {0x00E4, (UChar
)0x0062 /* 'b' */, (UChar
)0x0063 /* 'c' */, 0},
139 {(UChar
)0x0070 /* 'p' */, 0x00EA, (UChar
)0x0063 /* 'c' */, (UChar
)0x0068 /* 'h' */, (UChar
)0x0065 /* 'e' */, 0}
142 const static UCollationResult results
[] = {
144 UCOL_LESS
, /*UCOL_GREATER,*/
152 UCOL_LESS
, /*UCOL_GREATER,*/ /* 10 */
169 /* Test Tertiary > 26 */
180 /* test identical > 36 */
183 /* test primary > 38 */
189 /* test secondary > 43 */
198 const static UChar testBugs
[][MAX_TOKEN_LEN
] = {
199 {(UChar
)0x0061 /* 'a' */, 0},
200 {(UChar
)0x0041 /* 'A' */, 0},
201 {(UChar
)0x0065 /* 'e' */, 0},
202 {(UChar
)0x0045 /* 'E' */, 0},
207 {(UChar
)0x0065 /* 'e' */, (UChar
)0x0061 /* 'a' */, 0},
208 {(UChar
)0x0078 /* 'x' */, 0}
212 /* 0x0300 is grave, 0x0301 is acute
213 the order of elements in this array must be different than the order in CollationFrenchTest */
214 const static UChar testAcute
[][MAX_TOKEN_LEN
] = {
215 {(UChar
)0x0065 /* 'e' */, (UChar
)0x0065 /* 'e' */, 0},
216 {(UChar
)0x0065 /* 'e' */, (UChar
)0x0065 /* 'e' */, 0x0301, 0},
217 {(UChar
)0x0065 /* 'e' */, (UChar
)0x0065 /* 'e' */, 0x0301, 0x0300, 0},
218 {(UChar
)0x0065 /* 'e' */, (UChar
)0x0065 /* 'e' */, 0x0300, 0},
219 {(UChar
)0x0065 /* 'e' */, (UChar
)0x0065 /* 'e' */, 0x0300, 0x0301, 0},
220 {(UChar
)0x0065 /* 'e' */, 0x0301, (UChar
)0x0065 /* 'e' */, 0},
221 {(UChar
)0x0065 /* 'e' */, 0x0301, (UChar
)0x0065 /* 'e' */, 0x0301, 0},
222 {(UChar
)0x0065 /* 'e' */, 0x0301, (UChar
)0x0065 /* 'e' */, 0x0301, 0x0300, 0},
223 {(UChar
)0x0065 /* 'e' */, 0x0301, (UChar
)0x0065 /* 'e' */, 0x0300, 0},
224 {(UChar
)0x0065 /* 'e' */, 0x0301, (UChar
)0x0065 /* 'e' */, 0x0300, 0x0301, 0},
225 {(UChar
)0x0065 /* 'e' */, 0x0301, 0x0300, (UChar
)0x0065 /* 'e' */, 0},
226 {(UChar
)0x0065 /* 'e' */, 0x0301, 0x0300, (UChar
)0x0065 /* 'e' */, 0x0301, 0},
227 {(UChar
)0x0065 /* 'e' */, 0x0301, 0x0300, (UChar
)0x0065 /* 'e' */, 0x0301, 0x0300, 0},
228 {(UChar
)0x0065 /* 'e' */, 0x0301, 0x0300, (UChar
)0x0065 /* 'e' */, 0x0300, 0},
229 {(UChar
)0x0065 /* 'e' */, 0x0301, 0x0300, (UChar
)0x0065 /* 'e' */, 0x0300, 0x0301, 0},
230 {(UChar
)0x0065 /* 'e' */, 0x0300, (UChar
)0x0065 /* 'e' */, 0},
231 {(UChar
)0x0065 /* 'e' */, 0x0300, (UChar
)0x0065 /* 'e' */, 0x0301, 0},
232 {(UChar
)0x0065 /* 'e' */, 0x0300, (UChar
)0x0065 /* 'e' */, 0x0301, 0x0300, 0},
233 {(UChar
)0x0065 /* 'e' */, 0x0300, (UChar
)0x0065 /* 'e' */, 0x0300, 0},
234 {(UChar
)0x0065 /* 'e' */, 0x0300, (UChar
)0x0065 /* 'e' */, 0x0300, 0x0301, 0},
235 {(UChar
)0x0065 /* 'e' */, 0x0300, 0x0301, (UChar
)0x0065 /* 'e' */, 0},
236 {(UChar
)0x0065 /* 'e' */, 0x0300, 0x0301, (UChar
)0x0065 /* 'e' */, 0x0301, 0},
237 {(UChar
)0x0065 /* 'e' */, 0x0300, 0x0301, (UChar
)0x0065 /* 'e' */, 0x0301, 0x0300, 0},
238 {(UChar
)0x0065 /* 'e' */, 0x0300, 0x0301, (UChar
)0x0065 /* 'e' */, 0x0300, 0},
239 {(UChar
)0x0065 /* 'e' */, 0x0300, 0x0301, (UChar
)0x0065 /* 'e' */, 0x0300, 0x0301, 0}
242 static const UChar testMore
[][MAX_TOKEN_LEN
] = {
243 {(UChar
)0x0061 /* 'a' */, (UChar
)0x0065 /* 'e' */, 0},
246 {(UChar
)0x0061 /* 'a' */, (UChar
)0x0066 /* 'f' */, 0},
247 {(UChar
)0x006F /* 'o' */, (UChar
)0x0065 /* 'e' */, 0},
250 {(UChar
)0x006F /* 'o' */, (UChar
)0x0066 /* 'f' */, 0},
254 void addEnglishCollTest(TestNode
** root
)
257 addTest(root
, &TestPrimary
, "tscoll/encoll/TestPrimary");
258 addTest(root
, &TestSecondary
, "tscoll/encoll/TestSecondary");
259 addTest(root
, &TestTertiary
, "tscoll/encoll/TestTertiary");
263 static void TestTertiary( )
265 int32_t testMoreSize
;
266 UCollationResult expected
=UCOL_EQUAL
;
268 UErrorCode status
= U_ZERO_ERROR
;
269 myCollation
= ucol_open("en_US", &status
);
270 if(U_FAILURE(status
)){
271 log_err_status(status
, "ERROR: in creation of rule based collator: %s\n", myErrorName(status
));
274 log_verbose("Testing English Collation with Tertiary strength\n");
276 ucol_setStrength(myCollation
, UCOL_TERTIARY
);
277 for (i
= 0; i
< 38 ; i
++)
279 doTest(myCollation
, testSourceCases
[i
], testTargetCases
[i
], results
[i
]);
284 for (i
= 0; i
< 10; i
++)
286 for (j
= i
+1; j
< 10; j
++)
288 doTest(myCollation
, testBugs
[i
], testBugs
[j
], UCOL_LESS
);
291 /*test more interesting cases */
292 testMoreSize
= UPRV_LENGTHOF(testMore
);
293 for (i
= 0; i
< testMoreSize
; i
++)
295 for (j
= 0; j
< testMoreSize
; j
++)
297 if (i
< j
) expected
= UCOL_LESS
;
298 if (i
== j
) expected
= UCOL_EQUAL
;
299 if (i
> j
) expected
= UCOL_GREATER
;
300 doTest(myCollation
, testMore
[i
], testMore
[j
], expected
);
303 ucol_close(myCollation
);
306 static void TestPrimary()
310 UErrorCode status
= U_ZERO_ERROR
;
311 myCollation
= ucol_open("en_US", &status
);
312 if(U_FAILURE(status
)){
313 log_err_status(status
, "ERROR: in creation of rule based collator: %s\n", myErrorName(status
));
316 ucol_setStrength(myCollation
, UCOL_PRIMARY
);
317 log_verbose("Testing English Collation with Primary strength\n");
318 for (i
= 38; i
< 43 ; i
++)
320 doTest(myCollation
, testSourceCases
[i
], testTargetCases
[i
], results
[i
]);
322 ucol_close(myCollation
);
325 static void TestSecondary()
327 UCollationResult expected
=UCOL_EQUAL
;
328 int32_t i
,j
, testAcuteSize
;
329 UErrorCode status
= U_ZERO_ERROR
;
330 myCollation
= ucol_open("en_US", &status
);
331 if(U_FAILURE(status
)){
332 log_err_status(status
, "ERROR: in creation of rule based collator: %s\n", myErrorName(status
));
335 ucol_setStrength(myCollation
, UCOL_SECONDARY
);
336 log_verbose("Testing English Collation with Secondary strength\n");
337 for (i
= 43; i
< 49 ; i
++)
339 doTest(myCollation
, testSourceCases
[i
], testTargetCases
[i
], results
[i
]);
343 /*test acute and grave ordering (compare to french collation) */
344 testAcuteSize
= UPRV_LENGTHOF(testAcute
);
345 for (i
= 0; i
< testAcuteSize
; i
++)
347 for (j
= 0; j
< testAcuteSize
; j
++)
349 if (i
< j
) expected
= UCOL_LESS
;
350 if (i
== j
) expected
= UCOL_EQUAL
;
351 if (i
> j
) expected
= UCOL_GREATER
;
352 doTest(myCollation
, testAcute
[i
], testAcute
[j
], expected
);
355 ucol_close(myCollation
);
358 #endif /* #if !UCONFIG_NO_COLLATION */