OLD | NEW |
1 /******************************************************************** | 1 /******************************************************************** |
2 * COPYRIGHT: | 2 * COPYRIGHT: |
3 * Copyright (c) 1997-2010, 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 * File CG7COLL.C | 8 * File CG7COLL.C |
9 * | 9 * |
10 * Modification History: | 10 * Modification History: |
11 * Name Description | 11 * Name Description |
12 * Madhu Katragadda Ported for C API | 12 * Madhu Katragadda Ported for C API |
13 ********************************************************************************
*/ | 13 ********************************************************************************
*/ |
(...skipping 29 matching lines...) Expand all Loading... |
43 #if !UCONFIG_NO_COLLATION | 43 #if !UCONFIG_NO_COLLATION |
44 | 44 |
45 #include "unicode/ucol.h" | 45 #include "unicode/ucol.h" |
46 #include "unicode/uloc.h" | 46 #include "unicode/uloc.h" |
47 #include "cintltst.h" | 47 #include "cintltst.h" |
48 #include "cg7coll.h" | 48 #include "cg7coll.h" |
49 #include "ccolltst.h" | 49 #include "ccolltst.h" |
50 #include "callcoll.h" | 50 #include "callcoll.h" |
51 #include "unicode/ustring.h" | 51 #include "unicode/ustring.h" |
52 | 52 |
53 | |
54 const char* locales[8] = { | 53 const char* locales[8] = { |
55 "en_US", | 54 "en_US", |
56 "en_GB", | 55 "en_GB", |
57 "en_CA", | 56 "en_CA", |
58 "fr_FR", | 57 "fr_FR", |
59 "fr_CA", | 58 "fr_CA", |
60 "de_DE", | 59 "de_DE", |
61 "it_IT", | 60 "it_IT", |
62 "ja_JP" | 61 "ja_JP" |
63 }; | 62 }; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 addTest(root, &TestDemo1, "tscoll/cg7coll/TestDemo1"); | 128 addTest(root, &TestDemo1, "tscoll/cg7coll/TestDemo1"); |
130 addTest(root, &TestDemo2, "tscoll/cg7coll/TestDemo2"); | 129 addTest(root, &TestDemo2, "tscoll/cg7coll/TestDemo2"); |
131 addTest(root, &TestDemo3, "tscoll/cg7coll/TestDemo3"); | 130 addTest(root, &TestDemo3, "tscoll/cg7coll/TestDemo3"); |
132 addTest(root, &TestDemo4, "tscoll/cg7coll/TestDemo4"); | 131 addTest(root, &TestDemo4, "tscoll/cg7coll/TestDemo4"); |
133 | 132 |
134 | 133 |
135 } | 134 } |
136 | 135 |
137 static void TestG7Locales() | 136 static void TestG7Locales() |
138 { | 137 { |
139 UCollator *myCollation, *tblColl1; | 138 UCollator *myCollation; |
140 UErrorCode status = U_ZERO_ERROR; | 139 UErrorCode status = U_ZERO_ERROR; |
141 const UChar *defRules; | 140 const UChar *defRules; |
142 int32_t i, rlen, j, n; | 141 int32_t i, rlen, j, n; |
143 log_verbose("Testing ucol_openRules for all the locales\n"); | 142 log_verbose("Testing ucol_openRules for all the locales\n"); |
144 for (i = 0; i < 8; i++) | 143 for (i = 0; i < UPRV_LENGTHOF(locales); i++) |
145 { | 144 { |
| 145 const char *locale = locales[i]; |
146 status = U_ZERO_ERROR; | 146 status = U_ZERO_ERROR; |
147 myCollation = ucol_open(locales[i], &status); | 147 myCollation = ucol_open(locale, &status); |
148 ucol_setAttribute(myCollation, UCOL_STRENGTH, UCOL_QUATERNARY, &status); | 148 ucol_setAttribute(myCollation, UCOL_STRENGTH, UCOL_QUATERNARY, &status); |
149 ucol_setAttribute(myCollation, UCOL_ALTERNATE_HANDLING, UCOL_SHIFTED, &s
tatus); | 149 ucol_setAttribute(myCollation, UCOL_ALTERNATE_HANDLING, UCOL_SHIFTED, &s
tatus); |
150 | 150 |
151 if (U_FAILURE(status)) | 151 if (U_FAILURE(status)) |
152 { | 152 { |
153 log_err_status(status, "Error in creating collator in %s: %s\n", lo
cales[i], myErrorName(status)); | 153 log_err_status(status, "Error in creating collator in %s: %s\n", lo
cale, myErrorName(status)); |
| 154 ucol_close(myCollation); |
154 continue; | 155 continue; |
155 } | 156 } |
156 | 157 |
157 defRules = ucol_getRules(myCollation, &rlen); | 158 defRules = ucol_getRules(myCollation, &rlen); |
158 status = U_ZERO_ERROR; | 159 if (rlen == 0 && (strcmp(locale, "fr_CA") == 0 || strcmp(locale, "ja_JP"
) == 0)) { |
159 tblColl1 = ucol_openRules(defRules, rlen, UCOL_OFF, | 160 log_data_err("%s UCollator missing rule string\n", locale); |
160 UCOL_DEFAULT_STRENGTH,NULL, &status); | 161 if (log_knownIssue("10671", "TestG7Locales does not test ignore-punc
tuation")) { |
161 if (U_FAILURE(status)) | 162 ucol_close(myCollation); |
162 { | 163 continue; |
| 164 } |
| 165 } else { |
| 166 UCollator *tblColl1; |
| 167 status = U_ZERO_ERROR; |
| 168 tblColl1 = ucol_openRules(defRules, rlen, UCOL_OFF, |
| 169 UCOL_DEFAULT_STRENGTH,NULL, &status); |
163 ucol_close(myCollation); | 170 ucol_close(myCollation); |
164 log_err_status(status, "Error in creating collator in %s: %s\n", lo
cales[i], myErrorName(status)); | 171 if (U_FAILURE(status)) |
165 continue; | 172 { |
| 173 log_err_status(status, "Error in creating collator in %s: %s\n"
, locale, myErrorName(status)); |
| 174 continue; |
| 175 } |
| 176 myCollation = tblColl1; |
166 } | 177 } |
167 | 178 |
168 | |
169 log_verbose("Locale %s\n", locales[i]); | 179 log_verbose("Locale %s\n", locales[i]); |
170 log_verbose(" tests start...\n"); | 180 log_verbose(" tests start...\n"); |
171 | 181 |
172 j = 0; | 182 j = 0; |
173 n = 0; | 183 n = 0; |
174 for (j = 0; j < FIXEDTESTSET; j++) | 184 for (j = 0; j < FIXEDTESTSET; j++) |
175 { | 185 { |
176 for (n = j+1; n < FIXEDTESTSET; n++) | 186 for (n = j+1; n < FIXEDTESTSET; n++) |
177 { | 187 { |
178 doTest(tblColl1, testCases[results[i][j]], testCases[results[i][
n]], UCOL_LESS); | 188 doTest(myCollation, testCases[results[i][j]], testCases[results[
i][n]], UCOL_LESS); |
179 } | 189 } |
180 } | 190 } |
181 | 191 |
182 ucol_close(myCollation); | 192 ucol_close(myCollation); |
183 ucol_close(tblColl1); | |
184 } | 193 } |
185 } | 194 } |
186 | 195 |
187 static void TestDemo1() | 196 static void TestDemo1() |
188 { | 197 { |
189 UCollator *myCollation; | 198 UCollator *myCollation; |
190 int32_t j, n; | 199 int32_t j, n; |
191 static const char rules[] = "& Z < p, P"; | 200 static const char rules[] = "& Z < p, P"; |
192 int32_t len=(int32_t)strlen(rules); | 201 int32_t len=(int32_t)strlen(rules); |
193 UChar temp[sizeof(rules)]; | 202 UChar temp[sizeof(rules)]; |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 { | 306 { |
298 for (n = j+1; n < TOTALTESTSET; n++) | 307 for (n = j+1; n < TOTALTESTSET; n++) |
299 { | 308 { |
300 doTest(myCollation, testCases[results[11][j]], testCases[results[11]
[n]], UCOL_LESS); | 309 doTest(myCollation, testCases[results[11][j]], testCases[results[11]
[n]], UCOL_LESS); |
301 } | 310 } |
302 } | 311 } |
303 ucol_close(myCollation); | 312 ucol_close(myCollation); |
304 } | 313 } |
305 | 314 |
306 #endif /* #if !UCONFIG_NO_COLLATION */ | 315 #endif /* #if !UCONFIG_NO_COLLATION */ |
OLD | NEW |