OLD | NEW |
1 /******************************************************************** | 1 /******************************************************************** |
2 * COPYRIGHT: | 2 * COPYRIGHT: |
3 * Copyright (c) 1997-2011, International Business Machines Corporation and | 3 * Copyright (c) 1997-2014, International Business Machines Corporation and |
4 * others. All Rights Reserved. | 4 * others. All Rights Reserved. |
5 ********************************************************************/ | 5 ********************************************************************/ |
6 | 6 |
7 /** | 7 /** |
8 * IntlTestCollator is the medium level test class for everything in the directo
ry "collate". | 8 * IntlTestCollator is the medium level test class for everything in the directo
ry "collate". |
9 */ | 9 */ |
10 | 10 |
11 /*********************************************************************** | 11 /*********************************************************************** |
12 * Modification history | 12 * Modification history |
13 * Date Name Description | 13 * Date Name Description |
14 * 02/14/2001 synwee Compare with cintltst and commented away tests | 14 * 02/14/2001 synwee Compare with cintltst and commented away tests |
15 * that are not run. | 15 * that are not run. |
16 ***********************************************************************/ | 16 ***********************************************************************/ |
17 | 17 |
18 #include "unicode/utypes.h" | 18 #include "unicode/utypes.h" |
19 | 19 |
20 #if !UCONFIG_NO_COLLATION | 20 #if !UCONFIG_NO_COLLATION |
21 | 21 |
22 #include "unicode/localpointer.h" | 22 #include "unicode/localpointer.h" |
| 23 #include "unicode/sortkey.h" |
23 #include "unicode/uchar.h" | 24 #include "unicode/uchar.h" |
24 #include "unicode/ustring.h" | 25 #include "unicode/ustring.h" |
25 | 26 |
26 #include "dadrcoll.h" | |
27 | |
28 #include "encoll.h" | 27 #include "encoll.h" |
29 #include "frcoll.h" | 28 #include "frcoll.h" |
30 #include "decoll.h" | 29 #include "decoll.h" |
31 #include "escoll.h" | 30 #include "escoll.h" |
32 #include "ficoll.h" | 31 #include "ficoll.h" |
33 #include "jacoll.h" | 32 #include "jacoll.h" |
34 #include "trcoll.h" | 33 #include "trcoll.h" |
35 #include "allcoll.h" | 34 #include "allcoll.h" |
36 #include "g7coll.h" | 35 #include "g7coll.h" |
37 #include "mnkytst.h" | 36 #include "mnkytst.h" |
38 #include "apicoll.h" | 37 #include "apicoll.h" |
39 #include "regcoll.h" | 38 #include "regcoll.h" |
40 #include "currcoll.h" | 39 #include "currcoll.h" |
41 #include "itercoll.h" | 40 #include "itercoll.h" |
42 #include "tstnorm.h" | 41 #include "tstnorm.h" |
43 #include "normconf.h" | 42 #include "normconf.h" |
44 #include "thcoll.h" | 43 #include "thcoll.h" |
45 #include "srchtest.h" | 44 #include "srchtest.h" |
46 #include "ssearch.h" | 45 #include "ssearch.h" |
47 #include "cntabcol.h" | |
48 #include "lcukocol.h" | 46 #include "lcukocol.h" |
49 #include "ucaconf.h" | 47 #include "ucaconf.h" |
50 #include "svccoll.h" | 48 #include "svccoll.h" |
51 #include "cmemory.h" | 49 #include "cmemory.h" |
52 #include "alphaindextst.h" | 50 #include "alphaindextst.h" |
53 //#include "rndmcoll.h" | |
54 | 51 |
55 // Set to 1 to test offsets in backAndForth() | 52 // Set to 1 to test offsets in backAndForth() |
56 #define TEST_OFFSETS 0 | 53 #define TEST_OFFSETS 0 |
57 | 54 |
58 #define TESTCLASS(n,classname) \ | 55 extern IntlTest *createCollationTest(); |
59 case n: \ | |
60 name = #classname; \ | |
61 if (exec) { \ | |
62 logln(#classname "---"); \ | |
63 logln(""); \ | |
64 classname t; \ | |
65 callTest(t, par); \ | |
66 } \ | |
67 break | |
68 | 56 |
69 void IntlTestCollator::runIndexedTest( int32_t index, UBool exec, const char* &n
ame, char* par ) | 57 void IntlTestCollator::runIndexedTest( int32_t index, UBool exec, const char* &n
ame, char* par ) |
70 { | 58 { |
71 if (exec) { | 59 if (exec) { |
72 logln("TestSuite Collator: "); | 60 logln("TestSuite Collator: "); |
73 } | 61 } |
74 | 62 |
75 switch (index) { | 63 TESTCASE_AUTO_BEGIN; |
76 TESTCLASS(0, CollationEnglishTest); | 64 TESTCASE_AUTO_CLASS(CollationEnglishTest); |
77 TESTCLASS(1, CollationFrenchTest); | 65 TESTCASE_AUTO_CLASS(CollationFrenchTest); |
78 TESTCLASS(2, CollationGermanTest); | 66 TESTCASE_AUTO_CLASS(CollationGermanTest); |
79 TESTCLASS(3, CollationSpanishTest); | 67 TESTCASE_AUTO_CLASS(CollationSpanishTest); |
80 TESTCLASS(4, CollationKanaTest); | 68 TESTCASE_AUTO_CLASS(CollationKanaTest); |
81 TESTCLASS(5, CollationTurkishTest); | 69 TESTCASE_AUTO_CLASS(CollationTurkishTest); |
82 TESTCLASS(6, CollationDummyTest); | 70 TESTCASE_AUTO_CLASS(CollationDummyTest); |
83 TESTCLASS(7, G7CollationTest); | 71 TESTCASE_AUTO_CLASS(G7CollationTest); |
84 TESTCLASS(8, CollationMonkeyTest); | 72 TESTCASE_AUTO_CLASS(CollationMonkeyTest); |
85 TESTCLASS(9, CollationAPITest); | 73 TESTCASE_AUTO_CLASS(CollationAPITest); |
86 TESTCLASS(10, CollationRegressionTest); | 74 TESTCASE_AUTO_CLASS(CollationRegressionTest); |
87 TESTCLASS(11, CollationCurrencyTest); | 75 TESTCASE_AUTO_CLASS(CollationCurrencyTest); |
88 TESTCLASS(12, CollationIteratorTest); | 76 TESTCASE_AUTO_CLASS(CollationIteratorTest); |
89 TESTCLASS(13, CollationThaiTest); | 77 TESTCASE_AUTO_CLASS(CollationThaiTest); |
90 TESTCLASS(14, LotusCollationKoreanTest); | 78 TESTCASE_AUTO_CLASS(LotusCollationKoreanTest); |
91 TESTCLASS(15, StringSearchTest); | 79 TESTCASE_AUTO_CLASS(StringSearchTest); |
92 TESTCLASS(16, ContractionTableTest); | 80 TESTCASE_AUTO_CLASS(UCAConformanceTest); |
93 #if !UCONFIG_NO_FILE_IO && !UCONFIG_NO_LEGACY_CONVERSION | 81 TESTCASE_AUTO_CLASS(CollationServiceTest); |
94 TESTCLASS(17, DataDrivenCollatorTest); | 82 TESTCASE_AUTO_CLASS(CollationFinnishTest); // removed by weiv - we have chan
ged Finnish collation |
| 83 TESTCASE_AUTO_CLASS(SSearchTest); |
| 84 #if !UCONFIG_NO_NORMALIZATION |
| 85 TESTCASE_AUTO_CLASS(AlphabeticIndexTest); |
95 #endif | 86 #endif |
96 TESTCLASS(18, UCAConformanceTest); | 87 TESTCASE_AUTO_CREATE_CLASS(CollationTest); |
97 TESTCLASS(19, CollationServiceTest); | 88 TESTCASE_AUTO_END; |
98 TESTCLASS(20, CollationFinnishTest); // removed by weiv - we have changed
Finnish collation | |
99 //TESTCLASS(21, RandomCollatorTest); // See ticket 5747 about reenabling t
his test. | |
100 TESTCLASS(21, SSearchTest); | |
101 #if !UCONFIG_NO_COLLATION && !UCONFIG_NO_NORMALIZATION | |
102 TESTCLASS(22, AlphabeticIndexTest); | |
103 #endif | |
104 | |
105 default: name = ""; break; | |
106 } | |
107 } | 89 } |
108 | 90 |
109 UCollationResult | 91 UCollationResult |
110 IntlTestCollator::compareUsingPartials(UCollator *coll, const UChar source[], in
t32_t sLen, const UChar target[], int32_t tLen, int32_t pieceSize, UErrorCode &s
tatus) { | 92 IntlTestCollator::compareUsingPartials(UCollator *coll, const UChar source[], in
t32_t sLen, const UChar target[], int32_t tLen, int32_t pieceSize, UErrorCode &s
tatus) { |
111 int32_t partialSKResult = 0; | 93 int32_t partialSKResult = 0; |
112 uint8_t sBuf[512], tBuf[512]; | 94 uint8_t sBuf[512], tBuf[512]; |
113 UCharIterator sIter, tIter; | 95 UCharIterator sIter, tIter; |
114 uint32_t sState[2], tState[2]; | 96 uint32_t sState[2], tState[2]; |
115 int32_t sSize = pieceSize, tSize = pieceSize; | 97 int32_t sSize = pieceSize, tSize = pieceSize; |
116 int32_t i = 0; | 98 int32_t i = 0; |
(...skipping 21 matching lines...) Expand all Loading... |
138 } else { | 120 } else { |
139 return UCOL_EQUAL; | 121 return UCOL_EQUAL; |
140 } | 122 } |
141 } | 123 } |
142 | 124 |
143 void | 125 void |
144 IntlTestCollator::doTestVariant(Collator* col, const UnicodeString &source, cons
t UnicodeString &target, Collator::EComparisonResult result) | 126 IntlTestCollator::doTestVariant(Collator* col, const UnicodeString &source, cons
t UnicodeString &target, Collator::EComparisonResult result) |
145 { | 127 { |
146 UErrorCode status = U_ZERO_ERROR; | 128 UErrorCode status = U_ZERO_ERROR; |
147 | 129 |
148 UCollator *myCollation = (UCollator *)((RuleBasedCollator *)col)->getUCollator
(); | 130 UCollator *myCollation = col->toUCollator(); |
149 | 131 |
150 Collator::EComparisonResult compareResult = col->compare(source, target); | 132 Collator::EComparisonResult compareResult = col->compare(source, target); |
151 | 133 |
152 CollationKey srckey, tgtkey; | 134 CollationKey srckey, tgtkey; |
153 col->getCollationKey(source, srckey, status); | 135 col->getCollationKey(source, srckey, status); |
154 col->getCollationKey(target, tgtkey, status); | 136 col->getCollationKey(target, tgtkey, status); |
155 if (U_FAILURE(status)){ | 137 if (U_FAILURE(status)){ |
156 errln("Creation of collation keys failed\n"); | 138 errln("Creation of collation keys failed\n"); |
157 } | 139 } |
158 Collator::EComparisonResult keyResult = srckey.compareTo(tgtkey); | 140 Collator::EComparisonResult keyResult = srckey.compareTo(tgtkey); |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
517 uprv_memcpy(temp, orders.getAlias(), size * sizeof(Order)); | 499 uprv_memcpy(temp, orders.getAlias(), size * sizeof(Order)); |
518 orders.adoptInstead(temp); | 500 orders.adoptInstead(temp); |
519 } | 501 } |
520 | 502 |
521 orders[size].order = order; | 503 orders[size].order = order; |
522 orders[size].offset = offset; | 504 orders[size].offset = offset; |
523 | 505 |
524 offset = iter.getOffset(); | 506 offset = iter.getOffset(); |
525 size += 1; | 507 size += 1; |
526 } | 508 } |
| 509 if (U_FAILURE(status)) { |
| 510 errln("CollationElementIterator.next() failed - %s", |
| 511 u_errorName(status)); |
| 512 } |
527 | 513 |
528 if (maxSize > size) | 514 if (maxSize > size) |
529 { | 515 { |
530 Order *temp = new Order[size]; | 516 Order *temp = new Order[size]; |
531 | 517 |
532 uprv_memcpy(temp, orders.getAlias(), size * sizeof(Order)); | 518 uprv_memcpy(temp, orders.getAlias(), size * sizeof(Order)); |
533 orders.adoptInstead(temp); | 519 orders.adoptInstead(temp); |
534 } | 520 } |
535 | 521 |
536 orderLength = size; | 522 orderLength = size; |
537 return orders.orphan(); | 523 return orders.orphan(); |
538 } | 524 } |
539 | 525 |
540 #endif /* #if !UCONFIG_NO_COLLATION */ | 526 #endif /* #if !UCONFIG_NO_COLLATION */ |
OLD | NEW |