2 *******************************************************************************
\r
3 * Copyright (C) 2002-2009, International Business Machines Corporation and *
\r
4 * others. All Rights Reserved. *
\r
5 *******************************************************************************
\r
9 * Port From: ICU4C v2.1 : collate/CollationAPITest
\r
10 * Source File: $ICU4CRoot/source/test/intltest/apicoll.cpp
\r
13 package com.ibm.icu.dev.test.collator;
\r
15 import java.text.CharacterIterator;
\r
16 import java.text.StringCharacterIterator;
\r
17 import java.util.Arrays;
\r
18 import java.util.HashSet;
\r
19 import java.util.Locale;
\r
20 import java.util.MissingResourceException;
\r
21 import java.util.Set;
\r
23 import com.ibm.icu.dev.test.TestFmwk;
\r
24 import com.ibm.icu.text.CollationElementIterator;
\r
25 import com.ibm.icu.text.CollationKey;
\r
26 import com.ibm.icu.text.Collator;
\r
27 import com.ibm.icu.text.RawCollationKey;
\r
28 import com.ibm.icu.text.RuleBasedCollator;
\r
29 import com.ibm.icu.text.UCharacterIterator;
\r
30 import com.ibm.icu.text.UnicodeSet;
\r
31 import com.ibm.icu.text.Collator.CollatorFactory;
\r
32 import com.ibm.icu.util.ULocale;
\r
33 import com.ibm.icu.util.VersionInfo;
\r
35 public class CollationAPITest extends TestFmwk {
\r
36 public static void main(String[] args) throws Exception {
\r
37 new CollationAPITest().run(args);
\r
38 //new CollationAPITest().TestGetTailoredSet();
\r
42 * This tests the collation key related APIs.
\r
43 * - constructor/destructor
\r
44 * - Collator.getCollationKey
\r
45 * - == and != operators
\r
46 * - comparison between collation keys
\r
47 * - creating collation key with a byte array and vice versa
\r
49 public void TestCollationKey() {
\r
50 logln("testing CollationKey begins...");
\r
51 Collator col = Collator.getInstance();
\r
52 col.setStrength(Collator.TERTIARY);
\r
54 String test1 = "Abcda";
\r
55 String test2 = "abcda";
\r
57 logln("Testing weird arguments");
\r
58 CollationKey sortk1 = col.getCollationKey("");
\r
59 // key gets reset here
\r
60 byte[] bytes = sortk1.toByteArray();
\r
61 doAssert(bytes.length == 3 && bytes[0] == 1 && bytes[1] == 1
\r
63 "Empty string should return an empty collation key");
\r
64 // bogus key returned here
\r
65 sortk1 = col.getCollationKey(null);
\r
66 doAssert(sortk1 == null, "Error code should return bogus collation key");
\r
68 logln("Use tertiary comparison level testing ....");
\r
69 sortk1 = col.getCollationKey(test1);
\r
70 CollationKey sortk2 = col.getCollationKey(test2);
\r
71 doAssert((sortk1.compareTo(sortk2)) > 0, "Result should be \"Abcda\" >>> \"abcda\"");
\r
73 CollationKey sortkNew;
\r
75 doAssert(!(sortk1.equals(sortk2)), "The sort keys should be different");
\r
76 doAssert((sortk1.hashCode() != sortk2.hashCode()), "sort key hashCode() failed");
\r
77 doAssert((sortk1.equals(sortkNew)), "The sort keys assignment failed");
\r
78 doAssert((sortk1.hashCode() == sortkNew.hashCode()), "sort key hashCode() failed");
\r
80 // port from apicoll
\r
82 col = Collator.getInstance();
\r
83 } catch (Exception e) {
\r
84 errln("Collator.getInstance() failed");
\r
86 if (col.getStrength() != Collator.TERTIARY){
\r
87 errln("Default collation did not have tertiary strength");
\r
90 // Need to use identical strength
\r
91 col.setStrength(Collator.IDENTICAL);
\r
93 CollationKey key1 = col.getCollationKey(test1);
\r
94 CollationKey key2 = col.getCollationKey(test2);
\r
95 CollationKey key3 = col.getCollationKey(test2);
\r
97 doAssert(key1.compareTo(key2) > 0,
\r
98 "Result should be \"Abcda\" > \"abcda\"");
\r
99 doAssert(key2.compareTo(key1) < 0,
\r
100 "Result should be \"abcda\" < \"Abcda\"");
\r
101 doAssert(key2.compareTo(key3) == 0,
\r
102 "Result should be \"abcda\" == \"abcda\"");
\r
104 byte key2identical[] = key2.toByteArray();
\r
106 logln("Use secondary comparision level testing ...");
\r
107 col.setStrength(Collator.SECONDARY);
\r
109 key1 = col.getCollationKey(test1);
\r
110 key2 = col.getCollationKey(test2);
\r
111 key3 = col.getCollationKey(test2);
\r
113 doAssert(key1.compareTo(key2) == 0,
\r
114 "Result should be \"Abcda\" == \"abcda\"");
\r
115 doAssert(key2.compareTo(key3) == 0,
\r
116 "Result should be \"abcda\" == \"abcda\"");
\r
118 byte tempkey[] = key2.toByteArray();
\r
119 byte subkey2compat[] = new byte[tempkey.length];
\r
120 System.arraycopy(key2identical, 0, subkey2compat, 0, tempkey.length);
\r
121 subkey2compat[subkey2compat.length - 1] = 0;
\r
122 doAssert(Arrays.equals(tempkey, subkey2compat),
\r
123 "Binary format for 'abcda' sortkey different for secondary strength!");
\r
125 logln("testing sortkey ends...");
\r
128 public void TestRawCollationKey()
\r
130 // testing constructors
\r
131 RawCollationKey key = new RawCollationKey();
\r
132 if (key.bytes != null || key.size != 0) {
\r
133 errln("Empty default constructor expected to leave the bytes null "
\r
136 byte array[] = new byte[128];
\r
137 key = new RawCollationKey(array);
\r
138 if (key.bytes != array || key.size != 0) {
\r
139 errln("Constructor taking an array expected to adopt it and "
\r
140 + "retaining its size 0");
\r
143 key = new RawCollationKey(array, 129);
\r
144 errln("Constructor taking an array and a size > array.length "
\r
145 + "expected to throw an exception");
\r
146 } catch (IndexOutOfBoundsException e) {
\r
147 logln("PASS: Constructor failed as expected");
\r
150 key = new RawCollationKey(array, -1);
\r
151 errln("Constructor taking an array and a size < 0 "
\r
152 + "expected to throw an exception");
\r
153 } catch (IndexOutOfBoundsException e) {
\r
154 logln("PASS: Constructor failed as expected");
\r
156 key = new RawCollationKey(array, array.length >> 1);
\r
157 if (key.bytes != array || key.size != (array.length >> 1)) {
\r
158 errln("Constructor taking an array and a size, "
\r
159 + "expected to adopt it and take the size specified");
\r
161 key = new RawCollationKey(10);
\r
162 if (key.bytes == null || key.bytes.length != 10 || key.size != 0) {
\r
163 errln("Constructor taking a specified capacity expected to "
\r
164 + "create a new internal byte array with length 10 and "
\r
165 + "retain size 0");
\r
169 void doAssert(boolean conditions, String message) {
\r
176 * This tests the comparison convenience methods of a collator object.
\r
178 * - greater than or equal to
\r
181 public void TestCompare() {
\r
182 logln("The compare tests begin : ");
\r
183 Collator col = Collator.getInstance(Locale.ENGLISH);
\r
185 String test1 = "Abcda";
\r
186 String test2 = "abcda";
\r
187 logln("Use tertiary comparison level testing ....");
\r
189 doAssert((!col.equals(test1, test2) ), "Result should be \"Abcda\" != \"abcda\"");
\r
190 doAssert((col.compare(test1, test2) > 0 ), "Result should be \"Abcda\" >>> \"abcda\"");
\r
192 col.setStrength(Collator.SECONDARY);
\r
193 logln("Use secondary comparison level testing ....");
\r
195 doAssert((col.equals(test1, test2) ), "Result should be \"Abcda\" == \"abcda\"");
\r
196 doAssert((col.compare(test1, test2) == 0), "Result should be \"Abcda\" == \"abcda\"");
\r
198 col.setStrength(Collator.PRIMARY);
\r
199 logln("Use primary comparison level testing ....");
\r
201 doAssert((col.equals(test1, test2) ), "Result should be \"Abcda\" == \"abcda\"");
\r
202 doAssert((col.compare(test1, test2) == 0 ), "Result should be \"Abcda\" == \"abcda\"");
\r
203 logln("The compare tests end.");
\r
207 * Tests decomposition setting
\r
209 public void TestDecomposition() {
\r
210 Collator en_US = null, el_GR = null, vi_VN = null;
\r
212 en_US = Collator.getInstance(new Locale("en", "US"));
\r
213 el_GR = Collator.getInstance(new Locale("el", "GR"));
\r
214 vi_VN = Collator.getInstance(new Locale("vi", "VN"));
\r
217 // there is no reason to have canonical decomposition in en_US OR default locale */
\r
218 if (vi_VN.getDecomposition() != Collator.CANONICAL_DECOMPOSITION)
\r
220 errln("vi_VN collation did not have cannonical decomposition for normalization!");
\r
223 if (el_GR.getDecomposition() != Collator.CANONICAL_DECOMPOSITION)
\r
225 errln("el_GR collation did not have cannonical decomposition for normalization!");
\r
228 if (en_US.getDecomposition() != Collator.NO_DECOMPOSITION)
\r
230 errln("en_US collation had cannonical decomposition for normalization!");
\r
235 * This tests the duplication of a collator object.
\r
237 public void TestDuplicate() {
\r
238 //Clone does not be implemented
\r
239 Collator col1 = Collator.getInstance(Locale.ENGLISH);
\r
241 // Collator col2 = (Collator)col1.clone();
\r
242 // doAssert(col1.equals(col2), "Cloned object is not equal to the orginal");
\r
243 String ruleset = "< a, A < b, B < c, C < d, D, e, E";
\r
244 RuleBasedCollator col3 = null;
\r
246 col3 = new RuleBasedCollator(ruleset);
\r
247 } catch (Exception e) {
\r
248 errln("Failure creating RuleBasedCollator with rule:" + ruleset);
\r
251 doAssert(!col1.equals(col3), "Cloned object is equal to some dummy");
\r
252 col3 = (RuleBasedCollator)col1;
\r
253 doAssert(col1.equals(col3), "Copied object is not equal to the orginal");
\r
258 * This tests the CollationElementIterator related APIs.
\r
259 * - creation of a CollationElementIterator object
\r
260 * - == and != operators
\r
261 * - iterating forward
\r
262 * - reseting the iterator index
\r
263 * - requesting the order properties(primary, secondary or tertiary)
\r
265 public void TestElemIter() {
\r
266 // logln("testing sortkey begins...");
\r
267 Collator col = Collator.getInstance(Locale.ENGLISH);
\r
270 String testString1 = "XFILE What subset of all possible test cases has the highest probability of detecting the most errors?";
\r
271 String testString2 = "Xf_ile What subset of all possible test cases has the lowest probability of detecting the least errors?";
\r
272 // logln("Constructors and comparison testing....");
\r
273 CollationElementIterator iterator1 = ((RuleBasedCollator)col).getCollationElementIterator(testString1);
\r
275 CharacterIterator chariter=new StringCharacterIterator(testString1);
\r
277 CollationElementIterator iterator2 = ((RuleBasedCollator)col).getCollationElementIterator(chariter);
\r
278 UCharacterIterator uchariter=UCharacterIterator.getInstance(testString2);
\r
279 CollationElementIterator iterator3 = ((RuleBasedCollator)col).getCollationElementIterator(uchariter);
\r
282 offset = iterator1.getOffset();
\r
284 errln("Error in getOffset for collation element iterator");
\r
287 iterator1.setOffset(6);
\r
288 iterator1.setOffset(0);
\r
289 int order1, order2, order3;
\r
291 order1 = iterator1.next();
\r
292 doAssert(!(iterator1.equals(iterator2)), "The first iterator advance failed");
\r
293 order2 = iterator2.next();
\r
295 doAssert((iterator1.equals(iterator2)), "The second iterator advance failed");
\r
296 doAssert((order1 == order2), "The order result should be the same");
\r
297 order3 = iterator3.next();
\r
299 doAssert((CollationElementIterator.primaryOrder(order1) ==
\r
300 CollationElementIterator.primaryOrder(order3)), "The primary orders should be the same");
\r
301 doAssert((CollationElementIterator.secondaryOrder(order1) ==
\r
302 CollationElementIterator.secondaryOrder(order3)), "The secondary orders should be the same");
\r
303 doAssert((CollationElementIterator.tertiaryOrder(order1) ==
\r
304 CollationElementIterator.tertiaryOrder(order3)), "The tertiary orders should be the same");
\r
306 order1 = iterator1.next();
\r
307 order3 = iterator3.next();
\r
309 doAssert((CollationElementIterator.primaryOrder(order1) ==
\r
310 CollationElementIterator.primaryOrder(order3)), "The primary orders should be identical");
\r
311 doAssert((CollationElementIterator.tertiaryOrder(order1) !=
\r
312 CollationElementIterator.tertiaryOrder(order3)), "The tertiary orders should be different");
\r
314 order1 = iterator1.next();
\r
315 order3 = iterator3.next();
\r
316 // invalid test wrong in UCA
\r
317 // doAssert((CollationElementIterator.secondaryOrder(order1) !=
\r
318 // CollationElementIterator.secondaryOrder(order3)), "The secondary orders should not be the same");
\r
320 doAssert((order1 != CollationElementIterator.NULLORDER), "Unexpected end of iterator reached");
\r
322 iterator1.reset();
\r
323 iterator2.reset();
\r
325 order1 = iterator1.next();
\r
327 doAssert(!(iterator1.equals(iterator2)), "The first iterator advance failed");
\r
329 order2 = iterator2.next();
\r
331 doAssert((iterator1.equals(iterator2)), "The second iterator advance failed");
\r
332 doAssert((order1 == order2), "The order result should be the same");
\r
334 order3 = iterator3.next();
\r
336 doAssert((CollationElementIterator.primaryOrder(order1) ==
\r
337 CollationElementIterator.primaryOrder(order3)), "The primary orders should be the same");
\r
338 doAssert((CollationElementIterator.secondaryOrder(order1) ==
\r
339 CollationElementIterator.secondaryOrder(order3)), "The secondary orders should be the same");
\r
340 doAssert((CollationElementIterator.tertiaryOrder(order1) ==
\r
341 CollationElementIterator.tertiaryOrder(order3)), "The tertiary orders should be the same");
\r
343 order1 = iterator1.next();
\r
344 order2 = iterator2.next();
\r
345 order3 = iterator3.next();
\r
347 doAssert((CollationElementIterator.primaryOrder(order1) ==
\r
348 CollationElementIterator.primaryOrder(order3)), "The primary orders should be identical");
\r
349 doAssert((CollationElementIterator.tertiaryOrder(order1) !=
\r
350 CollationElementIterator.tertiaryOrder(order3)), "The tertiary orders should be different");
\r
352 order1 = iterator1.next();
\r
353 order3 = iterator3.next();
\r
355 // obsolete invalid test, removed
\r
356 // doAssert((CollationElementIterator.secondaryOrder(order1) !=
\r
357 // CollationElementIterator.secondaryOrder(order3)), "The secondary orders should not be the same");
\r
358 doAssert((order1 != CollationElementIterator.NULLORDER), "Unexpected end of iterator reached");
\r
359 doAssert(!(iterator2.equals(iterator3)), "The iterators should be different");
\r
360 logln("testing CollationElementIterator ends...");
\r
364 * This tests the hashCode method of a collator object.
\r
366 public void TestHashCode() {
\r
367 logln("hashCode tests begin.");
\r
368 Collator col1 = Collator.getInstance(Locale.ENGLISH);
\r
370 Collator col2 = null;
\r
371 Locale dk = new Locale("da", "DK", "");
\r
373 col2 = Collator.getInstance(dk);
\r
374 } catch (Exception e) {
\r
375 errln("Danish collation creation failed.");
\r
379 Collator col3 = null;
\r
381 col3 = Collator.getInstance(Locale.ENGLISH);
\r
382 } catch (Exception e) {
\r
383 errln("2nd default collation creation failed.");
\r
387 logln("Collator.hashCode() testing ...");
\r
389 doAssert(col1.hashCode() != col2.hashCode(), "Hash test1 result incorrect" );
\r
390 doAssert(!(col1.hashCode() == col2.hashCode()), "Hash test2 result incorrect" );
\r
391 doAssert(col1.hashCode() == col3.hashCode(), "Hash result not equal" );
\r
393 logln("hashCode tests end.");
\r
395 String test1 = "Abcda";
\r
396 String test2 = "abcda";
\r
398 CollationKey sortk1, sortk2, sortk3;
\r
400 sortk1 = col3.getCollationKey(test1);
\r
401 sortk2 = col3.getCollationKey(test2);
\r
402 sortk3 = col3.getCollationKey(test2);
\r
404 doAssert(sortk1.hashCode() != sortk2.hashCode(), "Hash test1 result incorrect");
\r
405 doAssert(sortk2.hashCode() == sortk3.hashCode(), "Hash result not equal" );
\r
409 * This tests the properties of a collator object.
\r
411 * - factory method getInstance
\r
412 * - compare and getCollationKey
\r
413 * - get/set decomposition mode and comparison level
\r
415 public void TestProperty() {
\r
417 All the collations have the same version in an ICU
\r
419 ICU 2.0 currVersionArray = {0x18, 0xC0, 0x02, 0x02};
\r
420 ICU 2.1 currVersionArray = {0x19, 0x00, 0x03, 0x03};
\r
421 ICU 2.8 currVersionArray = {0x29, 0x80, 0x00, 0x04};
\r
423 logln("The property tests begin : ");
\r
424 logln("Test ctors : ");
\r
425 Collator col = Collator.getInstance(Locale.ENGLISH);
\r
428 logln("Test getVersion");
\r
429 VersionInfo expectedVersion = VersionInfo.getInstance(0x31, 0xC0, 0x00, 0x05);
\r
430 doAssert(col.getVersion().equals(expectedVersion), "Expected version "+expectedVersion.toString()+" got "+col.getVersion().toString());
\r
432 logln("Test getUCAVersion");
\r
433 VersionInfo expectedUCAVersion = VersionInfo.getInstance(5, 2, 0, 0);
\r
434 doAssert(col.getUCAVersion().equals(expectedUCAVersion), "Expected UCA version "+expectedUCAVersion.toString()+" got "+col.getUCAVersion().toString());
\r
436 doAssert((col.compare("ab", "abc") < 0), "ab < abc comparison failed");
\r
437 doAssert((col.compare("ab", "AB") < 0), "ab < AB comparison failed");
\r
438 doAssert((col.compare("blackbird", "black-bird") > 0), "black-bird > blackbird comparison failed");
\r
439 doAssert((col.compare("black bird", "black-bird") < 0), "black bird > black-bird comparison failed");
\r
440 doAssert((col.compare("Hello", "hello") > 0), "Hello > hello comparison failed");
\r
442 logln("Test ctors ends.");
\r
444 logln("testing Collator.getStrength() method ...");
\r
445 doAssert((col.getStrength() == Collator.TERTIARY), "collation object has the wrong strength");
\r
446 doAssert((col.getStrength() != Collator.PRIMARY), "collation object's strength is primary difference");
\r
448 logln("testing Collator.setStrength() method ...");
\r
449 col.setStrength(Collator.SECONDARY);
\r
450 doAssert((col.getStrength() != Collator.TERTIARY), "collation object's strength is secondary difference");
\r
451 doAssert((col.getStrength() != Collator.PRIMARY), "collation object's strength is primary difference");
\r
452 doAssert((col.getStrength() == Collator.SECONDARY), "collation object has the wrong strength");
\r
454 logln("testing Collator.setDecomposition() method ...");
\r
455 col.setDecomposition(Collator.NO_DECOMPOSITION);
\r
456 doAssert((col.getDecomposition() != Collator.CANONICAL_DECOMPOSITION), "Decomposition mode != Collator.CANONICAL_DECOMPOSITION");
\r
457 doAssert((col.getDecomposition() == Collator.NO_DECOMPOSITION), "Decomposition mode = Collator.NO_DECOMPOSITION");
\r
460 RuleBasedCollator rcol = (RuleBasedCollator)Collator.getInstance(new Locale("da", "DK"));
\r
461 doAssert(rcol.getRules().length() != 0, "da_DK rules does not have length 0");
\r
464 col = Collator.getInstance(Locale.FRENCH);
\r
465 } catch (Exception e) {
\r
466 errln("Creating French collation failed.");
\r
470 col.setStrength(Collator.PRIMARY);
\r
471 logln("testing Collator.getStrength() method again ...");
\r
472 doAssert((col.getStrength() != Collator.TERTIARY), "collation object has the wrong strength");
\r
473 doAssert((col.getStrength() == Collator.PRIMARY), "collation object's strength is not primary difference");
\r
475 logln("testing French Collator.setStrength() method ...");
\r
476 col.setStrength(Collator.TERTIARY);
\r
477 doAssert((col.getStrength() == Collator.TERTIARY), "collation object's strength is not tertiary difference");
\r
478 doAssert((col.getStrength() != Collator.PRIMARY), "collation object's strength is primary difference");
\r
479 doAssert((col.getStrength() != Collator.SECONDARY), "collation object's strength is secondary difference");
\r
482 public void TestJunkCollator(){
\r
483 logln("Create junk collation: ");
\r
484 Locale abcd = new Locale("ab", "CD", "");
\r
486 Collator junk = Collator.getInstance(abcd);
\r
487 Collator col = Collator.getInstance();
\r
490 String colrules = ((RuleBasedCollator)col).getRules();
\r
491 String junkrules = ((RuleBasedCollator)junk).getRules();
\r
492 doAssert(colrules == junkrules || colrules.equals(junkrules),
\r
493 "The default collation should be returned.");
\r
494 Collator frCol = null;
\r
496 frCol = Collator.getInstance(Locale.FRANCE);
\r
497 } catch (Exception e) {
\r
498 errln("Creating French collator failed.");
\r
502 doAssert(!(frCol.equals(junk)), "The junk is the same as the French collator.");
\r
503 logln("Collator property test ended.");
\r
507 * This tests the RuleBasedCollator
\r
508 * - constructor/destructor
\r
511 public void TestRuleBasedColl() {
\r
512 RuleBasedCollator col1 = null, col2 = null, col3 = null, col4 = null;
\r
514 String ruleset1 = "&9 < a, A < b, B < c, C; ch, cH, Ch, CH < d, D, e, E";
\r
515 String ruleset2 = "&9 < a, A < b, B < c, C < d, D, e, E";
\r
516 String ruleset3 = "&";
\r
519 col1 = new RuleBasedCollator(ruleset1);
\r
520 } catch (Exception e) {
\r
521 // only first error needs to be a warning since we exit function
\r
522 warnln("RuleBased Collator creation failed.");
\r
527 col2 = new RuleBasedCollator(ruleset2);
\r
528 } catch (Exception e) {
\r
529 errln("RuleBased Collator creation failed.");
\r
534 // empty rules fail
\r
535 col3 = new RuleBasedCollator(ruleset3);
\r
536 errln("Failure: Empty rules for the collator should fail");
\r
538 } catch (MissingResourceException e) {
\r
539 warnln(e.getMessage());
\r
540 } catch (Exception e) {
\r
541 logln("PASS: Empty rules for the collator failed as expected");
\r
544 Locale locale = new Locale("aa", "AA");
\r
546 col3 = (RuleBasedCollator)Collator.getInstance(locale);
\r
547 } catch (Exception e) {
\r
548 errln("Fallback Collator creation failed.: %s");
\r
553 col3 = (RuleBasedCollator)Collator.getInstance();
\r
554 } catch (Exception e) {
\r
555 errln("Default Collator creation failed.: %s");
\r
559 String rule1 = col1.getRules();
\r
560 String rule2 = col2.getRules();
\r
561 String rule3 = col3.getRules();
\r
563 doAssert(!rule1.equals(rule2), "Default collator getRules failed");
\r
564 doAssert(!rule2.equals(rule3), "Default collator getRules failed");
\r
565 doAssert(!rule1.equals(rule3), "Default collator getRules failed");
\r
568 col4 = new RuleBasedCollator(rule2);
\r
569 } catch (Exception e) {
\r
570 errln("RuleBased Collator creation failed.");
\r
574 String rule4 = col4.getRules();
\r
575 doAssert(rule2.equals(rule4), "Default collator getRules failed");
\r
576 // tests that modifier ! is always ignored
\r
577 String exclamationrules = "!&a<b";
\r
578 // java does not allow ! to be the start of the rule
\r
579 String thaistr = "\u0e40\u0e01\u0e2d";
\r
581 RuleBasedCollator col5 = new RuleBasedCollator(exclamationrules);
\r
582 RuleBasedCollator encol = (RuleBasedCollator)
\r
583 Collator.getInstance(Locale.ENGLISH);
\r
584 CollationElementIterator col5iter
\r
585 = col5.getCollationElementIterator(thaistr);
\r
586 CollationElementIterator encoliter
\r
587 = encol.getCollationElementIterator(
\r
590 // testing with en since thai has its own tailoring
\r
591 int ce = col5iter.next();
\r
592 int ce2 = encoliter.next();
\r
594 errln("! modifier test failed");
\r
596 if (ce == CollationElementIterator.NULLORDER) {
\r
600 } catch (Exception e) {
\r
601 errln("RuleBased Collator creation failed for ! modifier.");
\r
607 * This tests the RuleBasedCollator
\r
610 public void TestRules() {
\r
611 RuleBasedCollator coll = (RuleBasedCollator)Collator.getInstance(new Locale("","","")); //root
\r
612 // logln("PASS: RuleBased Collator creation passed");
\r
615 String rules = coll.getRules();
\r
616 if (rules != null && rules.length() != 0) {
\r
617 errln("Root tailored rules failed");
\r
621 public void TestSafeClone() {
\r
622 String test1 = "abCda";
\r
623 String test2 = "abcda";
\r
625 // one default collator & two complex ones
\r
626 RuleBasedCollator someCollators[] = {
\r
627 (RuleBasedCollator)Collator.getInstance(Locale.ENGLISH),
\r
628 (RuleBasedCollator)Collator.getInstance(Locale.KOREA),
\r
629 (RuleBasedCollator)Collator.getInstance(Locale.JAPAN)
\r
631 RuleBasedCollator someClonedCollators[] = new RuleBasedCollator[3];
\r
633 // change orig & clone & make sure they are independent
\r
635 for (int index = 0; index < someCollators.length; index ++)
\r
638 someClonedCollators[index]
\r
639 = (RuleBasedCollator)someCollators[index].clone();
\r
640 } catch (CloneNotSupportedException e) {
\r
641 errln("Error cloning collator");
\r
644 someClonedCollators[index].setStrength(Collator.TERTIARY);
\r
645 someCollators[index].setStrength(Collator.PRIMARY);
\r
646 someClonedCollators[index].setCaseLevel(false);
\r
647 someCollators[index].setCaseLevel(false);
\r
649 doAssert(someClonedCollators[index].compare(test1, test2) > 0,
\r
650 "Result should be \"abCda\" >>> \"abcda\" ");
\r
651 doAssert(someCollators[index].compare(test1, test2) == 0,
\r
652 "Result should be \"abCda\" == \"abcda\" ");
\r
656 public void TestGetTailoredSet()
\r
658 logln("testing getTailoredSet...");
\r
661 "& S < \u0161 <<< \u0160",
\r
663 String data[][] = {
\r
664 { "\u212b", "A\u030a", "\u00c5" },
\r
665 { "\u0161", "s\u030C", "\u0160", "S\u030C" }
\r
670 RuleBasedCollator coll;
\r
673 for(i = 0; i < rules.length; i++) {
\r
675 logln("Instantiating a collator from "+rules[i]);
\r
676 coll = new RuleBasedCollator(rules[i]);
\r
677 set = coll.getTailoredSet();
\r
678 logln("Got set: "+set.toPattern(true));
\r
679 if(set.size() != data[i].length) {
\r
680 errln("Tailored set size different ("+set.size()+") than expected ("+data[i].length+")");
\r
682 for(j = 0; j < data[i].length; j++) {
\r
683 logln("Checking to see whether "+data[i][j]+" is in set");
\r
684 if(!set.contains(data[i][j])) {
\r
685 errln("Tailored set doesn't contain "+data[i][j]+"... It should");
\r
688 } catch (Exception e) {
\r
689 warnln("Couldn't open collator with rules "+ rules[i]);
\r
695 * Simple test to see if Collator is subclassable
\r
697 public void TestSubClass()
\r
699 class TestCollator extends Collator
\r
701 public boolean equals(Object that) {
\r
702 return this == that;
\r
705 public int hashCode() {
\r
709 public int compare(String source, String target) {
\r
710 return source.compareTo(target);
\r
713 public CollationKey getCollationKey(String source)
\r
714 { return new CollationKey(source,
\r
715 getRawCollationKey(source, new RawCollationKey()));
\r
718 public RawCollationKey getRawCollationKey(String source,
\r
719 RawCollationKey key)
\r
721 byte temp1[] = source.getBytes();
\r
722 byte temp2[] = new byte[temp1.length + 1];
\r
723 System.arraycopy(temp1, 0, temp2, 0, temp1.length);
\r
724 temp2[temp1.length] = 0;
\r
726 key = new RawCollationKey();
\r
728 key.bytes = temp2;
\r
729 key.size = temp2.length;
\r
733 public void setVariableTop(int ce)
\r
737 public int setVariableTop(String str)
\r
742 public int getVariableTop()
\r
746 public VersionInfo getVersion()
\r
748 return VersionInfo.getInstance(0);
\r
750 public VersionInfo getUCAVersion()
\r
752 return VersionInfo.getInstance(0);
\r
756 Collator col1 = new TestCollator();
\r
757 Collator col2 = new TestCollator();
\r
758 if (col1.equals(col2)) {
\r
759 errln("2 different instance of TestCollator should fail");
\r
761 if (col1.hashCode() != col2.hashCode()) {
\r
762 errln("Every TestCollator has the same hashcode");
\r
764 String abc = "abc";
\r
765 String bcd = "bcd";
\r
766 if (col1.compare(abc, bcd) != abc.compareTo(bcd)) {
\r
767 errln("TestCollator compare should be the same as the default " +
\r
768 "string comparison");
\r
770 CollationKey key = col1.getCollationKey(abc);
\r
771 byte temp1[] = abc.getBytes();
\r
772 byte temp2[] = new byte[temp1.length + 1];
\r
773 System.arraycopy(temp1, 0, temp2, 0, temp1.length);
\r
774 temp2[temp1.length] = 0;
\r
775 if (!java.util.Arrays.equals(key.toByteArray(), temp2)
\r
776 || !key.getSourceString().equals(abc)) {
\r
777 errln("TestCollator collationkey API is returning wrong values");
\r
779 UnicodeSet set = col1.getTailoredSet();
\r
780 if (!set.equals(new UnicodeSet(0, 0x10FFFF))) {
\r
781 errln("Error getting default tailored set");
\r
786 * Simple test the collator setter and getters
\r
788 public void TestSetGet()
\r
790 RuleBasedCollator collator = (RuleBasedCollator)Collator.getInstance();
\r
791 int decomp = collator.getDecomposition();
\r
792 int strength = collator.getStrength();
\r
793 boolean alt = collator.isAlternateHandlingShifted();
\r
794 boolean caselevel = collator.isCaseLevel();
\r
795 boolean french = collator.isFrenchCollation();
\r
796 boolean hquart = collator.isHiraganaQuaternary();
\r
797 boolean lowercase = collator.isLowerCaseFirst();
\r
798 boolean uppercase = collator.isUpperCaseFirst();
\r
800 collator.setDecomposition(Collator.CANONICAL_DECOMPOSITION);
\r
801 if (collator.getDecomposition() != Collator.CANONICAL_DECOMPOSITION) {
\r
802 errln("Setting decomposition failed");
\r
804 collator.setStrength(Collator.QUATERNARY);
\r
805 if (collator.getStrength() != Collator.QUATERNARY) {
\r
806 errln("Setting strength failed");
\r
808 collator.setAlternateHandlingShifted(!alt);
\r
809 if (collator.isAlternateHandlingShifted() == alt) {
\r
810 errln("Setting alternate handling failed");
\r
812 collator.setCaseLevel(!caselevel);
\r
813 if (collator.isCaseLevel() == caselevel) {
\r
814 errln("Setting case level failed");
\r
816 collator.setFrenchCollation(!french);
\r
817 if (collator.isFrenchCollation() == french) {
\r
818 errln("Setting french collation failed");
\r
820 collator.setHiraganaQuaternary(!hquart);
\r
821 if (collator.isHiraganaQuaternary() == hquart) {
\r
822 errln("Setting hiragana quartenary failed");
\r
824 collator.setLowerCaseFirst(!lowercase);
\r
825 if (collator.isLowerCaseFirst() == lowercase) {
\r
826 errln("Setting lower case first failed");
\r
828 collator.setUpperCaseFirst(!uppercase);
\r
829 if (collator.isUpperCaseFirst() == uppercase) {
\r
830 errln("Setting upper case first failed");
\r
832 collator.setDecompositionDefault();
\r
833 if (collator.getDecomposition() != decomp) {
\r
834 errln("Setting decomposition default failed");
\r
836 collator.setStrengthDefault();
\r
837 if (collator.getStrength() != strength) {
\r
838 errln("Setting strength default failed");
\r
840 collator.setAlternateHandlingDefault();
\r
841 if (collator.isAlternateHandlingShifted() != alt) {
\r
842 errln("Setting alternate handling default failed");
\r
844 collator.setCaseLevelDefault();
\r
845 if (collator.isCaseLevel() != caselevel) {
\r
846 errln("Setting case level default failed");
\r
848 collator.setFrenchCollationDefault();
\r
849 if (collator.isFrenchCollation() != french) {
\r
850 errln("Setting french handling default failed");
\r
852 collator.setHiraganaQuaternaryDefault();
\r
853 if (collator.isHiraganaQuaternary() != hquart) {
\r
854 errln("Setting Hiragana Quartenary default failed");
\r
856 collator.setCaseFirstDefault();
\r
857 if (collator.isLowerCaseFirst() != lowercase
\r
858 || collator.isUpperCaseFirst() != uppercase) {
\r
859 errln("Setting case first handling default failed");
\r
863 public void TestBounds()
\r
865 Collator coll = Collator.getInstance(new Locale("sh", ""));
\r
867 String test[] = { "John Smith", "JOHN SMITH",
\r
868 "john SMITH", "j\u00F6hn sm\u00EFth",
\r
869 "J\u00F6hn Sm\u00EFth", "J\u00D6HN SM\u00CFTH",
\r
870 "john smithsonian", "John Smithsonian",
\r
873 String testStr[] = {
\r
874 "\u010CAKI MIHALJ",
\r
875 "\u010CAKI MIHALJ",
\r
876 "\u010CAKI PIRO\u0160KA",
\r
877 "\u010CABAI ANDRIJA",
\r
878 "\u010CABAI LAJO\u0160",
\r
879 "\u010CABAI MARIJA",
\r
880 "\u010CABAI STEVAN",
\r
881 "\u010CABAI STEVAN",
\r
882 "\u010CABARKAPA BRANKO",
\r
883 "\u010CABARKAPA MILENKO",
\r
884 "\u010CABARKAPA MIROSLAV",
\r
885 "\u010CABARKAPA SIMO",
\r
886 "\u010CABARKAPA STANKO",
\r
887 "\u010CABARKAPA TAMARA",
\r
888 "\u010CABARKAPA TOMA\u0160",
\r
889 "\u010CABDARI\u0106 NIKOLA",
\r
890 "\u010CABDARI\u0106 ZORICA",
\r
891 "\u010CABI NANDOR",
\r
892 "\u010CABOVI\u0106 MILAN",
\r
893 "\u010CABRADI AGNEZIJA",
\r
894 "\u010CABRADI IVAN",
\r
895 "\u010CABRADI JELENA",
\r
896 "\u010CABRADI LJUBICA",
\r
897 "\u010CABRADI STEVAN",
\r
898 "\u010CABRDA MARTIN",
\r
899 "\u010CABRILO BOGDAN",
\r
900 "\u010CABRILO BRANISLAV",
\r
901 "\u010CABRILO LAZAR",
\r
902 "\u010CABRILO LJUBICA",
\r
903 "\u010CABRILO SPASOJA",
\r
904 "\u010CADE\u0160 ZDENKA",
\r
905 "\u010CADESKI BLAGOJE",
\r
906 "\u010CADOVSKI VLADIMIR",
\r
907 "\u010CAGLJEVI\u0106 TOMA",
\r
908 "\u010CAGOROVI\u0106 VLADIMIR",
\r
910 "\u010CAJI\u0106 BOGOLJUB",
\r
911 "\u010CAJI\u0106 BORISLAV",
\r
912 "\u010CAJI\u0106 RADOSLAV",
\r
913 "\u010CAK\u0160IRAN MILADIN",
\r
914 "\u010CAKAN EUGEN",
\r
915 "\u010CAKAN EVGENIJE",
\r
917 "\u010CAKAN JULIJAN",
\r
918 "\u010CAKAN MIHAJLO",
\r
919 "\u010CAKAN STEVAN",
\r
920 "\u010CAKAN VLADIMIR",
\r
921 "\u010CAKAN VLADIMIR",
\r
922 "\u010CAKAN VLADIMIR",
\r
924 "\u010CAKAREVI\u0106 MOMIR",
\r
925 "\u010CAKAREVI\u0106 NEDELJKO",
\r
926 "\u010CAKI \u0160ANDOR",
\r
927 "\u010CAKI AMALIJA",
\r
928 "\u010CAKI ANDRA\u0160",
\r
929 "\u010CAKI LADISLAV",
\r
930 "\u010CAKI LAJO\u0160",
\r
931 "\u010CAKI LASLO" };
\r
933 CollationKey testKey[] = new CollationKey[testStr.length];
\r
934 for (int i = 0; i < testStr.length; i ++) {
\r
935 testKey[i] = coll.getCollationKey(testStr[i]);
\r
938 Arrays.sort(testKey);
\r
939 for(int i = 0; i < testKey.length - 1; i ++) {
\r
940 CollationKey lower
\r
941 = testKey[i].getBound(CollationKey.BoundMode.LOWER,
\r
942 Collator.SECONDARY);
\r
943 for (int j = i + 1; j < testKey.length; j ++) {
\r
944 CollationKey upper
\r
945 = testKey[j].getBound(CollationKey.BoundMode.UPPER,
\r
946 Collator.SECONDARY);
\r
947 for (int k = i; k <= j; k ++) {
\r
948 if (lower.compareTo(testKey[k]) > 0) {
\r
949 errln("Problem with lower bound at i = " + i + " j = "
\r
950 + j + " k = " + k);
\r
952 if (upper.compareTo(testKey[k]) <= 0) {
\r
953 errln("Problem with upper bound at i = " + i + " j = "
\r
954 + j + " k = " + k);
\r
960 for (int i = 0; i < test.length; i ++)
\r
962 CollationKey key = coll.getCollationKey(test[i]);
\r
963 CollationKey lower = key.getBound(CollationKey.BoundMode.LOWER,
\r
964 Collator.SECONDARY);
\r
965 CollationKey upper = key.getBound(CollationKey.BoundMode.UPPER_LONG,
\r
966 Collator.SECONDARY);
\r
967 for (int j = i + 1; j < test.length; j ++) {
\r
968 key = coll.getCollationKey(test[j]);
\r
969 if (lower.compareTo(key) > 0) {
\r
970 errln("Problem with lower bound i = " + i + " j = " + j);
\r
972 if (upper.compareTo(key) <= 0) {
\r
973 errln("Problem with upper bound i = " + i + " j = " + j);
\r
979 public final void TestGetAll() {
\r
980 Locale[] list = Collator.getAvailableLocales();
\r
981 int errorCount = 0;
\r
982 for (int i = 0; i < list.length; ++i) {
\r
983 log("Locale name: ");
\r
984 log(list[i].toString());
\r
985 log(" , the display name is : ");
\r
986 logln(list[i].getDisplayName());
\r
988 logln(" ...... Or display as: " + Collator.getDisplayName(list[i]));
\r
989 logln(" ...... and display in Chinese: " +
\r
990 Collator.getDisplayName(list[i],Locale.CHINA));
\r
991 }catch(MissingResourceException ex){
\r
993 logln("could not get displayName for " + list[i]);
\r
997 warnln("Could not load the locale data.");
\r
1002 doSetsTest(UnicodeSet ref, UnicodeSet set, String inSet, String outSet) {
\r
1005 set.applyPattern(inSet);
\r
1007 if(!ref.containsAll(set)) {
\r
1008 err("Some stuff from "+inSet+" is not present in the set\n");
\r
1012 set.applyPattern(outSet);
\r
1013 if(!ref.containsNone(set)) {
\r
1014 err("Some stuff from "+outSet+" is present in the set\n");
\r
1018 public void TestGetContractions()throws Exception {
\r
1019 /* static struct {
\r
1020 const char* locale;
\r
1021 const char* inConts;
\r
1022 const char* outConts;
\r
1023 const char* inExp;
\r
1024 const char* outExp;
\r
1025 const char* unsafeCodeUnits;
\r
1026 const char* safeCodeUnits;
\r
1029 String tests[][] = {
\r
1031 "[{\u0474\u030F}{\u0475\u030F}{\u04D8\u0308}{\u04D9\u0308}{\u04E8\u0308}{\u04E9\u0308}]",
\r
1032 "[{\u0430\u0306}{\u0410\u0306}{\u0430\u0308}{\u0410\u0306}{\u0433\u0301}{\u0413\u0301}]",
\r
1035 "[\u0474\u0475\u04d8\u04d9\u04e8\u04e9]",
\r
1036 "[aAbB\u0430\u0410\u0433\u0413]"
\r
1039 "[{\u0474\u030F}{\u0475\u030F}{\u04D8\u0308}{\u04D9\u0308}{\u04E8\u0308}{\u04E9\u0308}"+
\r
1040 "{\u0430\u0306}{\u0410\u0306}{\u0430\u0308}{\u0410\u0306}{\u0433\u0301}{\u0413\u0301}]",
\r
1044 "[\u0474\u0475\u04D8\u04D9\u04E8\u04E9\u0430\u0410\u0433\u0413]",
\r
1048 "[{C\u0301}{C\u030C}{C\u0341}{DZ\u030C}{Dz\u030C}{D\u017D}{D\u017E}{lj}{nj}]",
\r
1049 "[{\u309d\u3099}{\u30fd\u3099}]",
\r
1056 "[{\u3053\u3099\u309D}{\u3053\u3099\u309D\u3099}{\u3053\u3099\u309E}{\u3053\u3099\u30FC}{\u3053\u309D}{\u3053\u309D\u3099}{\u3053\u309E}{\u3053\u30FC}{\u30B3\u3099\u30FC}{\u30B3\u3099\u30FD}{\u30B3\u3099\u30FD\u3099}{\u30B3\u3099\u30FE}{\u30B3\u30FC}{\u30B3\u30FD}{\u30B3\u30FD\u3099}{\u30B3\u30FE}]",
\r
1057 "[{\u30FD\u3099}{\u309D\u3099}{\u3053\u3099}{\u30B3\u3099}{lj}{nj}]",
\r
1068 RuleBasedCollator coll = null;
\r
1070 UnicodeSet conts = new UnicodeSet();
\r
1071 UnicodeSet exp = new UnicodeSet();
\r
1072 UnicodeSet set = new UnicodeSet();
\r
1074 for(i = 0; i < tests.length; i++) {
\r
1075 logln("Testing locale: "+ tests[i][0]);
\r
1076 coll = (RuleBasedCollator)Collator.getInstance(new ULocale(tests[i][0]));
\r
1077 coll.getContractionsAndExpansions(conts, exp, true);
\r
1078 logln("Contractions "+conts.size()+":\n"+conts.toPattern(true));
\r
1079 doSetsTest(conts, set, tests[i][1], tests[i][2]);
\r
1080 logln("Expansions "+exp.size()+":\n"+exp.toPattern(true));
\r
1081 doSetsTest(exp, set, tests[i][3], tests[i][4]);
\r
1083 // No unsafe set in ICU4J
\r
1084 //noConts = ucol_getUnsafeSet(coll, conts, &status);
\r
1085 //doSetsTest(conts, set, tests[i][5], tests[i][6]);
\r
1086 //log_verbose("Unsafes "+conts.size()+":\n"+conts.toPattern(true)+"\n");
\r
1089 private static final String bigone = "One";
\r
1090 private static final String littleone = "one";
\r
1092 public void TestClone() {
\r
1093 logln("\ninit c0");
\r
1094 RuleBasedCollator c0 = (RuleBasedCollator)Collator.getInstance();
\r
1095 c0.setStrength(Collator.TERTIARY);
\r
1098 logln("\ninit c1");
\r
1099 RuleBasedCollator c1 = (RuleBasedCollator)Collator.getInstance();
\r
1100 c1.setStrength(Collator.TERTIARY);
\r
1101 c1.setUpperCaseFirst(!c1.isUpperCaseFirst());
\r
1105 logln("\ninit c2");
\r
1106 RuleBasedCollator c2 = (RuleBasedCollator)c1.clone();
\r
1107 c2.setUpperCaseFirst(!c2.isUpperCaseFirst());
\r
1111 if(c1.equals(c2)){
\r
1112 errln("The cloned objects refer to same data");
\r
1114 }catch(CloneNotSupportedException ex){
\r
1115 errln("Could not clone the collator");
\r
1119 private void dump(String msg, RuleBasedCollator c) {
\r
1120 logln(msg + " " + c.compare(bigone, littleone) +
\r
1121 " s: " + c.getStrength() +
\r
1122 " u: " + c.isUpperCaseFirst());
\r
1126 * Tests the method public void setStrength(int newStrength)
\r
1128 public void TestSetStrength() {
\r
1129 // Tests when if ((newStrength != PRIMARY) && ... ) is true
\r
1130 int[] cases = { -1, 4, 5 };
\r
1131 for (int i = 0; i < cases.length; i++) {
\r
1133 // Assuming -1 is not one of the values
\r
1134 Collator c = Collator.getInstance();
\r
1135 c.setStrength(cases[i]);
\r
1136 errln("Collator.setStrength(int) is suppose to return "
\r
1137 + "an exception for an invalid newStrength value of " + cases[i]);
\r
1138 } catch (Exception e) {
\r
1144 * Tests the method public void setDecomposition(int decomposition)
\r
1146 public void TestSetDecomposition() {
\r
1147 // Tests when if ((decomposition != NO_DECOMPOSITION) && ...) is true
\r
1148 int[] cases = { 0, 1, 14, 15, 18, 19 };
\r
1149 for (int i = 0; i < cases.length; i++) {
\r
1151 // Assuming -1 is not one of the values
\r
1152 Collator c = Collator.getInstance();
\r
1153 c.setDecomposition(cases[i]);
\r
1154 errln("Collator.setDecomposition(int) is suppose to return "
\r
1155 + "an exception for an invalid decomposition value of " + cases[i]);
\r
1156 } catch (Exception e) {
\r
1162 * Tests the class CollatorFactory
\r
1164 public void TestCreateCollator() {
\r
1165 // The following class override public Collator createCollator(Locale loc)
\r
1166 class TestCreateCollator extends CollatorFactory {
\r
1167 public Set<String> getSupportedLocaleIDs() {
\r
1168 return new HashSet<String>();
\r
1171 public TestCreateCollator() {
\r
1175 public Collator createCollator(ULocale c) {
\r
1179 // The following class override public Collator createCollator(ULocale loc)
\r
1180 class TestCreateCollator1 extends CollatorFactory {
\r
1181 public Set<String> getSupportedLocaleIDs() {
\r
1182 return new HashSet<String>();
\r
1185 public TestCreateCollator1() {
\r
1189 public Collator createCollator(Locale c) {
\r
1192 public boolean visible(){
\r
1198 * Tests the method public Collator createCollator(Locale loc) using TestCreateCollator1 class
\r
1201 TestCreateCollator tcc = new TestCreateCollator();
\r
1202 tcc.createCollator(new Locale("en_US"));
\r
1203 } catch (Exception e) {
\r
1204 errln("Collator.createCollator(Locale) was not suppose to " + "return an exception.");
\r
1208 * Tests the method public Collator createCollator(ULocale loc) using TestCreateCollator1 class
\r
1211 TestCreateCollator1 tcc = new TestCreateCollator1();
\r
1212 tcc.createCollator(new ULocale("en_US"));
\r
1213 } catch (Exception e) {
\r
1214 errln("Collator.createCollator(ULocale) was not suppose to " + "return an exception.");
\r
1218 * Tests the method gpublic String getDisplayName(Locale objectLocale, Locale displayLocale) using TestCreateCollator1 class
\r
1221 TestCreateCollator tcc = new TestCreateCollator();
\r
1222 tcc.getDisplayName(new Locale("en_US"), new Locale("jp_JP"));
\r
1223 } catch (Exception e) {
\r
1224 errln("Collator.getDisplayName(Locale,Locale) was not suppose to return an exception.");
\r
1228 * Tests the method public String getDisplayName(ULocale objectLocale, ULocale displayLocale) using TestCreateCollator1 class
\r
1231 TestCreateCollator1 tcc = new TestCreateCollator1();
\r
1232 tcc.getDisplayName(new ULocale("en_US"), new ULocale("jp_JP"));
\r
1233 } catch (Exception e) {
\r
1234 errln("Collator.getDisplayName(ULocale,ULocale) was not suppose to return an exception.");
\r
1237 /* Tests the method
\r
1238 * public static final String[] getKeywordValues(String keyword)
\r
1240 @SuppressWarnings("static-access")
\r
1241 public void TestGetKeywordValues(){
\r
1242 // Tests when "if (!keyword.equals(KEYWORDS[0]))" is true
\r
1243 String[] cases = {"","dummy"};
\r
1244 for(int i=0; i<cases.length; i++){
\r
1246 Collator c = Collator.getInstance();
\r
1247 @SuppressWarnings("unused")
\r
1248 String[] s = c.getKeywordValues(cases[i]);
\r
1249 errln("Collator.getKeywordValues(String) is suppose to return " +
\r
1250 "an exception for an invalid keyword.");
\r
1251 } catch(Exception e){}
\r