]> gitweb.fperrin.net Git - Dictionary.git/blob - jars/icu4j-4_2_1-src/src/com/ibm/icu/dev/test/collator/CollationRegressionTest.java
icu4jsrc
[Dictionary.git] / jars / icu4j-4_2_1-src / src / com / ibm / icu / dev / test / collator / CollationRegressionTest.java
1 /*\r
2  *******************************************************************************\r
3  * Copyright (C) 2002-2007, International Business Machines Corporation and    *\r
4  * others. All Rights Reserved.                                                *\r
5  *******************************************************************************\r
6  */\r
7 \r
8 /** \r
9  * Port From:   ICU4C v2.1 : collate/CollationRegressionTest\r
10  * Source File: $ICU4CRoot/source/test/intltest/regcoll.cpp\r
11  **/\r
12  \r
13 package com.ibm.icu.dev.test.collator;\r
14 \r
15 import com.ibm.icu.dev.test.*;\r
16 import com.ibm.icu.text.*;\r
17 \r
18 import java.util.Locale;\r
19 import java.util.Vector;\r
20 import java.text.ParseException;\r
21 \r
22 public class CollationRegressionTest extends TestFmwk {\r
23     public static void main(String[] args) throws Exception{\r
24         new CollationRegressionTest().run(args);\r
25     }\r
26     \r
27     // @bug 4048446\r
28     //\r
29     // CollationElementIterator.reset() doesn't work\r
30     //\r
31     public void Test4048446() {\r
32         final String test1 = "XFILE What subset of all possible test cases has the highest probability of detecting the most errors?";\r
33         //final String test2 = "Xf_ile What subset of all possible test cases has the lowest probability of detecting the least errors?";\r
34         RuleBasedCollator en_us = (RuleBasedCollator) Collator.getInstance(Locale.US);\r
35         CollationElementIterator i1 = en_us.getCollationElementIterator(test1);\r
36         CollationElementIterator i2 = en_us.getCollationElementIterator(test1);\r
37         \r
38         if (i1 == null || i2 == null) {\r
39             errln("Could not create CollationElementIterator's");\r
40             return;\r
41         }\r
42     \r
43         while (i1.next() != CollationElementIterator.NULLORDER) {\r
44             //\r
45         }\r
46     \r
47         i1.reset();\r
48         assertEqual(i1, i2);\r
49     }\r
50     \r
51     void assertEqual(CollationElementIterator i1, CollationElementIterator i2) {\r
52         int c1, c2, count = 0;\r
53     \r
54         do {\r
55             c1 = i1.next();\r
56             c2 = i2.next();\r
57     \r
58             if (c1 != c2) {\r
59                 String msg = "";\r
60                 String msg1 = "    ";\r
61                 \r
62                 msg += msg1 + count;\r
63                 msg += ": strength(0x" + Integer.toHexString(c1);\r
64                 msg += ") != strength(0x" + Integer.toHexString(c2);\r
65                 msg += ")";\r
66                 errln(msg);\r
67                 break;\r
68             }\r
69             count += 1;\r
70         } while (c1 != CollationElementIterator.NULLORDER);\r
71     }\r
72     \r
73     // @bug 4051866\r
74     //\r
75     // Collator -> rules -> Collator round-trip broken for expanding characters\r
76     //\r
77     public void Test4051866() {\r
78        String rules = "< o & oe ,o\u3080& oe ,\u1530 ,O& OE ,O\u3080& OE ,\u1520< p ,P";\r
79 \r
80         // Build a collator containing expanding characters\r
81         RuleBasedCollator c1 = null;\r
82         \r
83         try {\r
84             c1 = new RuleBasedCollator(rules);\r
85         } catch (Exception e) {\r
86             errln("Fail to create RuleBasedCollator with rules:" + rules);\r
87             return;\r
88         }\r
89     \r
90         // Build another using the rules from  the first\r
91         RuleBasedCollator c2 = null;\r
92         try {\r
93             c2 = new RuleBasedCollator(c1.getRules());\r
94         } catch (Exception e) {\r
95             errln("Fail to create RuleBasedCollator with rules:" + rules);\r
96             return;\r
97         }\r
98     \r
99         // Make sure they're the same\r
100         if (!(c1.getRules().equals(c2.getRules())))\r
101         {\r
102             errln("Rules are not equal");\r
103         }\r
104     }\r
105     \r
106     // @bug 4053636\r
107     //\r
108     // Collator thinks "black-bird" == "black"\r
109     //\r
110     public void Test4053636() {\r
111         RuleBasedCollator en_us = (RuleBasedCollator) Collator.getInstance(Locale.US);\r
112         if (en_us.equals("black_bird", "black")) {\r
113             errln("black-bird == black");\r
114         }\r
115     }\r
116     \r
117     // @bug 4054238\r
118     //\r
119     // CollationElementIterator will not work correctly if the associated\r
120     // Collator object's mode is changed\r
121     //\r
122     public void Test4054238(/* char* par */) {\r
123         final char[] chars3 = {0x61, 0x00FC, 0x62, 0x65, 0x63, 0x6b, 0x20, 0x47, 0x72, 0x00F6, 0x00DF, 0x65, 0x20, 0x4c, 0x00FC, 0x62, 0x63, 0x6b, 0};\r
124         final String test3 = new String(chars3);\r
125         RuleBasedCollator c = (RuleBasedCollator) Collator.getInstance(Locale.US);\r
126     \r
127         // NOTE: The Java code uses en_us to create the CollationElementIterators\r
128         // but I'm pretty sure that's wrong, so I've changed this to use c.\r
129         c.setDecomposition(Collator.NO_DECOMPOSITION);\r
130         CollationElementIterator i1 = c.getCollationElementIterator(test3);\r
131         logln("Offset:" + i1.getOffset());\r
132     }\r
133     \r
134     // @bug 4054734\r
135     //\r
136     // Collator::IDENTICAL documented but not implemented\r
137     //\r
138     public void Test4054734(/* char* par */) {\r
139         \r
140             //Here's the original Java:\r
141     \r
142             String[] decomp = {\r
143                 "\u0001",   "<",    "\u0002",\r
144                 "\u0001",   "=",    "\u0001",\r
145                 "A\u0001",  ">",    "~\u0002",      // Ensure A and ~ are not compared bitwise\r
146                 "\u00C0",   "=",    "A\u0300",      // Decomp should make these equal\r
147             };\r
148     \r
149         RuleBasedCollator c = (RuleBasedCollator) Collator.getInstance(Locale.US);\r
150         c.setStrength(Collator.IDENTICAL);\r
151         c.setDecomposition(Collator.CANONICAL_DECOMPOSITION);\r
152         compareArray(c, decomp);\r
153     }\r
154     \r
155     void compareArray(Collator c, String[] tests) {\r
156         \r
157         int expectedResult = 0;\r
158     \r
159         for (int i = 0; i < tests.length; i += 3) {\r
160             String source = tests[i];\r
161             String comparison = tests[i + 1];\r
162             String target = tests[i + 2];\r
163     \r
164             if (comparison.equals("<")) {\r
165                 expectedResult = -1;\r
166             } else if (comparison.equals(">")) {\r
167                 expectedResult = 1;\r
168             } else if (comparison.equals("=")) {\r
169                 expectedResult = 0;\r
170             } else {\r
171                 errln("Bogus comparison string \"" + comparison + "\"");\r
172             }\r
173             \r
174             int compareResult = 0;\r
175             \r
176             logln("i = " + i);\r
177             logln(source);\r
178             logln(target);\r
179             try {\r
180                 compareResult = c.compare(source, target);\r
181             } catch (Exception e) {\r
182                 errln(e.toString());\r
183             }\r
184     \r
185             CollationKey sourceKey = null, targetKey = null;\r
186             try {\r
187                 sourceKey = c.getCollationKey(source);\r
188             } catch (Exception e) {\r
189                 errln("Couldn't get collationKey for source");\r
190                 continue;\r
191             }\r
192     \r
193             try {\r
194                 targetKey = c.getCollationKey(target);\r
195             } catch (Exception e) {\r
196                 errln("Couldn't get collationKey for target");\r
197                 continue;\r
198             }\r
199     \r
200             int keyResult = sourceKey.compareTo(targetKey);\r
201             reportCResult( source, target, sourceKey, targetKey, compareResult, keyResult, compareResult, expectedResult );\r
202         }\r
203     }\r
204     \r
205     void reportCResult( String source, String target, CollationKey sourceKey, CollationKey targetKey,\r
206                                 int compareResult, int keyResult, int incResult, int expectedResult ){\r
207         if (expectedResult < -1 || expectedResult > 1)\r
208         {\r
209             errln("***** invalid call to reportCResult ****");\r
210             return;\r
211         }\r
212 \r
213         boolean ok1 = (compareResult == expectedResult);\r
214         boolean ok2 = (keyResult == expectedResult);\r
215         boolean ok3 = (incResult == expectedResult);\r
216 \r
217         if (ok1 && ok2 && ok3 && !isVerbose()){\r
218             return;    \r
219         }else{\r
220             String msg1 = ok1? "Ok: compare(\"" : "FAIL: compare(\"";\r
221             String msg2 = "\", \"";\r
222             String msg3 = "\") returned ";\r
223             String msg4 = "; expected ";\r
224             \r
225             String sExpect = new String("");\r
226             String sResult = new String("");\r
227             sResult = appendCompareResult(compareResult, sResult);\r
228             sExpect = appendCompareResult(expectedResult, sExpect);\r
229             if (ok1) {\r
230                 logln(msg1 + source + msg2 + target + msg3 + sResult);\r
231             } else {\r
232                 errln(msg1 + source + msg2 + target + msg3 + sResult + msg4 + sExpect);\r
233             }\r
234             \r
235             msg1 = ok2 ? "Ok: key(\"" : "FAIL: key(\"";\r
236             msg2 = "\").compareTo(key(\"";\r
237             msg3 = "\")) returned ";\r
238             sResult = appendCompareResult(keyResult, sResult);\r
239             if (ok2) {\r
240                 logln(msg1 + source + msg2 + target + msg3 + sResult);\r
241             } else {\r
242                 errln(msg1 + source + msg2 + target + msg3 + sResult + msg4 + sExpect);\r
243                 msg1 = "  ";\r
244                 msg2 = " vs. ";\r
245                 errln(msg1 + prettify(sourceKey) + msg2 + prettify(targetKey));\r
246             }\r
247             \r
248             msg1 = ok3 ? "Ok: incCompare(\"" : "FAIL: incCompare(\"";\r
249             msg2 = "\", \"";\r
250             msg3 = "\") returned ";\r
251 \r
252             sResult = appendCompareResult(incResult, sResult);\r
253 \r
254             if (ok3) {\r
255                 logln(msg1 + source + msg2 + target + msg3 + sResult);\r
256             } else {\r
257                 errln(msg1 + source + msg2 + target + msg3 + sResult + msg4 + sExpect);\r
258             }                \r
259         }\r
260     }\r
261     \r
262     String appendCompareResult(int result, String target) {\r
263         if (result == -1) {  //LESS\r
264             target += "LESS";\r
265         } else if (result == 0) {  //EQUAL\r
266             target += "EQUAL";\r
267         } else if (result == 1) {  //GREATER\r
268             target += "GREATER";\r
269         } else {\r
270             String huh = "?";\r
271             target += huh + result;\r
272         }\r
273         return target;\r
274     }\r
275     \r
276     String prettify(CollationKey sourceKey) {\r
277         int i;\r
278         byte[] bytes= sourceKey.toByteArray();\r
279         String target = "[";\r
280     \r
281         for (i = 0; i < bytes.length; i++) {\r
282             target += Integer.toHexString(bytes[i]);\r
283             target += " ";\r
284         }\r
285         target += "]";\r
286         return target;\r
287     }\r
288     \r
289     // @bug 4054736\r
290     //\r
291     // Full Decomposition mode not implemented\r
292     //\r
293     public void Test4054736(/* char* par */) {\r
294         RuleBasedCollator c = (RuleBasedCollator) Collator.getInstance(Locale.US);\r
295     \r
296         c.setStrength(Collator.SECONDARY);\r
297         c.setDecomposition(Collator.NO_DECOMPOSITION);\r
298     \r
299         final String[] tests = { "\uFB4F", "\u003d", "\u05D0\u05DC" };  // Alef-Lamed vs. Alef, Lamed\r
300         compareArray(c, tests);\r
301     }\r
302     \r
303     // @bug 4058613\r
304     //\r
305     // Collator::createInstance() causes an ArrayIndexOutofBoundsException for Korean  \r
306     //\r
307     public void Test4058613(/* char* par */) {\r
308         // Creating a default collator doesn't work when Korean is the default\r
309         // locale\r
310         \r
311         Locale oldDefault = Locale.getDefault();\r
312         Locale.setDefault(new Locale("ko", ""));\r
313     \r
314         Collator c = null;\r
315         \r
316         c = Collator.getInstance(new Locale("en", "US"));\r
317     \r
318         if (c == null) {\r
319             errln("Could not create a Korean collator");\r
320             Locale.setDefault(oldDefault);\r
321             return;\r
322         }\r
323         \r
324         // Since the fix to this bug was to turn off decomposition for Korean collators,\r
325         // ensure that's what we got\r
326         if (c.getDecomposition() != Collator.NO_DECOMPOSITION) {\r
327           errln("Decomposition is not set to NO_DECOMPOSITION for Korean collator");\r
328         }\r
329     \r
330         Locale.setDefault(oldDefault);\r
331     }\r
332     \r
333     // @bug 4059820\r
334     //\r
335     // RuleBasedCollator.getRules does not return the exact pattern as input\r
336     // for expanding character sequences\r
337     //\r
338     public void Test4059820(/* char* par */) {\r
339         RuleBasedCollator c = null;\r
340         String rules = "< a < b , c/a < d < z";\r
341         try {\r
342             c = new RuleBasedCollator(rules);\r
343         } catch (Exception e) {\r
344             errln("Failure building a collator.");\r
345             return;\r
346         }\r
347     \r
348         if ( c.getRules().indexOf("c/a") == -1)\r
349         {\r
350             errln("returned rules do not contain 'c/a'");\r
351         }\r
352     }\r
353     \r
354     // @bug 4060154\r
355     //\r
356     // MergeCollation::fixEntry broken for "& H < \u0131, \u0130, i, I"\r
357     //\r
358     public void Test4060154(/* char* par */) {\r
359         String rules ="< g, G < h, H < i, I < j, J & H < \u0131, \u0130, i, I";\r
360     \r
361         RuleBasedCollator c = null;\r
362         try {\r
363             c = new RuleBasedCollator(rules);\r
364         } catch (Exception e) {\r
365             //System.out.println(e);\r
366             errln("failure building collator.");\r
367             return;\r
368         }\r
369     \r
370         c.setDecomposition(Collator.NO_DECOMPOSITION);\r
371     \r
372         String[] tertiary = {\r
373             "A",        "<",    "B",\r
374             "H",        "<",    "\u0131",\r
375             "H",        "<",    "I",\r
376             "\u0131",   "<",    "\u0130",\r
377             "\u0130",   "<",    "i",\r
378             "\u0130",   ">",    "H",\r
379         };\r
380     \r
381         c.setStrength(Collator.TERTIARY);\r
382         compareArray(c, tertiary);\r
383     \r
384         String[] secondary = {\r
385             "H",        "<",    "I",\r
386             "\u0131",   "=",    "\u0130",\r
387         };\r
388     \r
389         c.setStrength(Collator.PRIMARY);\r
390         compareArray(c, secondary);\r
391     }\r
392     \r
393     // @bug 4062418\r
394     //\r
395     // Secondary/Tertiary comparison incorrect in French Secondary\r
396     //\r
397     public void Test4062418(/* char* par */) {\r
398         RuleBasedCollator c = null;\r
399         try {\r
400             c = (RuleBasedCollator) Collator.getInstance(Locale.FRANCE);\r
401         } catch (Exception e) {\r
402             errln("Failed to create collator for Locale::FRANCE()");\r
403             return;\r
404         }\r
405         c.setStrength(Collator.SECONDARY);\r
406     \r
407         String[] tests = {\r
408                 "p\u00eache",    "<",    "p\u00e9ch\u00e9",    // Comparing accents from end, p\u00e9ch\u00e9 is greater\r
409         };\r
410     \r
411         compareArray(c, tests);\r
412     }\r
413     \r
414     // @bug 4065540\r
415     //\r
416     // Collator::compare() method broken if either string contains spaces\r
417     //\r
418     public void Test4065540(/* char* par */) {\r
419         RuleBasedCollator en_us = (RuleBasedCollator) Collator.getInstance(Locale.US);\r
420         if (en_us.compare("abcd e", "abcd f") == 0) {\r
421             errln("'abcd e' == 'abcd f'");\r
422         }\r
423     }\r
424     \r
425     // @bug 4066189\r
426     //\r
427     // Unicode characters need to be recursively decomposed to get the\r
428     // correct result. For example,\r
429     // u1EB1 -> \u0103 + \u0300 -> a + \u0306 + \u0300.\r
430     //\r
431     public void Test4066189(/* char* par */) {\r
432         final  String test1 = "\u1EB1";\r
433         final  String test2 = "\u0061\u0306\u0300";\r
434     \r
435         // NOTE: The java code used en_us to create the\r
436         // CollationElementIterator's. I'm pretty sure that\r
437         // was wrong, so I've change the code to use c1 and c2\r
438         RuleBasedCollator c1 = (RuleBasedCollator) Collator.getInstance(Locale.US);\r
439         c1.setDecomposition(Collator.CANONICAL_DECOMPOSITION);\r
440         CollationElementIterator i1 = c1.getCollationElementIterator(test1);\r
441     \r
442         RuleBasedCollator c2 = (RuleBasedCollator) Collator.getInstance(Locale.US);\r
443         c2.setDecomposition(Collator.NO_DECOMPOSITION);\r
444         CollationElementIterator i2 = c2.getCollationElementIterator(test2);\r
445     \r
446         assertEqual(i1, i2);\r
447     }\r
448     \r
449     // @bug 4066696\r
450     //\r
451     // French secondary collation checking at the end of compare iteration fails\r
452     //\r
453     public void Test4066696(/* char* par */) {\r
454         RuleBasedCollator c = null;\r
455         try {\r
456             c = (RuleBasedCollator)Collator.getInstance(Locale.FRANCE);\r
457         } catch(Exception e) {\r
458             errln("Failure creating collator for Locale::getFrance()");\r
459             return;\r
460         }\r
461         c.setStrength(Collator.SECONDARY);\r
462     \r
463         String[] tests = {\r
464             "\u00e0",   ">",     "\u01fa",       // a-grave <  A-ring-acute\r
465         };    \r
466         compareArray(c, tests);\r
467     }\r
468     \r
469     // @bug 4076676\r
470     //\r
471     // Bad canonicalization of same-class combining characters\r
472     //\r
473     public void Test4076676(/* char* par */) {\r
474         // These combining characters are all in the same class, so they should not\r
475         // be reordered, and they should compare as unequal.\r
476         final String s1 = "\u0041\u0301\u0302\u0300";\r
477         final String s2 = "\u0041\u0302\u0300\u0301";\r
478     \r
479         RuleBasedCollator c = (RuleBasedCollator) Collator.getInstance(Locale.US);\r
480         c.setStrength(Collator.TERTIARY);\r
481     \r
482         if (c.compare(s1,s2) == 0) {\r
483             errln("Same-class combining chars were reordered");\r
484         }\r
485     }\r
486 \r
487     // @bug 4078588\r
488     //\r
489     // RuleBasedCollator breaks on "< a < bb" rule\r
490     //\r
491     public void Test4078588(/* char *par */) {\r
492         RuleBasedCollator rbc = null;\r
493         try {\r
494             rbc = new RuleBasedCollator("< a < bb");\r
495         } catch (Exception e) {\r
496             errln("Failed to create RuleBasedCollator.");\r
497             return;\r
498         }\r
499     \r
500         int result = rbc.compare("a","bb");\r
501     \r
502         if (result >= 0) {\r
503             errln("Compare(a,bb) returned " + result + "; expected -1");\r
504         }\r
505     }\r
506     \r
507     // @bug 4079231\r
508     //\r
509     // RuleBasedCollator::operator==(NULL) throws NullPointerException\r
510     //\r
511     public void Test4079231(/* char* par */) {    \r
512         RuleBasedCollator en_us = (RuleBasedCollator) Collator.getInstance(Locale.US);\r
513         try {\r
514             if (en_us.equals(null)) {\r
515                 errln("en_us.equals(null) returned true");\r
516             }\r
517         } catch (Exception e) {\r
518             errln("en_us.equals(null) threw " + e.toString());\r
519         }\r
520     }\r
521     \r
522     // @bug 4081866\r
523     //\r
524     // Combining characters in different classes not reordered properly.\r
525     //\r
526     public void Test4081866(/* char* par */) {\r
527         // These combining characters are all in different classes,\r
528         // so they should be reordered and the strings should compare as equal.\r
529         String s1 = "\u0041\u0300\u0316\u0327\u0315";\r
530         String s2 = "\u0041\u0327\u0316\u0315\u0300";\r
531     \r
532         RuleBasedCollator c = (RuleBasedCollator) Collator.getInstance(Locale.US);\r
533         c.setStrength(Collator.TERTIARY);\r
534         \r
535         // Now that the default collators are set to NO_DECOMPOSITION\r
536         // (as a result of fixing bug 4114077), we must set it explicitly\r
537         // when we're testing reordering behavior.  -- lwerner, 5/5/98\r
538         c.setDecomposition(Collator.CANONICAL_DECOMPOSITION);\r
539         if (c.compare(s1,s2) != 0) {\r
540             errln("Combining chars were not reordered");\r
541         }\r
542     }\r
543     \r
544     // @bug 4087241\r
545     //\r
546     // string comparison errors in Scandinavian collators\r
547     //\r
548     public void Test4087241(/* char* par */) {\r
549         Locale da_DK = new Locale("da", "DK");\r
550         RuleBasedCollator c = null;\r
551         try {\r
552             c = (RuleBasedCollator) Collator.getInstance(da_DK);\r
553         } catch (Exception e) {\r
554             errln("Failed to create collator for da_DK locale");\r
555             return;\r
556         }\r
557         c.setStrength(Collator.SECONDARY);\r
558         String tests[] = {\r
559             "\u007a",       "\u003c", "\u00E6",            // z        < ae\r
560             "\u0061\u0308", "\u003c", "\u0061\u030A",      // a-unlaut < a-ring\r
561             "\u0059",       "\u003c", "\u0075\u0308",      // Y        < u-umlaut\r
562         };\r
563         compareArray(c, tests);\r
564     }\r
565     \r
566     // @bug 4087243\r
567     //\r
568     // CollationKey takes ignorable strings into account when it shouldn't\r
569     //\r
570     public void Test4087243(/* char* par */) {\r
571         RuleBasedCollator c = (RuleBasedCollator) Collator.getInstance(Locale.US);\r
572         c.setStrength(Collator.TERTIARY);\r
573         String tests[] = {\r
574             "\u0031\u0032\u0033", "\u003d", "\u0031\u0032\u0033\u0001"    // 1 2 3  =  1 2 3 ctrl-A\r
575         };\r
576         compareArray(c, tests);\r
577     }\r
578     \r
579     // @bug 4092260\r
580     //\r
581     // Mu/micro conflict\r
582     // Micro symbol and greek lowercase letter Mu should sort identically\r
583     //\r
584     public void Test4092260(/* char* par */) {\r
585         Locale el = new Locale("el", "");\r
586         Collator c = null;\r
587         try {\r
588             c = Collator.getInstance(el);\r
589         } catch (Exception e) {\r
590             errln("Failed to create collator for el locale.");\r
591             return;\r
592         }\r
593         // These now have tertiary differences in UCA\r
594         c.setStrength(Collator.SECONDARY);\r
595         String tests[] = {\r
596             "\u00B5", "\u003d", "\u03BC",\r
597         };\r
598         compareArray(c, tests);\r
599     }\r
600     \r
601     // @bug 4095316\r
602     //\r
603     public void Test4095316(/* char* par */) {\r
604         Locale el_GR = new Locale("el", "GR");\r
605         Collator c = null;\r
606         try {\r
607             c = Collator.getInstance(el_GR);\r
608         } catch (Exception e) {\r
609             errln("Failed to create collator for el_GR locale");\r
610             return;\r
611         }\r
612         // These now have tertiary differences in UCA\r
613         //c->setStrength(Collator::TERTIARY);\r
614         //c->setAttribute(UCOL_STRENGTH, UCOL_SECONDARY, status);\r
615         c.setStrength(Collator.SECONDARY);\r
616         String tests[] = {\r
617             "\u03D4", "\u003d", "\u03AB",\r
618         };\r
619         compareArray(c, tests);\r
620     }\r
621     \r
622     // @bug 4101940\r
623     //\r
624     public void Test4101940(/* char* par */) {\r
625         RuleBasedCollator c = null;\r
626         String rules = "< a < b";\r
627         String nothing = "";\r
628         try {\r
629             c = new RuleBasedCollator(rules);\r
630         } catch (Exception e) {\r
631             errln("Failed to create RuleBasedCollator");\r
632             return;\r
633         }\r
634         CollationElementIterator i = c.getCollationElementIterator(nothing);\r
635         i.reset();\r
636         if (i.next() != CollationElementIterator.NULLORDER) {\r
637             errln("next did not return NULLORDER");\r
638         }\r
639     }\r
640     \r
641     // @bug 4103436\r
642     //\r
643     // Collator::compare not handling spaces properly\r
644     //\r
645     public void Test4103436(/* char* par */) {\r
646         RuleBasedCollator c = (RuleBasedCollator) Collator.getInstance(Locale.US);\r
647         c.setStrength(Collator.TERTIARY);\r
648         String[] tests = {\r
649             "\u0066\u0069\u006c\u0065", "\u003c", "\u0066\u0069\u006c\u0065\u0020\u0061\u0063\u0063\u0065\u0073\u0073",\r
650             "\u0066\u0069\u006c\u0065", "\u003c", "\u0066\u0069\u006c\u0065\u0061\u0063\u0063\u0065\u0073\u0073",\r
651         };\r
652         compareArray(c, tests);\r
653     }\r
654     \r
655     // @bug 4114076\r
656     //\r
657     // Collation not Unicode conformant with Hangul syllables\r
658     //\r
659     public void Test4114076(/* char* par */) {\r
660         RuleBasedCollator c = (RuleBasedCollator) Collator.getInstance(Locale.US);\r
661         c.setStrength(Collator.TERTIARY);\r
662     \r
663         //\r
664         // With Canonical decomposition, Hangul syllables should get decomposed\r
665         // into Jamo, but Jamo characters should not be decomposed into\r
666         // conjoining Jamo\r
667         //\r
668         String test1[] = {\r
669             "\ud4db", "\u003d", "\u1111\u1171\u11b6"\r
670         };\r
671     \r
672         c.setDecomposition(Collator.CANONICAL_DECOMPOSITION);\r
673         compareArray(c, test1);\r
674     \r
675         // From UTR #15:\r
676         // *In earlier versions of Unicode, jamo characters like ksf\r
677         //  had compatibility mappings to kf + sf. These mappings were \r
678         //  removed in Unicode 2.1.9 to ensure that Hangul syllables are maintained.)\r
679         // That is, the following test is obsolete as of 2.1.9\r
680     \r
681     //obsolete-    // With Full decomposition, it should go all the way down to\r
682     //obsolete-    // conjoining Jamo characters.\r
683     //obsolete-    //\r
684     //obsolete-    static const UChar test2[][CollationRegressionTest::MAX_TOKEN_LEN] =\r
685     //obsolete-    {\r
686     //obsolete-        {0xd4db, 0}, {0x3d, 0}, {0x1111, 0x116e, 0x1175, 0x11af, 0x11c2, 0}\r
687     //obsolete-    };\r
688     //obsolete-\r
689     //obsolete-    c->setDecomposition(Normalizer::DECOMP_COMPAT);\r
690     //obsolete-    compareArray(*c, test2, ARRAY_LENGTH(test2));\r
691     }\r
692 \r
693     // @bug 4114077\r
694     //\r
695     // Collation with decomposition off doesn't work for Europe \r
696     //\r
697     public void Test4114077(/* char* par */) {\r
698         // Ensure that we get the same results with decomposition off\r
699         // as we do with it on....\r
700         RuleBasedCollator c = (RuleBasedCollator) Collator.getInstance(Locale.US);\r
701         c.setStrength(Collator.TERTIARY);\r
702         String test1[] = {\r
703             "\u00C0",                         "\u003d", "\u0041\u0300",            // Should be equivalent\r
704             "\u0070\u00ea\u0063\u0068\u0065", "\u003e", "\u0070\u00e9\u0063\u0068\u00e9",\r
705             "\u0204",                         "\u003d", "\u0045\u030F",\r
706             "\u01fa",                         "\u003d", "\u0041\u030a\u0301",    // a-ring-acute -> a-ring, acute\r
707                                                     //   -> a, ring, acute\r
708             "\u0041\u0300\u0316",             "\u003c", "\u0041\u0316\u0300"        // No reordering --> unequal\r
709         };\r
710     \r
711         c.setDecomposition(Collator.NO_DECOMPOSITION);\r
712         compareArray(c, test1);\r
713     \r
714         String test2[] = {\r
715             "\u0041\u0300\u0316", "\u003d", "\u0041\u0316\u0300"      // Reordering --> equal\r
716         };\r
717     \r
718         c.setDecomposition(Collator.CANONICAL_DECOMPOSITION);\r
719         compareArray(c, test2);\r
720     }\r
721     \r
722     // @bug 4124632\r
723     //\r
724     // Collator::getCollationKey was hanging on certain character sequences\r
725     //\r
726     public void Test4124632(/* char* par */) {\r
727         Collator coll = null;\r
728         try {\r
729             coll = Collator.getInstance(Locale.JAPAN);\r
730         } catch (Exception e) {\r
731             errln("Failed to create collator for Locale::JAPAN");\r
732             return;\r
733         }\r
734         String test = "\u0041\u0308\u0062\u0063";\r
735         CollationKey key;\r
736         try {\r
737             key = coll.getCollationKey(test);\r
738             logln(key.getSourceString());\r
739         } catch (Exception e) {\r
740             errln("CollationKey creation failed.");\r
741         }\r
742     }\r
743     \r
744     // @bug 4132736\r
745     //\r
746     // sort order of french words with multiple accents has errors\r
747     //\r
748     public void Test4132736(/* char* par */) {\r
749         Collator c = null;\r
750         try {\r
751             c = Collator.getInstance(Locale.FRANCE);\r
752             c.setStrength(Collator.TERTIARY);\r
753         } catch (Exception e) {\r
754             errln("Failed to create a collator for Locale::getFrance()");\r
755         }\r
756     \r
757         String test1[] = {\r
758             "\u0065\u0300\u0065\u0301", "\u003c", "\u0065\u0301\u0065\u0300",\r
759             "\u0065\u0300\u0301",       "\u003c", "\u0065\u0301\u0300",\r
760         };\r
761         compareArray(c, test1);\r
762     }\r
763     \r
764     // @bug 4133509\r
765     //\r
766     // The sorting using java.text.CollationKey is not in the exact order\r
767     //\r
768     public void Test4133509(/* char* par */) {\r
769         RuleBasedCollator en_us = (RuleBasedCollator) Collator.getInstance(Locale.US);\r
770         String test1[] = {\r
771             "\u0045\u0078\u0063\u0065\u0070\u0074\u0069\u006f\u006e", "\u003c", "\u0045\u0078\u0063\u0065\u0070\u0074\u0069\u006f\u006e\u0049\u006e\u0049\u006e\u0069\u0074\u0069\u0061\u006c\u0069\u007a\u0065\u0072\u0045\u0072\u0072\u006f\u0072",\r
772             "\u0047\u0072\u0061\u0070\u0068\u0069\u0063\u0073",       "\u003c", "\u0047\u0072\u0061\u0070\u0068\u0069\u0063\u0073\u0045\u006e\u0076\u0069\u0072\u006f\u006e\u006d\u0065\u006e\u0074",\r
773             "\u0053\u0074\u0072\u0069\u006e\u0067",                   "\u003c", "\u0053\u0074\u0072\u0069\u006e\u0067\u0042\u0075\u0066\u0066\u0065\u0072",\r
774         };\r
775     \r
776         compareArray(en_us, test1);\r
777     }\r
778     \r
779     // @bug 4139572\r
780     //\r
781     // getCollationKey throws exception for spanish text \r
782     // Cannot reproduce this bug on 1.2, however it DOES fail on 1.1.6\r
783     //\r
784     public void Test4139572(/* char* par */) {\r
785         //\r
786         // Code pasted straight from the bug report\r
787         // (and then translated to C++ ;-)\r
788         //\r
789         // create spanish locale and collator\r
790         Locale l = new Locale("es", "es");\r
791         Collator col = null;\r
792         try {\r
793             col = Collator.getInstance(l);\r
794         } catch (Exception e) {\r
795             errln("Failed to create a collator for es_es locale.");\r
796             return;\r
797         }\r
798         CollationKey key = null;\r
799         // this spanish phrase kills it!\r
800         try {\r
801             key = col.getCollationKey("Nombre De Objeto");\r
802             logln("source:" + key.getSourceString());\r
803         } catch (Exception e) {\r
804             errln("Error creating CollationKey for \"Nombre De Ojbeto\"");\r
805         }\r
806     }\r
807     \r
808     // @bug 4141640\r
809     //\r
810     // Support for Swedish gone in 1.1.6 (Can't create Swedish collator) \r
811     //\r
812     public void Test4141640(/* char* par */) {\r
813         //\r
814         // Rather than just creating a Swedish collator, we might as well\r
815         // try to instantiate one for every locale available on the system\r
816         // in order to prevent this sort of bug from cropping up in the future\r
817         //\r
818         Locale locales[] = Collator.getAvailableLocales();\r
819         \r
820         for (int i = 0; i < locales.length; i += 1)\r
821         {\r
822             Collator c = null;\r
823             try {\r
824                 c = Collator.getInstance(locales[i]);\r
825                 logln("source: " + c.getStrength());\r
826             } catch (Exception e) {\r
827                 String msg = "";\r
828                 msg += "Could not create collator for locale ";\r
829                 msg += locales[i].getDisplayName();\r
830                 errln(msg);\r
831             }\r
832         }\r
833     }\r
834     \r
835     private void checkListOrder(String[] sortedList, Collator c) {\r
836         // this function uses the specified Collator to make sure the\r
837         // passed-in list is already sorted into ascending order\r
838         for (int i = 0; i < sortedList.length - 1; i++) {\r
839             if (c.compare(sortedList[i], sortedList[i + 1]) >= 0) {\r
840                 errln("List out of order at element #" + i + ": "\r
841                         + sortedList[i] + " >= "\r
842                         + sortedList[i + 1]);\r
843             }\r
844         }\r
845     }\r
846 \r
847     public void Test4171974() {\r
848         // test French accent ordering more thoroughly\r
849         /*String[] frenchList = {\r
850             "\u0075\u0075",     // u u\r
851             "\u00fc\u0075",     // u-umlaut u\r
852             "\u01d6\u0075",     // u-umlaut-macron u\r
853             "\u016b\u0075",     // u-macron u\r
854             "\u1e7b\u0075",     // u-macron-umlaut u\r
855             "\u0075\u00fc",     // u u-umlaut\r
856             "\u00fc\u00fc",     // u-umlaut u-umlaut\r
857             "\u01d6\u00fc",     // u-umlaut-macron u-umlaut\r
858             "\u016b\u00fc",     // u-macron u-umlaut\r
859             "\u1e7b\u00fc",     // u-macron-umlaut u-umlaut\r
860             "\u0075\u01d6",     // u u-umlaut-macron\r
861             "\u00fc\u01d6",     // u-umlaut u-umlaut-macron\r
862             "\u01d6\u01d6",     // u-umlaut-macron u-umlaut-macron\r
863             "\u016b\u01d6",     // u-macron u-umlaut-macron\r
864             "\u1e7b\u01d6",     // u-macron-umlaut u-umlaut-macron\r
865             "\u0075\u016b",     // u u-macron\r
866             "\u00fc\u016b",     // u-umlaut u-macron\r
867             "\u01d6\u016b",     // u-umlaut-macron u-macron\r
868             "\u016b\u016b",     // u-macron u-macron\r
869             "\u1e7b\u016b",     // u-macron-umlaut u-macron\r
870             "\u0075\u1e7b",     // u u-macron-umlaut\r
871             "\u00fc\u1e7b",     // u-umlaut u-macron-umlaut\r
872             "\u01d6\u1e7b",     // u-umlaut-macron u-macron-umlaut\r
873             "\u016b\u1e7b",     // u-macron u-macron-umlaut\r
874             "\u1e7b\u1e7b"      // u-macron-umlaut u-macron-umlaut\r
875         };\r
876         Collator french = Collator.getInstance(Locale.FRENCH);\r
877 \r
878         logln("Testing French order...");\r
879         checkListOrder(frenchList, french);\r
880 \r
881         logln("Testing French order without decomposition...");\r
882         french.setDecomposition(Collator.NO_DECOMPOSITION);\r
883         checkListOrder(frenchList, french);*/\r
884 \r
885         String[] englishList = {\r
886             "\u0075\u0075",     // u u\r
887             "\u0075\u00fc",     // u u-umlaut\r
888             "\u0075\u01d6",     // u u-umlaut-macron\r
889             "\u0075\u016b",     // u u-macron\r
890             "\u0075\u1e7b",     // u u-macron-umlaut\r
891             "\u00fc\u0075",     // u-umlaut u\r
892             "\u00fc\u00fc",     // u-umlaut u-umlaut\r
893             "\u00fc\u01d6",     // u-umlaut u-umlaut-macron\r
894             "\u00fc\u016b",     // u-umlaut u-macron\r
895             "\u00fc\u1e7b",     // u-umlaut u-macron-umlaut\r
896             "\u01d6\u0075",     // u-umlaut-macron u\r
897             "\u01d6\u00fc",     // u-umlaut-macron u-umlaut\r
898             "\u01d6\u01d6",     // u-umlaut-macron u-umlaut-macron\r
899             "\u01d6\u016b",     // u-umlaut-macron u-macron\r
900             "\u01d6\u1e7b",     // u-umlaut-macron u-macron-umlaut\r
901             "\u016b\u0075",     // u-macron u\r
902             "\u016b\u00fc",     // u-macron u-umlaut\r
903             "\u016b\u01d6",     // u-macron u-umlaut-macron\r
904             "\u016b\u016b",     // u-macron u-macron\r
905             "\u016b\u1e7b",     // u-macron u-macron-umlaut\r
906             "\u1e7b\u0075",     // u-macron-umlaut u\r
907             "\u1e7b\u00fc",     // u-macron-umlaut u-umlaut\r
908             "\u1e7b\u01d6",     // u-macron-umlaut u-umlaut-macron\r
909             "\u1e7b\u016b",     // u-macron-umlaut u-macron\r
910             "\u1e7b\u1e7b"      // u-macron-umlaut u-macron-umlaut\r
911         };\r
912         Collator english = Collator.getInstance(Locale.ENGLISH);\r
913 \r
914         logln("Testing English order...");\r
915         checkListOrder(englishList, english);\r
916 \r
917         logln("Testing English order without decomposition...");\r
918         english.setDecomposition(Collator.NO_DECOMPOSITION);\r
919         checkListOrder(englishList, english);\r
920     }\r
921 \r
922     public void Test4179216() throws Exception {\r
923         // you can position a CollationElementIterator in the middle of\r
924         // a contracting character sequence, yielding a bogus collation\r
925         // element\r
926         RuleBasedCollator coll = (RuleBasedCollator)Collator.getInstance(Locale.US);\r
927         coll = new RuleBasedCollator(coll.getRules()\r
928                 + " & C < ch , cH , Ch , CH < cat < crunchy");\r
929         String testText = "church church catcatcher runcrunchynchy";\r
930         CollationElementIterator iter = coll.getCollationElementIterator(\r
931                 testText);\r
932 \r
933         // test that the "ch" combination works properly\r
934         iter.setOffset(4);\r
935         int elt4 = CollationElementIterator.primaryOrder(iter.next());\r
936 \r
937         iter.reset();\r
938         int elt0 = CollationElementIterator.primaryOrder(iter.next());\r
939 \r
940         iter.setOffset(5);\r
941         int elt5 = CollationElementIterator.primaryOrder(iter.next());\r
942 \r
943         if (elt4 != elt0 || elt5 != elt0)\r
944             errln("The collation elements at positions 0 (" + elt0 + "), 4 ("\r
945                     + elt4 + "), and 5 (" + elt5 + ") don't match.");\r
946 \r
947         // test that the "cat" combination works properly\r
948         iter.setOffset(14);\r
949         int elt14 = CollationElementIterator.primaryOrder(iter.next());\r
950 \r
951         iter.setOffset(15);\r
952         int elt15 = CollationElementIterator.primaryOrder(iter.next());\r
953 \r
954         iter.setOffset(16);\r
955         int elt16 = CollationElementIterator.primaryOrder(iter.next());\r
956 \r
957         iter.setOffset(17);\r
958         int elt17 = CollationElementIterator.primaryOrder(iter.next());\r
959 \r
960         iter.setOffset(18);\r
961         int elt18 = CollationElementIterator.primaryOrder(iter.next());\r
962 \r
963         iter.setOffset(19);\r
964         int elt19 = CollationElementIterator.primaryOrder(iter.next());\r
965 \r
966         if (elt14 != elt15 || elt14 != elt16 || elt14 != elt17\r
967                 || elt14 != elt18 || elt14 != elt19)\r
968             errln("\"cat\" elements don't match: elt14 = " + elt14 + ", elt15 = "\r
969             + elt15 + ", elt16 = " + elt16 + ", elt17 = " + elt17\r
970             + ", elt18 = " + elt18 + ", elt19 = " + elt19);\r
971 \r
972         // now generate a complete list of the collation elements,\r
973         // first using next() and then using setOffset(), and\r
974         // make sure both interfaces return the same set of elements\r
975         iter.reset();\r
976 \r
977         int elt = iter.next();\r
978         int count = 0;\r
979         while (elt != CollationElementIterator.NULLORDER) {\r
980             ++count;\r
981             elt = iter.next();\r
982         }\r
983 \r
984         String[] nextElements = new String[count];\r
985         String[] setOffsetElements = new String[count];\r
986         int lastPos = 0;\r
987 \r
988         iter.reset();\r
989         elt = iter.next();\r
990         count = 0;\r
991         while (elt != CollationElementIterator.NULLORDER) {\r
992             nextElements[count++] = testText.substring(lastPos, iter.getOffset());\r
993             lastPos = iter.getOffset();\r
994             elt = iter.next();\r
995         }\r
996         count = 0;\r
997         for (int i = 0; i < testText.length(); ) {\r
998             iter.setOffset(i);\r
999             lastPos = iter.getOffset();\r
1000             elt = iter.next();\r
1001             setOffsetElements[count++] = testText.substring(lastPos, iter.getOffset());\r
1002             i = iter.getOffset();\r
1003         }\r
1004         for (int i = 0; i < nextElements.length; i++) {\r
1005             if (nextElements[i].equals(setOffsetElements[i])) {\r
1006                 logln(nextElements[i]);\r
1007             } else {\r
1008                 errln("Error: next() yielded " + nextElements[i] + ", but setOffset() yielded "\r
1009                     + setOffsetElements[i]);\r
1010             }\r
1011         }\r
1012     }\r
1013 \r
1014     public void Test4216006() throws Exception {\r
1015         // rule parser barfs on "<\u00e0=a\u0300", and on other cases\r
1016         // where the same token (after normalization) appears twice in a row\r
1017         boolean caughtException = false;\r
1018         try {\r
1019             new RuleBasedCollator("\u00e0<a\u0300");\r
1020         }\r
1021         catch (ParseException e) {\r
1022             caughtException = true;\r
1023         }\r
1024         if (!caughtException) {\r
1025             throw new Exception("\"a<a\" collation sequence didn't cause parse error!");\r
1026         }\r
1027 \r
1028         RuleBasedCollator collator = new RuleBasedCollator("<\u00e0=a\u0300");\r
1029         //commented by Kevin 2003/10/21 \r
1030         //for "FULL_DECOMPOSITION is not supported here." in ICU4J DOC\r
1031         //collator.setDecomposition(Collator.FULL_DECOMPOSITION);\r
1032         collator.setStrength(Collator.IDENTICAL);\r
1033 \r
1034         String[] tests = {\r
1035             "a\u0300", "=", "\u00e0",\r
1036             "\u00e0",  "=", "a\u0300"\r
1037         };\r
1038 \r
1039         compareArray(collator, tests);\r
1040     }\r
1041 \r
1042     // CollationElementIterator.previous broken for expanding char sequences\r
1043     //\r
1044     public void Test4179686() throws Exception {\r
1045         RuleBasedCollator en_us = (RuleBasedCollator) Collator.getInstance(Locale.US);\r
1046         // Create a collator with a few expanding character sequences in it....\r
1047         RuleBasedCollator coll = new RuleBasedCollator(en_us.getRules()\r
1048                                                     + " & ae ; \u00e4 & AE ; \u00c4"\r
1049                                                     + " & oe ; \u00f6 & OE ; \u00d6"\r
1050                                                     + " & ue ; \u00fc & UE ; \u00dc");\r
1051 \r
1052         String text = "T\u00f6ne"; // o-umlaut\r
1053 \r
1054         CollationElementIterator iter = coll.getCollationElementIterator(text);\r
1055         Vector elements = new Vector();\r
1056         int elem;\r
1057 \r
1058         // Iterate forward and collect all of the elements into a Vector\r
1059         while ((elem = iter.next()) != CollationElementIterator.NULLORDER) {\r
1060             elements.addElement(new Integer(elem));\r
1061         }\r
1062 \r
1063         // Now iterate backward and make sure they're the same\r
1064         int index = elements.size() - 1;\r
1065         while ((elem = iter.previous()) != CollationElementIterator.NULLORDER) {\r
1066             int expect = ((Integer)elements.elementAt(index)).intValue();\r
1067 \r
1068             if (elem != expect) {\r
1069                 errln("Mismatch at index " + index\r
1070                       + ": got " + Integer.toString(elem,16)\r
1071                       + ", expected " + Integer.toString(expect,16));\r
1072             }\r
1073             index--;\r
1074         }\r
1075     }\r
1076 \r
1077     protected void init()throws Exception{\r
1078     }\r
1079     \r
1080     public void Test4244884() throws Exception {\r
1081         RuleBasedCollator coll = (RuleBasedCollator)Collator.getInstance(Locale.US);\r
1082         coll = new RuleBasedCollator(coll.getRules()\r
1083                 + " & C < ch , cH , Ch , CH < cat < crunchy");\r
1084 \r
1085         String[] testStrings = new String[] {\r
1086             "car",\r
1087             "cave",\r
1088             "clamp",\r
1089             "cramp",\r
1090             "czar",\r
1091             "church",\r
1092             "catalogue",\r
1093             "crunchy",\r
1094             "dog"\r
1095         };\r
1096 \r
1097         for (int i = 1; i < testStrings.length; i++) {\r
1098             if (coll.compare(testStrings[i - 1], testStrings[i]) >= 0) {\r
1099                 errln("error: \"" + testStrings[i - 1]\r
1100                     + "\" is greater than or equal to \"" + testStrings[i]\r
1101                     + "\".");\r
1102             }\r
1103         }\r
1104     }\r
1105 \r
1106     //  CollationElementIterator set doesn't work propertly with next/prev\r
1107     public void Test4663220() {\r
1108         RuleBasedCollator collator = (RuleBasedCollator)Collator.getInstance(Locale.US);\r
1109         java.text.StringCharacterIterator stringIter = new java.text.StringCharacterIterator("fox");\r
1110         CollationElementIterator iter = collator.getCollationElementIterator(stringIter);\r
1111     \r
1112         int[] elements_next = new int[3];\r
1113         logln("calling next:");\r
1114         for (int i = 0; i < 3; ++i) {\r
1115             logln("[" + i + "] " + (elements_next[i] = iter.next()));\r
1116         }\r
1117     \r
1118         int[] elements_fwd = new int[3];\r
1119         logln("calling set/next:");\r
1120         for (int i = 0; i < 3; ++i) {\r
1121             iter.setOffset(i);\r
1122             logln("[" + i + "] " + (elements_fwd[i] = iter.next()));\r
1123         }\r
1124     \r
1125         for (int i = 0; i < 3; ++i) {\r
1126             if (elements_next[i] != elements_fwd[i]) {\r
1127                 errln("mismatch at position " + i + \r
1128                 ": " + elements_next[i] + \r
1129                 " != " + elements_fwd[i]);\r
1130             }\r
1131         }\r
1132     }\r
1133     \r
1134     /* RuleBasedCollator not subclassable\r
1135      * @bug 4146160\r
1136     //\r
1137     // RuleBasedCollator doesn't use createCollationElementIterator internally\r
1138     //\r
1139     public void Test4146160() {\r
1140         //\r
1141         // Use a custom collator class whose createCollationElementIterator\r
1142         // methods increment a count....\r
1143         //     \r
1144         RuleBasedCollator en_us = (RuleBasedCollator) Collator.getInstance(Locale.US);\r
1145         My4146160Collator.count = 0;\r
1146         My4146160Collator mc = null;\r
1147         try {\r
1148             mc = new My4146160Collator(en_us);\r
1149         } catch (Exception e) {\r
1150             errln("Failed to create a My4146160Collator.");\r
1151             return;\r
1152         }\r
1153     \r
1154         CollationKey key = null;\r
1155         try {\r
1156             key = mc.getCollationKey("1");\r
1157         } catch (Exception e) {\r
1158             errln("Failure to get a CollationKey from a My4146160Collator.");\r
1159             return;\r
1160         }\r
1161     \r
1162         if (My4146160Collator.count < 1) {\r
1163             errln("My4146160Collator.getCollationElementIterator not called for getCollationKey");\r
1164         }\r
1165     \r
1166         My4146160Collator.count = 0;\r
1167         mc.compare("1", "2");\r
1168     \r
1169         if (My4146160Collator.count < 1) {\r
1170             errln("My4146160Collator.getCollationElementIterator not called for compare");\r
1171         }\r
1172     }*/\r
1173 }\r
1174 \r
1175 /* RuleBasedCollator not subclassable\r
1176  * class My4146160Collator extends RuleBasedCollator {\r
1177     static int count = 0;\r
1178 \r
1179     public My4146160Collator(RuleBasedCollator rbc) throws Exception {\r
1180         super(rbc.getRules());\r
1181     }\r
1182 \r
1183     public CollationElementIterator getCollationElementIterator(String text) {\r
1184         count += 1;\r
1185         return super.getCollationElementIterator(text);\r
1186     }\r
1187     \r
1188     public CollationElementIterator getCollationElementIterator(java.text.CharacterIterator text) {\r
1189         count += 1;\r
1190         return super.getCollationElementIterator(text);\r
1191     }\r
1192 }\r
1193 */