| OLD | NEW |
| 1 /******************************************************************** | 1 /******************************************************************** |
| 2 * COPYRIGHT: | 2 * COPYRIGHT: |
| 3 * Copyright (c) 1997-2013, 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 CALLCOLL.C | 8 * File CALLCOLL.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 991 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1005 | 1005 |
| 1006 | 1006 |
| 1007 | 1007 |
| 1008 /** | 1008 /** |
| 1009 * Tests the [variable top] tag in rule syntax. Since the default [alternate] | 1009 * Tests the [variable top] tag in rule syntax. Since the default [alternate] |
| 1010 * tag has the value shifted, any codepoints before [variable top] should give | 1010 * tag has the value shifted, any codepoints before [variable top] should give |
| 1011 * a primary ce of 0. | 1011 * a primary ce of 0. |
| 1012 */ | 1012 */ |
| 1013 static void TestVariableTop(void) | 1013 static void TestVariableTop(void) |
| 1014 { | 1014 { |
| 1015 #if 0 |
| 1016 /* |
| 1017 * Starting with ICU 53, setting the variable top via a pseudo relation stri
ng |
| 1018 * is not supported any more. |
| 1019 * It was replaced by the [maxVariable symbol] setting. |
| 1020 * See ICU tickets #9958 and #8032. |
| 1021 */ |
| 1015 static const char str[] = "&z = [variable top]"; | 1022 static const char str[] = "&z = [variable top]"; |
| 1016 int len = strlen(str); | 1023 int len = strlen(str); |
| 1017 UChar rules[sizeof(str)]; | 1024 UChar rules[sizeof(str)]; |
| 1018 UCollator *myCollation; | 1025 UCollator *myCollation; |
| 1019 UCollator *enCollation; | 1026 UCollator *enCollation; |
| 1020 UErrorCode status = U_ZERO_ERROR; | 1027 UErrorCode status = U_ZERO_ERROR; |
| 1021 UChar source[1]; | 1028 UChar source[1]; |
| 1022 UChar ch; | 1029 UChar ch; |
| 1023 uint8_t result[20]; | 1030 uint8_t result[20]; |
| 1024 uint8_t expected[20]; | 1031 uint8_t expected[20]; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1071 log_err("ERROR: SHIFTED alternate does not return 0 for primary of %
c\n", | 1078 log_err("ERROR: SHIFTED alternate does not return 0 for primary of %
c\n", |
| 1072 ch); | 1079 ch); |
| 1073 } | 1080 } |
| 1074 ch ++; | 1081 ch ++; |
| 1075 } | 1082 } |
| 1076 | 1083 |
| 1077 ucol_close(enCollation); | 1084 ucol_close(enCollation); |
| 1078 ucol_close(myCollation); | 1085 ucol_close(myCollation); |
| 1079 enCollation = NULL; | 1086 enCollation = NULL; |
| 1080 myCollation = NULL; | 1087 myCollation = NULL; |
| 1088 #endif |
| 1081 } | 1089 } |
| 1082 | 1090 |
| 1083 /** | 1091 /** |
| 1084 * Tests surrogate support. | 1092 * Tests surrogate support. |
| 1085 * NOTE: This test used \\uD801\\uDC01 pair, which is now assigned to Desseret | 1093 * NOTE: This test used \\uD801\\uDC01 pair, which is now assigned to Desseret |
| 1086 * Therefore, another (unassigned) code point was used for this test. | 1094 * Therefore, another (unassigned) code point was used for this test. |
| 1087 */ | 1095 */ |
| 1088 static void TestSurrogates(void) | 1096 static void TestSurrogates(void) |
| 1089 { | 1097 { |
| 1090 static const char str[] = | 1098 static const char str[] = |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1160 */ | 1168 */ |
| 1161 static void | 1169 static void |
| 1162 TestInvalidRules(){ | 1170 TestInvalidRules(){ |
| 1163 #define MAX_ERROR_STATES 2 | 1171 #define MAX_ERROR_STATES 2 |
| 1164 | 1172 |
| 1165 static const char* rulesArr[MAX_ERROR_STATES] = { | 1173 static const char* rulesArr[MAX_ERROR_STATES] = { |
| 1166 "& C < ch, cH, Ch[this should fail]<d", | 1174 "& C < ch, cH, Ch[this should fail]<d", |
| 1167 "& C < ch, cH, & Ch[variable top]" | 1175 "& C < ch, cH, & Ch[variable top]" |
| 1168 }; | 1176 }; |
| 1169 static const char* preContextArr[MAX_ERROR_STATES] = { | 1177 static const char* preContextArr[MAX_ERROR_STATES] = { |
| 1170 "his should fail", | 1178 " C < ch, cH, Ch", |
| 1171 "& C < ch, cH, ", | 1179 "& C < ch, cH", |
| 1172 | 1180 |
| 1173 }; | 1181 }; |
| 1174 static const char* postContextArr[MAX_ERROR_STATES] = { | 1182 static const char* postContextArr[MAX_ERROR_STATES] = { |
| 1175 "<d", | 1183 "[this should fa", |
| 1176 " Ch[variable t" | 1184 ", & Ch[variable" |
| 1177 }; | 1185 }; |
| 1178 int i; | 1186 int i; |
| 1179 | 1187 |
| 1180 for(i = 0;i<MAX_ERROR_STATES;i++){ | 1188 for(i = 0;i<MAX_ERROR_STATES;i++){ |
| 1181 UChar rules[1000] = { '\0' }; | 1189 UChar rules[1000] = { '\0' }; |
| 1182 UChar preContextExp[1000] = { '\0' }; | 1190 UChar preContextExp[1000] = { '\0' }; |
| 1183 UChar postContextExp[1000] = { '\0' }; | 1191 UChar postContextExp[1000] = { '\0' }; |
| 1184 UParseError parseError; | 1192 UParseError parseError; |
| 1185 UErrorCode status = U_ZERO_ERROR; | 1193 UErrorCode status = U_ZERO_ERROR; |
| 1186 UCollator* coll=0; | 1194 UCollator* coll=0; |
| 1187 u_charsToUChars(rulesArr[i],rules,uprv_strlen(rulesArr[i])+1); | 1195 u_charsToUChars(rulesArr[i],rules,uprv_strlen(rulesArr[i])+1); |
| 1188 u_charsToUChars(preContextArr[i],preContextExp,uprv_strlen(preContextArr
[i])+1); | 1196 u_charsToUChars(preContextArr[i],preContextExp,uprv_strlen(preContextArr
[i])+1); |
| 1189 u_charsToUChars(postContextArr[i],postContextExp,uprv_strlen(postContext
Arr[i])+1); | 1197 u_charsToUChars(postContextArr[i],postContextExp,uprv_strlen(postContext
Arr[i])+1); |
| 1190 /* clean up stuff in parseError */ | 1198 /* clean up stuff in parseError */ |
| 1191 u_memset(parseError.preContext,0x0000,U_PARSE_CONTEXT_LEN); | 1199 u_memset(parseError.preContext,0x0000,U_PARSE_CONTEXT_LEN); |
| 1192 u_memset(parseError.postContext,0x0000,U_PARSE_CONTEXT_LEN); | 1200 u_memset(parseError.postContext,0x0000,U_PARSE_CONTEXT_LEN); |
| 1193 /* open the rules and test */ | 1201 /* open the rules and test */ |
| 1194 coll = ucol_openRules(rules,u_strlen(rules),UCOL_OFF,UCOL_DEFAULT_STRENG
TH,&parseError,&status); | 1202 coll = ucol_openRules(rules,u_strlen(rules),UCOL_OFF,UCOL_DEFAULT_STRENG
TH,&parseError,&status); |
| 1195 (void)coll; /* Suppress set but not used warning. */ | 1203 (void)coll; /* Suppress set but not used warning. */ |
| 1196 if(u_strcmp(parseError.preContext,preContextExp)!=0){ | 1204 if(u_strcmp(parseError.preContext,preContextExp)!=0){ |
| 1197 log_err_status(status, "preContext in UParseError for ucol_openRules
does not match\n"); | 1205 log_err_status(status, "preContext in UParseError for ucol_openRules
does not match: \"%s\"\n", |
| 1206 aescstrdup(parseError.preContext, -1)); |
| 1198 } | 1207 } |
| 1199 if(u_strcmp(parseError.postContext,postContextExp)!=0){ | 1208 if(u_strcmp(parseError.postContext,postContextExp)!=0){ |
| 1200 log_err_status(status, "postContext in UParseError for ucol_openRule
s does not match\n"); | 1209 log_err_status(status, "postContext in UParseError for ucol_openRule
s does not match: \"%s\"\n", |
| 1210 aescstrdup(parseError.postContext, -1)); |
| 1201 } | 1211 } |
| 1202 } | 1212 } |
| 1203 } | 1213 } |
| 1204 | 1214 |
| 1205 static void | 1215 static void |
| 1206 TestJitterbug1098(){ | 1216 TestJitterbug1098(){ |
| 1207 UChar rule[1000]; | 1217 UChar rule[1000]; |
| 1208 UCollator* c1 = NULL; | 1218 UCollator* c1 = NULL; |
| 1209 UErrorCode status = U_ZERO_ERROR; | 1219 UErrorCode status = U_ZERO_ERROR; |
| 1210 UParseError parseError; | 1220 UParseError parseError; |
| 1211 char preContext[200]={0}; | 1221 char preContext[200]={0}; |
| 1212 char postContext[200]={0}; | 1222 char postContext[200]={0}; |
| 1213 int i=0; | 1223 int i=0; |
| 1214 const char* rules[] = { | 1224 const char* rules[] = { |
| 1215 "&''<\\\\", | 1225 "&''<\\\\", |
| 1216 "&\\'<\\\\", | 1226 "&\\'<\\\\", |
| 1217 "&\\\"<'\\'", | 1227 "&\\\"<'\\'", |
| 1218 "&'\"'<\\'", | 1228 "&'\"'<\\'", |
| 1219 '\0' | 1229 NULL |
| 1220 | 1230 |
| 1221 }; | 1231 }; |
| 1222 const UCollationResult results1098[] = { | 1232 const UCollationResult results1098[] = { |
| 1223 UCOL_LESS, | 1233 UCOL_LESS, |
| 1224 UCOL_LESS, | 1234 UCOL_LESS, |
| 1225 UCOL_LESS, | 1235 UCOL_LESS, |
| 1226 UCOL_LESS, | 1236 UCOL_LESS, |
| 1227 }; | 1237 }; |
| 1228 const UChar input[][2]= { | 1238 const UChar input[][2]= { |
| 1229 {0x0027,0x005c}, | 1239 {0x0027,0x005c}, |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1301 static void TestJ5298(void) | 1311 static void TestJ5298(void) |
| 1302 { | 1312 { |
| 1303 UErrorCode status = U_ZERO_ERROR; | 1313 UErrorCode status = U_ZERO_ERROR; |
| 1304 char input[256], output[256]; | 1314 char input[256], output[256]; |
| 1305 UBool isAvailable; | 1315 UBool isAvailable; |
| 1306 int32_t i = 0; | 1316 int32_t i = 0; |
| 1307 UEnumeration* values = NULL; | 1317 UEnumeration* values = NULL; |
| 1308 const char *keywordValue = NULL; | 1318 const char *keywordValue = NULL; |
| 1309 log_verbose("Number of collator locales returned : %i \n", ucol_countAvailab
le()); | 1319 log_verbose("Number of collator locales returned : %i \n", ucol_countAvailab
le()); |
| 1310 values = ucol_getKeywordValues("collation", &status); | 1320 values = ucol_getKeywordValues("collation", &status); |
| 1321 while ((keywordValue = uenum_next(values, NULL, &status)) != NULL) { |
| 1322 if (strncmp(keywordValue, "private-", 8) == 0) { |
| 1323 log_err("ucol_getKeywordValues() returns private collation keyword:
%s\n", keywordValue); |
| 1324 } |
| 1325 } |
| 1311 for (i = 0; i < ucol_countAvailable(); i++) { | 1326 for (i = 0; i < ucol_countAvailable(); i++) { |
| 1312 uenum_reset(values, &status); | 1327 uenum_reset(values, &status); |
| 1313 while ((keywordValue = uenum_next(values, NULL, &status)) != NULL) { | 1328 while ((keywordValue = uenum_next(values, NULL, &status)) != NULL) { |
| 1314 strcpy(input, ucol_getAvailable(i)); | 1329 strcpy(input, ucol_getAvailable(i)); |
| 1315 if (strcmp(keywordValue, "standard") != 0) { | 1330 if (strcmp(keywordValue, "standard") != 0) { |
| 1316 strcat(input, "@collation="); | 1331 strcat(input, "@collation="); |
| 1317 strcat(input, keywordValue); | 1332 strcat(input, keywordValue); |
| 1318 } | 1333 } |
| 1319 | 1334 |
| 1320 ucol_getFunctionalEquivalent(output, 256, "collation", input, &isAva
ilable, &status); | 1335 ucol_getFunctionalEquivalent(output, 256, "collation", input, &isAva
ilable, &status); |
| 1321 if (strcmp(input, output) == 0) { /* Unique locale, print it out */ | 1336 if (strcmp(input, output) == 0) { /* Unique locale, print it out */ |
| 1322 log_verbose("%s, \n", output); | 1337 log_verbose("%s, \n", output); |
| 1323 } | 1338 } |
| 1324 } | 1339 } |
| 1325 } | 1340 } |
| 1326 uenum_close(values); | 1341 uenum_close(values); |
| 1327 log_verbose("\n"); | 1342 log_verbose("\n"); |
| 1328 } | 1343 } |
| 1329 #endif /* #if !UCONFIG_NO_COLLATION */ | 1344 #endif /* #if !UCONFIG_NO_COLLATION */ |
| OLD | NEW |