]> gitweb.fperrin.net Git - Dictionary.git/blob - jars/icu4j-52_1/main/tests/collate/src/com/ibm/icu/dev/test/collator/CollationEnglishTest.java
Clean up imports.
[Dictionary.git] / jars / icu4j-52_1 / main / tests / collate / src / com / ibm / icu / dev / test / collator / CollationEnglishTest.java
1 /*
2  *******************************************************************************
3  * Copyright (C) 2002-2010, International Business Machines Corporation and    *
4  * others. All Rights Reserved.                                                *
5  *******************************************************************************
6  */
7
8 /** 
9  * Port From:   ICU4C v2.1 : Collate/CollationEnglishTest
10  * Source File: $ICU4CRoot/source/test/intltest/encoll.cpp
11  **/
12  
13 package com.ibm.icu.dev.test.collator;
14  
15 import java.util.Locale;
16
17 import com.ibm.icu.dev.test.TestFmwk;
18 import com.ibm.icu.text.CollationKey;
19 import com.ibm.icu.text.Collator;
20  
21 public class CollationEnglishTest extends TestFmwk{
22     public static void main(String[] args) throws Exception{
23         new CollationEnglishTest().run(args);
24     }
25     
26     private static char[][] testSourceCases = {
27         {0x0061 /* 'a' */, 0x0062 /* 'b' */},
28         {0x0062 /* 'b' */, 0x006C /* 'l' */, 0x0061 /* 'a' */, 0x0063 /* 'c' */, 0x006B /* 'k' */, 0x002D /* '-' */, 0x0062 /* 'b' */, 0x0069 /* 'i' */, 0x0072 /* 'r' */, 0x0064 /* 'd' */},
29         {0x0062 /* 'b' */, 0x006C /* 'l' */, 0x0061 /* 'a' */, 0x0063 /* 'c' */, 0x006B /* 'k' */, 0x0020 /* ' ' */, 0x0062 /* 'b' */, 0x0069 /* 'i' */, 0x0072 /* 'r' */, 0x0064 /* 'd' */},
30         {0x0062 /* 'b' */, 0x006C /* 'l' */, 0x0061 /* 'a' */, 0x0063 /* 'c' */, 0x006B /* 'k' */, 0x002D /* '-' */, 0x0062 /* 'b' */, 0x0069 /* 'i' */, 0x0072 /* 'r' */, 0x0064 /* 'd' */},
31         {0x0048 /* 'H' */, 0x0065 /* 'e' */, 0x006C /* 'l' */, 0x006C /* 'l' */, 0x006F /* 'o' */},
32         {0x0041 /* 'A' */, 0x0042 /* 'B' */, 0x0043 /* 'C' */}, 
33         {0x0061 /* 'a' */, 0x0062 /* 'b' */, 0x0063 /* 'c' */},
34         {0x0062 /* 'b' */, 0x006C /* 'l' */, 0x0061 /* 'a' */, 0x0063 /* 'c' */, 0x006B /* 'k' */, 0x0062 /* 'b' */, 0x0069 /* 'i' */, 0x0072 /* 'r' */, 0x0064 /* 'd' */},
35         {0x0062 /* 'b' */, 0x006C /* 'l' */, 0x0061 /* 'a' */, 0x0063 /* 'c' */, 0x006B /* 'k' */, 0x002D /* '-' */, 0x0062 /* 'b' */, 0x0069 /* 'i' */, 0x0072 /* 'r' */, 0x0064 /* 'd' */},
36         {0x0062 /* 'b' */, 0x006C /* 'l' */, 0x0061 /* 'a' */, 0x0063 /* 'c' */, 0x006B /* 'k' */, 0x002D /* '-' */, 0x0062 /* 'b' */, 0x0069 /* 'i' */, 0x0072 /* 'r' */, 0x0064 /* 'd' */},
37         {0x0070 /* 'p' */, 0x00EA, 0x0063 /* 'c' */, 0x0068 /* 'h' */, 0x0065 /* 'e' */},                                            
38         {0x0070 /* 'p' */, 0x00E9, 0x0063 /* 'c' */, 0x0068 /* 'h' */, 0x00E9},
39         {0x00C4, 0x0042 /* 'B' */, 0x0308, 0x0043 /* 'C' */, 0x0308},
40         {0x0061 /* 'a' */, 0x0308, 0x0062 /* 'b' */, 0x0063 /* 'c' */},
41         {0x0070 /* 'p' */, 0x00E9, 0x0063 /* 'c' */, 0x0068 /* 'h' */, 0x0065 /* 'e' */, 0x0072 /* 'r' */},
42         {0x0072 /* 'r' */, 0x006F /* 'o' */, 0x006C /* 'l' */, 0x0065 /* 'e' */, 0x0073 /* 's' */},
43         {0x0061 /* 'a' */, 0x0062 /* 'b' */, 0x0063 /* 'c' */},
44         {0x0041 /* 'A' */},
45         {0x0041 /* 'A' */},
46         {0x0061 /* 'a' */, 0x0062 /* 'b' */},                                                                
47         {0x0074 /* 't' */, 0x0063 /* 'c' */, 0x006F /* 'o' */, 0x006D /* 'm' */, 0x0070 /* 'p' */, 0x0061 /* 'a' */, 0x0072 /* 'r' */, 0x0065 /* 'e' */, 0x0070 /* 'p' */, 0x006C /* 'l' */, 0x0061 /* 'a' */, 0x0069 /* 'i' */, 0x006E /* 'n' */},
48         {0x0061 /* 'a' */, 0x0062 /* 'b' */}, 
49         {0x0061 /* 'a' */, 0x0023 /* '#' */, 0x0062 /* 'b' */},
50         {0x0061 /* 'a' */, 0x0023 /* '#' */, 0x0062 /* 'b' */},
51         {0x0061 /* 'a' */, 0x0062 /* 'b' */, 0x0063 /* 'c' */},
52         {0x0041 /* 'A' */, 0x0062 /* 'b' */, 0x0063 /* 'c' */, 0x0064 /* 'd' */, 0x0061 /* 'a' */},
53         {0x0061 /* 'a' */, 0x0062 /* 'b' */, 0x0063 /* 'c' */, 0x0064 /* 'd' */, 0x0061 /* 'a' */},
54         {0x0061 /* 'a' */, 0x0062 /* 'b' */, 0x0063 /* 'c' */, 0x0064 /* 'd' */, 0x0061 /* 'a' */},
55         {0x00E6, 0x0062 /* 'b' */, 0x0063 /* 'c' */, 0x0064 /* 'd' */, 0x0061 /* 'a' */},
56         {0x00E4, 0x0062 /* 'b' */, 0x0063 /* 'c' */, 0x0064 /* 'd' */, 0x0061 /* 'a' */},                                            
57         {0x0061 /* 'a' */, 0x0062 /* 'b' */, 0x0063 /* 'c' */},
58         {0x0061 /* 'a' */, 0x0062 /* 'b' */, 0x0063 /* 'c' */},
59         {0x0061 /* 'a' */, 0x0062 /* 'b' */, 0x0063 /* 'c' */},
60         {0x0061 /* 'a' */, 0x0062 /* 'b' */, 0x0063 /* 'c' */},
61         {0x0061 /* 'a' */, 0x0062 /* 'b' */, 0x0063 /* 'c' */},
62         {0x0061 /* 'a' */, 0x0063 /* 'c' */, 0x0048 /* 'H' */, 0x0063 /* 'c' */},
63         {0x0061 /* 'a' */, 0x0308, 0x0062 /* 'b' */, 0x0063 /* 'c' */},
64         {0x0074 /* 't' */, 0x0068 /* 'h' */, 0x0069 /* 'i' */, 0x0302, 0x0073 /* 's' */},
65         {0x0070 /* 'p' */, 0x00EA, 0x0063 /* 'c' */, 0x0068 /* 'h' */, 0x0065 /* 'e' */},
66         {0x0061 /* 'a' */, 0x0062 /* 'b' */, 0x0063 /* 'c' */},                                                         
67         {0x0061 /* 'a' */, 0x0062 /* 'b' */, 0x0063 /* 'c' */},
68         {0x0061 /* 'a' */, 0x0062 /* 'b' */, 0x0063 /* 'c' */},
69         {0x0061 /* 'a' */, 0x00E6, 0x0063 /* 'c' */},
70         {0x0061 /* 'a' */, 0x0062 /* 'b' */, 0x0063 /* 'c' */},
71         {0x0061 /* 'a' */, 0x0062 /* 'b' */, 0x0063 /* 'c' */},
72         {0x0061 /* 'a' */, 0x00E6, 0x0063 /* 'c' */},
73         {0x0061 /* 'a' */, 0x0062 /* 'b' */, 0x0063 /* 'c' */},
74         {0x0061 /* 'a' */, 0x0062 /* 'b' */, 0x0063 /* 'c' */},               
75         {0x0070 /* 'p' */, 0x00E9, 0x0063 /* 'c' */, 0x0068 /* 'h' */, 0x00E9}                                            // 49
76     };
77     
78     private static char[][] testTargetCases = {
79         {0x0061 /* 'a' */, 0x0062 /* 'b' */, 0x0063 /* 'c' */},
80         {0x0062 /* 'b' */, 0x006C /* 'l' */, 0x0061 /* 'a' */, 0x0063 /* 'c' */, 0x006B /* 'k' */, 0x0062 /* 'b' */, 0x0069 /* 'i' */, 0x0072 /* 'r' */, 0x0064 /* 'd' */},
81         {0x0062 /* 'b' */, 0x006C /* 'l' */, 0x0061 /* 'a' */, 0x0063 /* 'c' */, 0x006B /* 'k' */, 0x002D /* '-' */, 0x0062 /* 'b' */, 0x0069 /* 'i' */, 0x0072 /* 'r' */, 0x0064 /* 'd' */},
82         {0x0062 /* 'b' */, 0x006C /* 'l' */, 0x0061 /* 'a' */, 0x0063 /* 'c' */, 0x006B /* 'k' */},
83         {0x0068 /* 'h' */, 0x0065 /* 'e' */, 0x006C /* 'l' */, 0x006C /* 'l' */, 0x006F /* 'o' */},
84         {0x0041 /* 'A' */, 0x0042 /* 'B' */, 0x0043 /* 'C' */},
85         {0x0041 /* 'A' */, 0x0042 /* 'B' */, 0x0043 /* 'C' */},
86         {0x0062 /* 'b' */, 0x006C /* 'l' */, 0x0061 /* 'a' */, 0x0063 /* 'c' */, 0x006B /* 'k' */, 0x0062 /* 'b' */, 0x0069 /* 'i' */, 0x0072 /* 'r' */, 0x0064 /* 'd' */, 0x0073 /* 's' */},
87         {0x0062 /* 'b' */, 0x006C /* 'l' */, 0x0061 /* 'a' */, 0x0063 /* 'c' */, 0x006B /* 'k' */, 0x0062 /* 'b' */, 0x0069 /* 'i' */, 0x0072 /* 'r' */, 0x0064 /* 'd' */, 0x0073 /* 's' */},
88         {0x0062 /* 'b' */, 0x006C /* 'l' */, 0x0061 /* 'a' */, 0x0063 /* 'c' */, 0x006B /* 'k' */, 0x0062 /* 'b' */, 0x0069 /* 'i' */, 0x0072 /* 'r' */, 0x0064 /* 'd' */},                             
89         {0x0070 /* 'p' */, 0x00E9, 0x0063 /* 'c' */, 0x0068 /* 'h' */, 0x00E9},
90         {0x0070 /* 'p' */, 0x00E9, 0x0063 /* 'c' */, 0x0068 /* 'h' */, 0x0065 /* 'e' */, 0x0072 /* 'r' */},
91         {0x00C4, 0x0042 /* 'B' */, 0x0308, 0x0043 /* 'C' */, 0x0308},
92         {0x0041 /* 'A' */, 0x0308, 0x0062 /* 'b' */, 0x0063 /* 'c' */},
93         {0x0070 /* 'p' */, 0x00E9, 0x0063 /* 'c' */, 0x0068 /* 'h' */, 0x0065 /* 'e' */},
94         {0x0072 /* 'r' */, 0x006F /* 'o' */, 0x0302, 0x006C /* 'l' */, 0x0065 /* 'e' */},
95         {0x0041 /* 'A' */, 0x00E1, 0x0063 /* 'c' */, 0x0064 /* 'd' */},
96         {0x0041 /* 'A' */, 0x00E1, 0x0063 /* 'c' */, 0x0064 /* 'd' */},
97         {0x0061 /* 'a' */, 0x0062 /* 'b' */, 0x0063 /* 'c' */},
98         {0x0061 /* 'a' */, 0x0062 /* 'b' */, 0x0063 /* 'c' */},                                                             
99         {0x0054 /* 'T' */, 0x0043 /* 'C' */, 0x006F /* 'o' */, 0x006D /* 'm' */, 0x0070 /* 'p' */, 0x0061 /* 'a' */, 0x0072 /* 'r' */, 0x0065 /* 'e' */, 0x0050 /* 'P' */, 0x006C /* 'l' */, 0x0061 /* 'a' */, 0x0069 /* 'i' */, 0x006E /* 'n' */},
100         {0x0061 /* 'a' */, 0x0042 /* 'B' */, 0x0063 /* 'c' */},
101         {0x0061 /* 'a' */, 0x0023 /* '#' */, 0x0042 /* 'B' */},
102         {0x0061 /* 'a' */, 0x0026 /* '&' */, 0x0062 /* 'b' */},
103         {0x0061 /* 'a' */, 0x0023 /* '#' */, 0x0063 /* 'c' */},
104         {0x0061 /* 'a' */, 0x0062 /* 'b' */, 0x0063 /* 'c' */, 0x0064 /* 'd' */, 0x0061 /* 'a' */},
105         {0x00C4, 0x0062 /* 'b' */, 0x0063 /* 'c' */, 0x0064 /* 'd' */, 0x0061 /* 'a' */},
106         {0x00E4, 0x0062 /* 'b' */, 0x0063 /* 'c' */, 0x0064 /* 'd' */, 0x0061 /* 'a' */},
107         {0x00C4, 0x0062 /* 'b' */, 0x0063 /* 'c' */, 0x0064 /* 'd' */, 0x0061 /* 'a' */},
108         {0x00C4, 0x0062 /* 'b' */, 0x0063 /* 'c' */, 0x0064 /* 'd' */, 0x0061 /* 'a' */},                                             
109         {0x0061 /* 'a' */, 0x0062 /* 'b' */, 0x0023 /* '#' */, 0x0063 /* 'c' */},
110         {0x0061 /* 'a' */, 0x0062 /* 'b' */, 0x0063 /* 'c' */},
111         {0x0061 /* 'a' */, 0x0062 /* 'b' */, 0x003D /* '=' */, 0x0063 /* 'c' */},
112         {0x0061 /* 'a' */, 0x0062 /* 'b' */, 0x0064 /* 'd' */},
113         {0x00E4, 0x0062 /* 'b' */, 0x0063 /* 'c' */},
114         {0x0061 /* 'a' */, 0x0043 /* 'C' */, 0x0048 /* 'H' */, 0x0063 /* 'c' */},
115         {0x00E4, 0x0062 /* 'b' */, 0x0063 /* 'c' */},
116         {0x0074 /* 't' */, 0x0068 /* 'h' */, 0x00EE, 0x0073 /* 's' */},
117         {0x0070 /* 'p' */, 0x00E9, 0x0063 /* 'c' */, 0x0068 /* 'h' */, 0x00E9},
118         {0x0061 /* 'a' */, 0x0042 /* 'B' */, 0x0043 /* 'C' */},                                                          
119         {0x0061 /* 'a' */, 0x0062 /* 'b' */, 0x0064 /* 'd' */},
120         {0x00E4, 0x0062 /* 'b' */, 0x0063 /* 'c' */},
121         {0x0061 /* 'a' */, 0x00C6, 0x0063 /* 'c' */},
122         {0x0061 /* 'a' */, 0x0042 /* 'B' */, 0x0064 /* 'd' */},
123         {0x00E4, 0x0062 /* 'b' */, 0x0063 /* 'c' */},
124         {0x0061 /* 'a' */, 0x00C6, 0x0063 /* 'c' */},
125         {0x0061 /* 'a' */, 0x0042 /* 'B' */, 0x0064 /* 'd' */},
126         {0x00E4, 0x0062 /* 'b' */, 0x0063 /* 'c' */},          
127         {0x0070 /* 'p' */, 0x00EA, 0x0063 /* 'c' */, 0x0068 /* 'h' */, 0x0065 /* 'e' */}
128     };                                           // 49
129
130     private static int[] results = {
131     //-1:LESS; 0:EQUAL; 1:GREATER
132         -1, 
133         -1, /*Collator::GREATER,*/
134         -1,
135         1,
136         1,
137         0,
138         -1,
139         -1,
140         -1,
141         -1, /*Collator::GREATER,*/                                                          /* 10 */
142         1,
143         -1,
144         0,
145         -1,
146         1,
147         1,
148         1,
149         -1,
150         -1,
151         -1,                                                             /* 20 */
152         -1,
153         -1,
154         -1,
155         1,
156         1,
157         1,
158         /* Test Tertiary  > 26 */
159         -1,
160         -1,
161         1,
162         -1,                                                             /* 30 */
163         1,
164         0,
165         1,
166         -1,
167         -1,
168         -1,
169         /* test identical > 36 */
170         0,
171         0,
172         /* test primary > 38 */
173         0,
174         0,                                                            /* 40 */
175         -1,
176         0,
177         0,
178         /* test secondary > 43 */
179         -1,
180         -1,
181         0,
182         -1,
183         -1, 
184         -1                                                                  // 49
185     };
186
187     private static char [][] testBugs = {
188         {0x61},
189         {0x41},
190         {0x65},
191         {0x45},
192         {0x00e9},
193         {0x00e8},
194         {0x00ea},
195         {0x00eb},
196         {0x65, 0x61},
197         {0x78}
198     };
199
200     // 0x0300 is grave, 0x0301 is acute
201     // the order of elements in this array must be different than the order in CollationFrenchTest
202     private static char[][] testAcute = {
203         {0x65, 0x65},
204         {0x65, 0x65, 0x0301},
205         {0x65, 0x65, 0x0301, 0x0300},
206         {0x65, 0x65, 0x0300},
207         {0x65, 0x65, 0x0300, 0x0301},
208         {0x65, 0x0301, 0x65},
209         {0x65, 0x0301, 0x65, 0x0301},
210         {0x65, 0x0301, 0x65, 0x0301, 0x0300},
211         {0x65, 0x0301, 0x65, 0x0300},
212         {0x65, 0x0301, 0x65, 0x0300, 0x0301},
213         {0x65, 0x0301, 0x0300, 0x65},
214         {0x65, 0x0301, 0x0300, 0x65, 0x0301},
215         {0x65, 0x0301, 0x0300, 0x65, 0x0301, 0x0300},
216         {0x65, 0x0301, 0x0300, 0x65, 0x0300},
217         {0x65, 0x0301, 0x0300, 0x65, 0x0300, 0x0301},
218         {0x65, 0x0300, 0x65},
219         {0x65, 0x0300, 0x65, 0x0301},
220         {0x65, 0x0300, 0x65, 0x0301, 0x0300},
221         {0x65, 0x0300, 0x65, 0x0300},
222         {0x65, 0x0300, 0x65, 0x0300, 0x0301},
223         {0x65, 0x0300, 0x0301, 0x65},
224         {0x65, 0x0300, 0x0301, 0x65, 0x0301},
225         {0x65, 0x0300, 0x0301, 0x65, 0x0301, 0x0300},
226         {0x65, 0x0300, 0x0301, 0x65, 0x0300},
227         {0x65, 0x0300, 0x0301, 0x65, 0x0300, 0x0301}
228     };
229
230     private static char[][] testMore = {
231         {0x0061 /* 'a' */, 0x0065 /* 'e' */},
232         { 0x00E6},
233         { 0x00C6},
234         {0x0061 /* 'a' */, 0x0066 /* 'f' */},
235         {0x006F /* 'o' */, 0x0065 /* 'e' */},
236         { 0x0153},
237         { 0x0152},
238         {0x006F /* 'o' */, 0x0066 /* 'f' */},
239     };
240     
241     private Collator myCollation = null;
242     
243     public CollationEnglishTest() {
244     }
245     protected void init()throws Exception{
246         myCollation = Collator.getInstance(Locale.ENGLISH);
247     }
248     
249     //performs test with strength PRIMARY
250     public void TestPrimary() {
251         int i;
252         myCollation.setStrength(Collator.PRIMARY);
253         for (i = 38; i < 43 ; i++) {
254             doTest(testSourceCases[i], testTargetCases[i], results[i]);
255         }  
256     }
257     
258     //perform test with strength SECONDARY
259     public void TestSecondary() {
260         int i;
261         myCollation.setStrength(Collator.SECONDARY);
262         for (i = 43; i < 49 ; i++) {
263             doTest(testSourceCases[i], testTargetCases[i], results[i]);
264         }
265
266         //test acute and grave ordering (compare to french collation)
267         int j;
268         int expected;
269         for (i = 0; i < testAcute.length; i++) {
270             for (j = 0; j < testAcute.length; j++) {
271                 logln("i = " + i + "; j = " + j);
272                 if (i <  j)
273                     expected = -1;
274                 else if (i == j)
275                     expected = 0;
276                 else // (i >  j)
277                     expected = 1;
278                 doTest(testAcute[i], testAcute[j], expected );
279             }
280         }
281     }
282     
283     //perform test with strength TERTIARY
284     public void TestTertiary() {
285         int i = 0;
286         myCollation.setStrength(Collator.TERTIARY);
287         //for (i = 0; i < 38 ; i++)  //attention: there is something wrong with 36, 37.
288         for (i = 0; i < 38 ; i++)
289         {
290             doTest(testSourceCases[i], testTargetCases[i], results[i]);
291         } 
292
293         int j = 0;
294         for (i = 0; i < 10; i++)
295         {
296             for (j = i+1; j < 10; j++)
297             {
298                 doTest(testBugs[i], testBugs[j], -1);
299             }
300         }
301
302         //test more interesting cases
303         int expected;
304         for (i = 0; i < testMore.length; i++)
305         {
306             for (j = 0; j < testMore.length; j++)
307             {
308                 if (i <  j)
309                     expected = -1;
310                 else if (i == j)
311                     expected = 0;
312                 else // (i >  j)
313                     expected = 1;
314                 doTest(testMore[i], testMore[j], expected );
315             }
316         }
317     }
318     
319    // main test routine, tests rules defined by the "en" locale
320     private void doTest(char[] source, char[] target, int result){
321         
322         String s = new String(source);
323         String t = new String(target);
324         int compareResult = myCollation.compare(s, t);
325         CollationKey sortKey1, sortKey2;
326         sortKey1 = myCollation.getCollationKey(s);
327         sortKey2 = myCollation.getCollationKey(t);
328         int keyResult = sortKey1.compareTo(sortKey2);
329         reportCResult(s, t, sortKey1, sortKey2, compareResult, keyResult, compareResult, result);
330         
331     }
332     
333     private void reportCResult( String source, String target, CollationKey sourceKey, CollationKey targetKey,
334                                 int compareResult, int keyResult, int incResult, int expectedResult ){
335         if (expectedResult < -1 || expectedResult > 1)
336         {
337             errln("***** invalid call to reportCResult ****");
338             return;
339         }
340
341         boolean ok1 = (compareResult == expectedResult);
342         boolean ok2 = (keyResult == expectedResult);
343         boolean ok3 = (incResult == expectedResult);
344
345         if (ok1 && ok2 && ok3 && !isVerbose()){
346             return;    
347         }else{
348             String msg1 = ok1? "Ok: compare(\"" : "FAIL: compare(\"";
349             String msg2 = "\", \"";
350             String msg3 = "\") returned ";
351             String msg4 = "; expected ";
352             
353             String sExpect = new String("");
354             String sResult = new String("");
355             sResult = appendCompareResult(compareResult, sResult);
356             sExpect = appendCompareResult(expectedResult, sExpect);
357             if (ok1) {
358                 logln(msg1 + source + msg2 + target + msg3 + sResult);
359             } else {
360                 errln(msg1 + source + msg2 + target + msg3 + sResult + msg4 + sExpect);
361             }
362             
363             msg1 = ok2 ? "Ok: key(\"" : "FAIL: key(\"";
364             msg2 = "\").compareTo(key(\"";
365             msg3 = "\")) returned ";
366             sResult = appendCompareResult(keyResult, sResult);
367             if (ok2) {
368                 logln(msg1 + source + msg2 + target + msg3 + sResult);
369             } else {
370                 errln(msg1 + source + msg2 + target + msg3 + sResult + msg4 + sExpect);
371                 msg1 = "  ";
372                 msg2 = " vs. ";
373                 errln(msg1 + prettify(sourceKey) + msg2 + prettify(targetKey));
374             }
375             
376             msg1 = ok3 ? "Ok: incCompare(\"" : "FAIL: incCompare(\"";
377             msg2 = "\", \"";
378             msg3 = "\") returned ";
379
380             sResult = appendCompareResult(incResult, sResult);
381
382             if (ok3) {
383                 logln(msg1 + source + msg2 + target + msg3 + sResult);
384             } else {
385                 errln(msg1 + source + msg2 + target + msg3 + sResult + msg4 + sExpect);
386             }                
387         }
388     }
389     
390     private String appendCompareResult(int result, String target){
391         if (result == -1)   //LESS
392         {
393             target += "LESS";
394         }
395         else if (result == 0)   //EQUAL
396         {
397             target += "EQUAL";
398         }
399         else if (result == 1)   //GREATER
400         {
401             target += "GREATER";
402         }
403         else
404         {
405             String huh = "?";
406
407             target += huh + result;
408         }
409         return target;
410     }
411     
412     String prettify(CollationKey sourceKey) {
413         int i;
414         byte[] bytes= sourceKey.toByteArray();
415         String target = "[";
416     
417         for (i = 0; i < bytes.length; i++) {
418             target += Integer.toHexString(bytes[i]);
419             target += " ";
420         }
421         target += "]";
422         return target;
423     }
424  }