Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(471)

Side by Side Diff: source/test/cintltst/cnormtst.c

Issue 845603002: Update ICU to 54.1 step 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/icu.git@master
Patch Set: remove unusued directories Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « source/test/cintltst/cnmdptst.c ('k') | source/test/cintltst/cnumtst.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /******************************************************************** 1 /********************************************************************
2 * COPYRIGHT: 2 * COPYRIGHT:
3 * Copyright (c) 1997-2012, 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 CNORMTST.C 8 * File CNORMTST.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 * synwee added test for quick check 13 * synwee added test for quick check
14 * synwee added test for checkFCD 14 * synwee added test for checkFCD
15 ******************************************************************************** */ 15 ******************************************************************************** */
16 /*tests for u_normalization*/ 16 /*tests for u_normalization*/
17 #include "unicode/utypes.h" 17 #include "unicode/utypes.h"
18 #include "unicode/unorm.h" 18 #include "unicode/unorm.h"
19 #include "unicode/utf16.h" 19 #include "unicode/utf16.h"
20 #include "cintltst.h" 20 #include "cintltst.h"
21 #include "cmemory.h"
21 22
22 #if !UCONFIG_NO_NORMALIZATION 23 #if !UCONFIG_NO_NORMALIZATION
23 24
24 #include <stdlib.h> 25 #include <stdlib.h>
25 #include <time.h> 26 #include <time.h>
26 #include "unicode/uchar.h" 27 #include "unicode/uchar.h"
27 #include "unicode/ustring.h" 28 #include "unicode/ustring.h"
28 #include "unicode/unorm.h" 29 #include "unicode/unorm.h"
29 #include "cnormtst.h" 30 #include "cnormtst.h"
30 31
31 #define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof ((array)[0]))
32
33 static void 32 static void
34 TestAPI(void); 33 TestAPI(void);
35 34
36 static void 35 static void
37 TestNormCoverage(void); 36 TestNormCoverage(void);
38 37
39 static void 38 static void
40 TestConcatenate(void); 39 TestConcatenate(void);
41 40
42 static void 41 static void
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 length2= unorm_normalize(source, -1, mode, 0, NULL, 0, &status2); 181 length2= unorm_normalize(source, -1, mode, 0, NULL, 0, &status2);
183 if(neededLen!=length2) { 182 if(neededLen!=length2) {
184 log_err("ERROR in unorm_normalize(%s)[%d]: " 183 log_err("ERROR in unorm_normalize(%s)[%d]: "
185 "preflight length/NUL %d!=%d preflight length/srcLength\n", 184 "preflight length/NUL %d!=%d preflight length/srcLength\n",
186 modeStrings[mode], (int)x, (int)neededLen, (int)length2); 185 modeStrings[mode], (int)x, (int)neededLen, (int)length2);
187 } 186 }
188 if(status==U_BUFFER_OVERFLOW_ERROR) 187 if(status==U_BUFFER_OVERFLOW_ERROR)
189 { 188 {
190 status=U_ZERO_ERROR; 189 status=U_ZERO_ERROR;
191 } 190 }
192 length2=unorm_normalize(source, u_strlen(source), mode, 0, result, LENGT HOF(result), &status); 191 length2=unorm_normalize(source, u_strlen(source), mode, 0, result, UPRV_ LENGTHOF(result), &status);
193 if(U_FAILURE(status) || neededLen!=length2) { 192 if(U_FAILURE(status) || neededLen!=length2) {
194 log_data_err("ERROR in unorm_normalize(%s/NUL) at %s: %s - (Are you missing data?)\n", 193 log_data_err("ERROR in unorm_normalize(%s/NUL) at %s: %s - (Are you missing data?)\n",
195 modeStrings[mode], austrdup(source), myErrorName(status )); 194 modeStrings[mode], austrdup(source), myErrorName(status ));
196 } else { 195 } else {
197 assertEqual(result, cases[x][expIndex], x); 196 assertEqual(result, cases[x][expIndex], x);
198 } 197 }
199 length2=unorm_normalize(source, -1, mode, 0, result, LENGTHOF(result), & status); 198 length2=unorm_normalize(source, -1, mode, 0, result, UPRV_LENGTHOF(resul t), &status);
200 if(U_FAILURE(status) || neededLen!=length2) { 199 if(U_FAILURE(status) || neededLen!=length2) {
201 log_data_err("ERROR in unorm_normalize(%s/srcLength) at %s: %s - (A re you missing data?)\n", 200 log_data_err("ERROR in unorm_normalize(%s/srcLength) at %s: %s - (A re you missing data?)\n",
202 modeStrings[mode], austrdup(source), myErrorName(status )); 201 modeStrings[mode], austrdup(source), myErrorName(status ));
203 } else { 202 } else {
204 assertEqual(result, cases[x][expIndex], x); 203 assertEqual(result, cases[x][expIndex], x);
205 } 204 }
206 free(source); 205 free(source);
207 } 206 }
208 } 207 }
209 208
210 void TestDecomp() { 209 void TestDecomp() {
211 TestNormCases(UNORM_NFD, canonTests, LENGTHOF(canonTests)); 210 TestNormCases(UNORM_NFD, canonTests, UPRV_LENGTHOF(canonTests));
212 } 211 }
213 212
214 void TestCompatDecomp() { 213 void TestCompatDecomp() {
215 TestNormCases(UNORM_NFKD, compatTests, LENGTHOF(compatTests)); 214 TestNormCases(UNORM_NFKD, compatTests, UPRV_LENGTHOF(compatTests));
216 } 215 }
217 216
218 void TestCanonDecompCompose() { 217 void TestCanonDecompCompose() {
219 TestNormCases(UNORM_NFC, canonTests, LENGTHOF(canonTests)); 218 TestNormCases(UNORM_NFC, canonTests, UPRV_LENGTHOF(canonTests));
220 } 219 }
221 220
222 void TestCompatDecompCompose() { 221 void TestCompatDecompCompose() {
223 TestNormCases(UNORM_NFKC, compatTests, LENGTHOF(compatTests)); 222 TestNormCases(UNORM_NFKC, compatTests, UPRV_LENGTHOF(compatTests));
224 } 223 }
225 224
226 void TestFCD() { 225 void TestFCD() {
227 TestNormCases(UNORM_FCD, fcdTests, LENGTHOF(fcdTests)); 226 TestNormCases(UNORM_FCD, fcdTests, UPRV_LENGTHOF(fcdTests));
228 } 227 }
229 228
230 static void assertEqual(const UChar* result, const char* expected, int32_t index ) 229 static void assertEqual(const UChar* result, const char* expected, int32_t index )
231 { 230 {
232 UChar *expectedUni = CharsToUChars(expected); 231 UChar *expectedUni = CharsToUChars(expected);
233 if(u_strcmp(result, expectedUni)!=0){ 232 if(u_strcmp(result, expectedUni)!=0){
234 log_err("ERROR in decomposition at index = %d. EXPECTED: %s , GOT: %s\n" , index, expected, 233 log_err("ERROR in decomposition at index = %d. EXPECTED: %s , GOT: %s\n" , index, expected,
235 austrdup(result) ); 234 austrdup(result) );
236 } 235 }
237 free(expectedUni); 236 free(expectedUni);
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 return; 387 return;
389 } 388 }
390 if (unorm_quickCheck(&cp, 1, UNORM_NFC, &error) != 389 if (unorm_quickCheck(&cp, 1, UNORM_NFC, &error) !=
391 UNORM_YES) 390 UNORM_YES)
392 { 391 {
393 log_err("ERROR in NFC quick check at U+%04x\n", cp); 392 log_err("ERROR in NFC quick check at U+%04x\n", cp);
394 return; 393 return;
395 } 394 }
396 if (unorm_quickCheck(&cp, 1, UNORM_NFKD, &error) != UNORM_YES) 395 if (unorm_quickCheck(&cp, 1, UNORM_NFKD, &error) != UNORM_YES)
397 { 396 {
398 log_err("ERROR in NFKD quick check at U+%04x\n", cp); 397 log_data_err("ERROR in NFKD quick check at U+%04x\n", cp);
399 return; 398 return;
400 } 399 }
401 if (unorm_quickCheck(&cp, 1, UNORM_NFKC, &error) != 400 if (unorm_quickCheck(&cp, 1, UNORM_NFKC, &error) !=
402 UNORM_YES) 401 UNORM_YES)
403 { 402 {
404 log_err("ERROR in NFKC quick check at U+%04x\n", cp); 403 log_err("ERROR in NFKC quick check at U+%04x\n", cp);
405 return; 404 return;
406 } 405 }
407 cp ++; 406 cp ++;
408 } 407 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 { 453 {
455 if (unorm_quickCheck(&(CPNFC[count]), 1, UNORM_NFC, &error) != 454 if (unorm_quickCheck(&(CPNFC[count]), 1, UNORM_NFC, &error) !=
456 UNORM_MAYBE) 455 UNORM_MAYBE)
457 { 456 {
458 log_data_err("ERROR in NFC quick check at U+%04x - (Are you missing data?) \n", CPNFC[count]); 457 log_data_err("ERROR in NFC quick check at U+%04x - (Are you missing data?) \n", CPNFC[count]);
459 return; 458 return;
460 } 459 }
461 if (unorm_quickCheck(&(CPNFKC[count]), 1, UNORM_NFKC, &error) != 460 if (unorm_quickCheck(&(CPNFKC[count]), 1, UNORM_NFKC, &error) !=
462 UNORM_MAYBE) 461 UNORM_MAYBE)
463 { 462 {
464 log_err("ERROR in NFKC quick check at U+%04x\n", CPNFKC[count]); 463 log_data_err("ERROR in NFKC quick check at U+%04x\n", CPNFKC[count]);
465 return; 464 return;
466 } 465 }
467 } 466 }
468 } 467 }
469 468
470 static void TestQuickCheckStringResult() 469 static void TestQuickCheckStringResult()
471 { 470 {
472 int count; 471 int count;
473 UChar *d = NULL; 472 UChar *d = NULL;
474 UChar *c = NULL; 473 UChar *c = NULL;
475 UErrorCode error = U_ZERO_ERROR; 474 UErrorCode error = U_ZERO_ERROR;
476 475
477 for (count = 0; count < LENGTHOF(canonTests); count ++) 476 for (count = 0; count < UPRV_LENGTHOF(canonTests); count ++)
478 { 477 {
479 d = CharsToUChars(canonTests[count][1]); 478 d = CharsToUChars(canonTests[count][1]);
480 c = CharsToUChars(canonTests[count][2]); 479 c = CharsToUChars(canonTests[count][2]);
481 if (unorm_quickCheck(d, u_strlen(d), UNORM_NFD, &error) != 480 if (unorm_quickCheck(d, u_strlen(d), UNORM_NFD, &error) !=
482 UNORM_YES) 481 UNORM_YES)
483 { 482 {
484 log_data_err("ERROR in NFD quick check for string at count %d - (Are you m issing data?)\n", count); 483 log_data_err("ERROR in NFD quick check for string at count %d - (Are you m issing data?)\n", count);
485 return; 484 return;
486 } 485 }
487 486
488 if (unorm_quickCheck(c, u_strlen(c), UNORM_NFC, &error) == 487 if (unorm_quickCheck(c, u_strlen(c), UNORM_NFC, &error) ==
489 UNORM_NO) 488 UNORM_NO)
490 { 489 {
491 log_err("ERROR in NFC quick check for string at count %d\n", count); 490 log_err("ERROR in NFC quick check for string at count %d\n", count);
492 return; 491 return;
493 } 492 }
494 493
495 free(d); 494 free(d);
496 free(c); 495 free(c);
497 } 496 }
498 497
499 for (count = 0; count < LENGTHOF(compatTests); count ++) 498 for (count = 0; count < UPRV_LENGTHOF(compatTests); count ++)
500 { 499 {
501 d = CharsToUChars(compatTests[count][1]); 500 d = CharsToUChars(compatTests[count][1]);
502 c = CharsToUChars(compatTests[count][2]); 501 c = CharsToUChars(compatTests[count][2]);
503 if (unorm_quickCheck(d, u_strlen(d), UNORM_NFKD, &error) != 502 if (unorm_quickCheck(d, u_strlen(d), UNORM_NFKD, &error) !=
504 UNORM_YES) 503 UNORM_YES)
505 { 504 {
506 log_err("ERROR in NFKD quick check for string at count %d\n", count); 505 log_data_err("ERROR in NFKD quick check for string at count %d\n", count);
507 return; 506 return;
508 } 507 }
509 508
510 if (unorm_quickCheck(c, u_strlen(c), UNORM_NFKC, &error) != 509 if (unorm_quickCheck(c, u_strlen(c), UNORM_NFKC, &error) !=
511 UNORM_YES) 510 UNORM_YES)
512 { 511 {
513 log_err("ERROR in NFKC quick check for string at count %d\n", count); 512 log_err("ERROR in NFKC quick check for string at count %d\n", count);
514 return; 513 return;
515 } 514 }
516 515
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 } 570 }
572 571
573 /* bad length */ 572 /* bad length */
574 errorCode=U_ZERO_ERROR; 573 errorCode=U_ZERO_ERROR;
575 (void)unorm_isNormalized(notNFC[0]+2, -2, UNORM_NFC, &errorCode); 574 (void)unorm_isNormalized(notNFC[0]+2, -2, UNORM_NFC, &errorCode);
576 if(errorCode!=U_ILLEGAL_ARGUMENT_ERROR) { 575 if(errorCode!=U_ILLEGAL_ARGUMENT_ERROR) {
577 log_data_err("error: isNormalized([-2]) did not set U_ILLEGAL_ARGUMENT_E RROR but %s - (Are you missing data?)\n", u_errorName(errorCode)); 576 log_data_err("error: isNormalized([-2]) did not set U_ILLEGAL_ARGUMENT_E RROR but %s - (Are you missing data?)\n", u_errorName(errorCode));
578 } 577 }
579 578
580 /* specific cases */ 579 /* specific cases */
581 for(i=0; i<LENGTHOF(notNFC); ++i) { 580 for(i=0; i<UPRV_LENGTHOF(notNFC); ++i) {
582 errorCode=U_ZERO_ERROR; 581 errorCode=U_ZERO_ERROR;
583 if(unorm_isNormalized(notNFC[i], -1, UNORM_NFC, &errorCode) || U_FAILURE (errorCode)) { 582 if(unorm_isNormalized(notNFC[i], -1, UNORM_NFC, &errorCode) || U_FAILURE (errorCode)) {
584 log_data_err("error: isNormalized(notNFC[%d], NFC) is wrong (%s) - ( Are you missing data?)\n", i, u_errorName(errorCode)); 583 log_data_err("error: isNormalized(notNFC[%d], NFC) is wrong (%s) - ( Are you missing data?)\n", i, u_errorName(errorCode));
585 } 584 }
586 errorCode=U_ZERO_ERROR; 585 errorCode=U_ZERO_ERROR;
587 if(unorm_isNormalized(notNFC[i], -1, UNORM_NFKC, &errorCode) || U_FAILUR E(errorCode)) { 586 if(unorm_isNormalized(notNFC[i], -1, UNORM_NFKC, &errorCode) || U_FAILUR E(errorCode)) {
588 log_data_err("error: isNormalized(notNFC[%d], NFKC) is wrong (%s) - (Are you missing data?)\n", i, u_errorName(errorCode)); 587 log_data_err("error: isNormalized(notNFC[%d], NFKC) is wrong (%s) - (Are you missing data?)\n", i, u_errorName(errorCode));
589 } 588 }
590 } 589 }
591 for(i=0; i<LENGTHOF(notNFKC); ++i) { 590 for(i=0; i<UPRV_LENGTHOF(notNFKC); ++i) {
592 errorCode=U_ZERO_ERROR; 591 errorCode=U_ZERO_ERROR;
593 if(unorm_isNormalized(notNFKC[i], -1, UNORM_NFKC, &errorCode) || U_FAILU RE(errorCode)) { 592 if(unorm_isNormalized(notNFKC[i], -1, UNORM_NFKC, &errorCode) || U_FAILU RE(errorCode)) {
594 log_data_err("error: isNormalized(notNFKC[%d], NFKC) is wrong (%s) - (Are you missing data?)\n", i, u_errorName(errorCode)); 593 log_data_err("error: isNormalized(notNFKC[%d], NFKC) is wrong (%s) - (Are you missing data?)\n", i, u_errorName(errorCode));
595 } 594 }
596 } 595 }
597 } 596 }
598 597
599 void TestCheckFCD() 598 void TestCheckFCD()
600 { 599 {
601 UErrorCode status = U_ZERO_ERROR; 600 UErrorCode status = U_ZERO_ERROR;
(...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after
1325 { 0x2128, { 0x007A, 0 } }, 1324 { 0x2128, { 0x007A, 0 } },
1326 { 0x1D5DB, { 0x0068, 0 } }, 1325 { 0x1D5DB, { 0x0068, 0 } },
1327 { 0x1D5ED, { 0x007A, 0 } }, 1326 { 0x1D5ED, { 0x007A, 0 } },
1328 { 0x0061, { 0 } } 1327 { 0x0061, { 0 } }
1329 }; 1328 };
1330 1329
1331 UChar buffer[8]; 1330 UChar buffer[8];
1332 UErrorCode errorCode; 1331 UErrorCode errorCode;
1333 int32_t i, length; 1332 int32_t i, length;
1334 1333
1335 for(i=0; i<LENGTHOF(tests); ++i) { 1334 for(i=0; i<UPRV_LENGTHOF(tests); ++i) {
1336 errorCode=U_ZERO_ERROR; 1335 errorCode=U_ZERO_ERROR;
1337 length=u_getFC_NFKC_Closure(tests[i].c, buffer, LENGTHOF(buffer), &error Code); 1336 length=u_getFC_NFKC_Closure(tests[i].c, buffer, UPRV_LENGTHOF(buffer), & errorCode);
1338 if(U_FAILURE(errorCode) || length!=u_strlen(buffer) || 0!=u_strcmp(tests [i].s, buffer)) { 1337 if(U_FAILURE(errorCode) || length!=u_strlen(buffer) || 0!=u_strcmp(tests [i].s, buffer)) {
1339 log_data_err("u_getFC_NFKC_Closure(U+%04lx) is wrong (%s) - (Are you missing data?)\n", tests[i].c, u_errorName(errorCode)); 1338 log_data_err("u_getFC_NFKC_Closure(U+%04lx) is wrong (%s) - (Are you missing data?)\n", tests[i].c, u_errorName(errorCode));
1340 } 1339 }
1341 } 1340 }
1342 1341
1343 /* error handling */ 1342 /* error handling */
1344 errorCode=U_ZERO_ERROR; 1343 errorCode=U_ZERO_ERROR;
1345 length=u_getFC_NFKC_Closure(0x5c, NULL, LENGTHOF(buffer), &errorCode); 1344 length=u_getFC_NFKC_Closure(0x5c, NULL, UPRV_LENGTHOF(buffer), &errorCode);
1346 if(errorCode!=U_ILLEGAL_ARGUMENT_ERROR) { 1345 if(errorCode!=U_ILLEGAL_ARGUMENT_ERROR) {
1347 log_err("u_getFC_NFKC_Closure(dest=NULL) is wrong (%s)\n", u_errorName(e rrorCode)); 1346 log_err("u_getFC_NFKC_Closure(dest=NULL) is wrong (%s)\n", u_errorName(e rrorCode));
1348 } 1347 }
1349 1348
1350 length=u_getFC_NFKC_Closure(0x5c, buffer, LENGTHOF(buffer), &errorCode); 1349 length=u_getFC_NFKC_Closure(0x5c, buffer, UPRV_LENGTHOF(buffer), &errorCode) ;
1351 if(errorCode!=U_ILLEGAL_ARGUMENT_ERROR) { 1350 if(errorCode!=U_ILLEGAL_ARGUMENT_ERROR) {
1352 log_err("u_getFC_NFKC_Closure(U_FAILURE) is wrong (%s)\n", u_errorName(e rrorCode)); 1351 log_err("u_getFC_NFKC_Closure(U_FAILURE) is wrong (%s)\n", u_errorName(e rrorCode));
1353 } 1352 }
1354 } 1353 }
1355 1354
1356 static void 1355 static void
1357 TestQuickCheckPerCP() { 1356 TestQuickCheckPerCP() {
1358 UErrorCode errorCode; 1357 UErrorCode errorCode;
1359 UChar32 c, lead, trail; 1358 UChar32 c, lead, trail;
1360 UChar s[U16_MAX_LENGTH], nfd[16]; 1359 UChar s[U16_MAX_LENGTH], nfd[16];
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1399 if(qc1!=qc2) { 1398 if(qc1!=qc2) {
1400 log_data_err("u_getIntPropertyValue(NFKC)=%d != %d=unorm_quickCheck( NFKC) for U+%04x - (Are you missing data?)\n", qc1, qc2, c); 1399 log_data_err("u_getIntPropertyValue(NFKC)=%d != %d=unorm_quickCheck( NFKC) for U+%04x - (Are you missing data?)\n", qc1, qc2, c);
1401 } 1400 }
1402 1401
1403 qc1=u_getIntPropertyValue(c, UCHAR_NFKD_QUICK_CHECK); 1402 qc1=u_getIntPropertyValue(c, UCHAR_NFKD_QUICK_CHECK);
1404 qc2=unorm_quickCheck(s, length, UNORM_NFKD, &errorCode); 1403 qc2=unorm_quickCheck(s, length, UNORM_NFKD, &errorCode);
1405 if(qc1!=qc2) { 1404 if(qc1!=qc2) {
1406 log_data_err("u_getIntPropertyValue(NFKD)=%d != %d=unorm_quickCheck( NFKD) for U+%04x - (Are you missing data?)\n", qc1, qc2, c); 1405 log_data_err("u_getIntPropertyValue(NFKD)=%d != %d=unorm_quickCheck( NFKD) for U+%04x - (Are you missing data?)\n", qc1, qc2, c);
1407 } 1406 }
1408 1407
1409 length=unorm_normalize(s, length, UNORM_NFD, 0, nfd, LENGTHOF(nfd), &err orCode); 1408 length=unorm_normalize(s, length, UNORM_NFD, 0, nfd, UPRV_LENGTHOF(nfd), &errorCode);
1410 /* length-length == 0 is used to get around a compiler warning. */ 1409 /* length-length == 0 is used to get around a compiler warning. */
1411 U16_GET(nfd, 0, length-length, length, lead); 1410 U16_GET(nfd, 0, length-length, length, lead);
1412 U16_GET(nfd, 0, length-1, length, trail); 1411 U16_GET(nfd, 0, length-1, length, trail);
1413 1412
1414 lccc1=u_getIntPropertyValue(c, UCHAR_LEAD_CANONICAL_COMBINING_CLASS); 1413 lccc1=u_getIntPropertyValue(c, UCHAR_LEAD_CANONICAL_COMBINING_CLASS);
1415 lccc2=u_getCombiningClass(lead); 1414 lccc2=u_getCombiningClass(lead);
1416 tccc1=u_getIntPropertyValue(c, UCHAR_TRAIL_CANONICAL_COMBINING_CLASS); 1415 tccc1=u_getIntPropertyValue(c, UCHAR_TRAIL_CANONICAL_COMBINING_CLASS);
1417 tccc2=u_getCombiningClass(trail); 1416 tccc2=u_getCombiningClass(trail);
1418 1417
1419 if(lccc1!=lccc2) { 1418 if(lccc1!=lccc2) {
1420 log_err("u_getIntPropertyValue(lccc)=%d != %d=u_getCombiningClass(le ad) for U+%04x\n", 1419 log_data_err("u_getIntPropertyValue(lccc)=%d != %d=u_getCombiningCla ss(lead) for U+%04x\n",
1421 lccc1, lccc2, c); 1420 lccc1, lccc2, c);
1422 } 1421 }
1423 if(tccc1!=tccc2) { 1422 if(tccc1!=tccc2) {
1424 log_err("u_getIntPropertyValue(tccc)=%d != %d=u_getCombiningClass(tr ail) for U+%04x\n", 1423 log_data_err("u_getIntPropertyValue(tccc)=%d != %d=u_getCombiningCla ss(trail) for U+%04x\n",
1425 tccc1, tccc2, c); 1424 tccc1, tccc2, c);
1426 } 1425 }
1427 1426
1428 /* skip some code points */ 1427 /* skip some code points */
1429 c=(20*c)/19+1; 1428 c=(20*c)/19+1;
1430 } 1429 }
1431 } 1430 }
1432 1431
1433 static void 1432 static void
1434 TestComposition(void) { 1433 TestComposition(void) {
(...skipping 14 matching lines...) Expand all
1449 { UNORM_NFC, 0, { 0xac00, 0x0300, 0x0327, 0x11a8 }, { 0xac00, 0x 0327, 0x0300, 0x11a8 } }, 1448 { UNORM_NFC, 0, { 0xac00, 0x0300, 0x0327, 0x11a8 }, { 0xac00, 0x 0327, 0x0300, 0x11a8 } },
1450 { UNORM_NFC, 0, { 0x0b47, 0x0300, 0x0b3e }, { 0x0b47, 0x 0300, 0x0b3e } }, 1449 { UNORM_NFC, 0, { 0x0b47, 0x0300, 0x0b3e }, { 0x0b47, 0x 0300, 0x0b3e } },
1451 1450
1452 /* TODO: add test cases for UNORM_FCC here (j2151) */ 1451 /* TODO: add test cases for UNORM_FCC here (j2151) */
1453 }; 1452 };
1454 1453
1455 UChar output[16]; 1454 UChar output[16];
1456 UErrorCode errorCode; 1455 UErrorCode errorCode;
1457 int32_t i, length; 1456 int32_t i, length;
1458 1457
1459 for(i=0; i<LENGTHOF(cases); ++i) { 1458 for(i=0; i<UPRV_LENGTHOF(cases); ++i) {
1460 errorCode=U_ZERO_ERROR; 1459 errorCode=U_ZERO_ERROR;
1461 length=unorm_normalize( 1460 length=unorm_normalize(
1462 cases[i].input, -1, 1461 cases[i].input, -1,
1463 cases[i].mode, cases[i].options, 1462 cases[i].mode, cases[i].options,
1464 output, LENGTHOF(output), 1463 output, UPRV_LENGTHOF(output),
1465 &errorCode); 1464 &errorCode);
1466 if( U_FAILURE(errorCode) || 1465 if( U_FAILURE(errorCode) ||
1467 length!=u_strlen(cases[i].expect) || 1466 length!=u_strlen(cases[i].expect) ||
1468 0!=u_memcmp(output, cases[i].expect, length) 1467 0!=u_memcmp(output, cases[i].expect, length)
1469 ) { 1468 ) {
1470 log_data_err("unexpected result for case %d - (Are you missing data? )\n", i); 1469 log_data_err("unexpected result for case %d - (Are you missing data? )\n", i);
1471 } 1470 }
1472 } 1471 }
1473 } 1472 }
1474 1473
1475 static void 1474 static void
1476 TestGetDecomposition() { 1475 TestGetDecomposition() {
1477 UChar decomp[32]; 1476 UChar decomp[32];
1478 int32_t length; 1477 int32_t length;
1479 1478
1480 UErrorCode errorCode=U_ZERO_ERROR; 1479 UErrorCode errorCode=U_ZERO_ERROR;
1481 const UNormalizer2 *n2=unorm2_getInstance(NULL, "nfc", UNORM2_COMPOSE_CONTIG UOUS, &errorCode); 1480 const UNormalizer2 *n2=unorm2_getInstance(NULL, "nfc", UNORM2_COMPOSE_CONTIG UOUS, &errorCode);
1482 if(U_FAILURE(errorCode)) { 1481 if(U_FAILURE(errorCode)) {
1483 log_err_status(errorCode, "unorm2_getInstance(nfc/FCC) failed: %s\n", u_ errorName(errorCode)); 1482 log_err_status(errorCode, "unorm2_getInstance(nfc/FCC) failed: %s\n", u_ errorName(errorCode));
1484 return; 1483 return;
1485 } 1484 }
1486 1485
1487 length=unorm2_getDecomposition(n2, 0x20, decomp, LENGTHOF(decomp), &errorCod e); 1486 length=unorm2_getDecomposition(n2, 0x20, decomp, UPRV_LENGTHOF(decomp), &err orCode);
1488 if(U_FAILURE(errorCode) || length>=0) { 1487 if(U_FAILURE(errorCode) || length>=0) {
1489 log_err("unorm2_getDecomposition(fcc, space) failed\n"); 1488 log_err("unorm2_getDecomposition(fcc, space) failed\n");
1490 } 1489 }
1491 errorCode=U_ZERO_ERROR; 1490 errorCode=U_ZERO_ERROR;
1492 length=unorm2_getDecomposition(n2, 0xe4, decomp, LENGTHOF(decomp), &errorCod e); 1491 length=unorm2_getDecomposition(n2, 0xe4, decomp, UPRV_LENGTHOF(decomp), &err orCode);
1493 if(U_FAILURE(errorCode) || length!=2 || decomp[0]!=0x61 || decomp[1]!=0x308 || decomp[2]!=0) { 1492 if(U_FAILURE(errorCode) || length!=2 || decomp[0]!=0x61 || decomp[1]!=0x308 || decomp[2]!=0) {
1494 log_err("unorm2_getDecomposition(fcc, a-umlaut) failed\n"); 1493 log_err("unorm2_getDecomposition(fcc, a-umlaut) failed\n");
1495 } 1494 }
1496 errorCode=U_ZERO_ERROR; 1495 errorCode=U_ZERO_ERROR;
1497 length=unorm2_getDecomposition(n2, 0xac01, decomp, LENGTHOF(decomp), &errorC ode); 1496 length=unorm2_getDecomposition(n2, 0xac01, decomp, UPRV_LENGTHOF(decomp), &e rrorCode);
1498 if(U_FAILURE(errorCode) || length!=3 || decomp[0]!=0x1100 || decomp[1]!=0x11 61 || decomp[2]!=0x11a8 || decomp[3]!=0) { 1497 if(U_FAILURE(errorCode) || length!=3 || decomp[0]!=0x1100 || decomp[1]!=0x11 61 || decomp[2]!=0x11a8 || decomp[3]!=0) {
1499 log_err("unorm2_getDecomposition(fcc, Hangul syllable U+AC01) failed\n") ; 1498 log_err("unorm2_getDecomposition(fcc, Hangul syllable U+AC01) failed\n") ;
1500 } 1499 }
1501 errorCode=U_ZERO_ERROR; 1500 errorCode=U_ZERO_ERROR;
1502 length=unorm2_getDecomposition(n2, 0xac01, NULL, 0, &errorCode); 1501 length=unorm2_getDecomposition(n2, 0xac01, NULL, 0, &errorCode);
1503 if(errorCode!=U_BUFFER_OVERFLOW_ERROR || length!=3) { 1502 if(errorCode!=U_BUFFER_OVERFLOW_ERROR || length!=3) {
1504 log_err("unorm2_getDecomposition(fcc, Hangul syllable U+AC01) overflow f ailed\n"); 1503 log_err("unorm2_getDecomposition(fcc, Hangul syllable U+AC01) overflow f ailed\n");
1505 } 1504 }
1506 errorCode=U_ZERO_ERROR; 1505 errorCode=U_ZERO_ERROR;
1507 length=unorm2_getDecomposition(n2, 0xac01, decomp, -1, &errorCode); 1506 length=unorm2_getDecomposition(n2, 0xac01, decomp, -1, &errorCode);
(...skipping 16 matching lines...) Expand all
1524 const UNormalizer2 *n2=unorm2_getNFKCInstance(&errorCode); 1523 const UNormalizer2 *n2=unorm2_getNFKCInstance(&errorCode);
1525 if(U_FAILURE(errorCode)) { 1524 if(U_FAILURE(errorCode)) {
1526 log_err_status(errorCode, "unorm2_getNFKCInstance() failed: %s\n", u_err orName(errorCode)); 1525 log_err_status(errorCode, "unorm2_getNFKCInstance() failed: %s\n", u_err orName(errorCode));
1527 return; 1526 return;
1528 } 1527 }
1529 /* 1528 /*
1530 * Raw decompositions from NFKC data are the Unicode Decomposition_Mapping v alues, 1529 * Raw decompositions from NFKC data are the Unicode Decomposition_Mapping v alues,
1531 * without recursive decomposition. 1530 * without recursive decomposition.
1532 */ 1531 */
1533 1532
1534 length=unorm2_getRawDecomposition(n2, 0x20, decomp, LENGTHOF(decomp), &error Code); 1533 length=unorm2_getRawDecomposition(n2, 0x20, decomp, UPRV_LENGTHOF(decomp), & errorCode);
1535 if(U_FAILURE(errorCode) || length>=0) { 1534 if(U_FAILURE(errorCode) || length>=0) {
1536 log_err("unorm2_getDecomposition(nfkc, space) failed\n"); 1535 log_err("unorm2_getDecomposition(nfkc, space) failed\n");
1537 } 1536 }
1538 errorCode=U_ZERO_ERROR; 1537 errorCode=U_ZERO_ERROR;
1539 length=unorm2_getRawDecomposition(n2, 0xe4, decomp, LENGTHOF(decomp), &error Code); 1538 length=unorm2_getRawDecomposition(n2, 0xe4, decomp, UPRV_LENGTHOF(decomp), & errorCode);
1540 if(U_FAILURE(errorCode) || length!=2 || decomp[0]!=0x61 || decomp[1]!=0x308 || decomp[2]!=0) { 1539 if(U_FAILURE(errorCode) || length!=2 || decomp[0]!=0x61 || decomp[1]!=0x308 || decomp[2]!=0) {
1541 log_err("unorm2_getDecomposition(nfkc, a-umlaut) failed\n"); 1540 log_err("unorm2_getDecomposition(nfkc, a-umlaut) failed\n");
1542 } 1541 }
1543 /* U+1E08 LATIN CAPITAL LETTER C WITH CEDILLA AND ACUTE */ 1542 /* U+1E08 LATIN CAPITAL LETTER C WITH CEDILLA AND ACUTE */
1544 errorCode=U_ZERO_ERROR; 1543 errorCode=U_ZERO_ERROR;
1545 length=unorm2_getRawDecomposition(n2, 0x1e08, decomp, LENGTHOF(decomp), &err orCode); 1544 length=unorm2_getRawDecomposition(n2, 0x1e08, decomp, UPRV_LENGTHOF(decomp), &errorCode);
1546 if(U_FAILURE(errorCode) || length!=2 || decomp[0]!=0xc7 || decomp[1]!=0x301 || decomp[2]!=0) { 1545 if(U_FAILURE(errorCode) || length!=2 || decomp[0]!=0xc7 || decomp[1]!=0x301 || decomp[2]!=0) {
1547 log_err("unorm2_getDecomposition(nfkc, c-cedilla-acute) failed\n"); 1546 log_err("unorm2_getDecomposition(nfkc, c-cedilla-acute) failed\n");
1548 } 1547 }
1549 /* U+212B ANGSTROM SIGN */ 1548 /* U+212B ANGSTROM SIGN */
1550 errorCode=U_ZERO_ERROR; 1549 errorCode=U_ZERO_ERROR;
1551 length=unorm2_getRawDecomposition(n2, 0x212b, decomp, LENGTHOF(decomp), &err orCode); 1550 length=unorm2_getRawDecomposition(n2, 0x212b, decomp, UPRV_LENGTHOF(decomp), &errorCode);
1552 if(U_FAILURE(errorCode) || length!=1 || decomp[0]!=0xc5 || decomp[1]!=0) { 1551 if(U_FAILURE(errorCode) || length!=1 || decomp[0]!=0xc5 || decomp[1]!=0) {
1553 log_err("unorm2_getDecomposition(nfkc, angstrom sign) failed\n"); 1552 log_err("unorm2_getDecomposition(nfkc, angstrom sign) failed\n");
1554 } 1553 }
1555 errorCode=U_ZERO_ERROR; 1554 errorCode=U_ZERO_ERROR;
1556 length=unorm2_getRawDecomposition(n2, 0xac00, decomp, LENGTHOF(decomp), &err orCode); 1555 length=unorm2_getRawDecomposition(n2, 0xac00, decomp, UPRV_LENGTHOF(decomp), &errorCode);
1557 if(U_FAILURE(errorCode) || length!=2 || decomp[0]!=0x1100 || decomp[1]!=0x11 61 || decomp[2]!=0) { 1556 if(U_FAILURE(errorCode) || length!=2 || decomp[0]!=0x1100 || decomp[1]!=0x11 61 || decomp[2]!=0) {
1558 log_err("unorm2_getDecomposition(nfkc, Hangul syllable U+AC00) failed\n" ); 1557 log_err("unorm2_getDecomposition(nfkc, Hangul syllable U+AC00) failed\n" );
1559 } 1558 }
1560 /* A Hangul LVT syllable has a raw decomposition of an LV syllable + T. */ 1559 /* A Hangul LVT syllable has a raw decomposition of an LV syllable + T. */
1561 errorCode=U_ZERO_ERROR; 1560 errorCode=U_ZERO_ERROR;
1562 length=unorm2_getRawDecomposition(n2, 0xac01, decomp, LENGTHOF(decomp), &err orCode); 1561 length=unorm2_getRawDecomposition(n2, 0xac01, decomp, UPRV_LENGTHOF(decomp), &errorCode);
1563 if(U_FAILURE(errorCode) || length!=2 || decomp[0]!=0xac00 || decomp[1]!=0x11 a8 || decomp[2]!=0) { 1562 if(U_FAILURE(errorCode) || length!=2 || decomp[0]!=0xac00 || decomp[1]!=0x11 a8 || decomp[2]!=0) {
1564 log_err("unorm2_getDecomposition(nfkc, Hangul syllable U+AC01) failed\n" ); 1563 log_err("unorm2_getDecomposition(nfkc, Hangul syllable U+AC01) failed\n" );
1565 } 1564 }
1566 errorCode=U_ZERO_ERROR; 1565 errorCode=U_ZERO_ERROR;
1567 length=unorm2_getRawDecomposition(n2, 0xac01, NULL, 0, &errorCode); 1566 length=unorm2_getRawDecomposition(n2, 0xac01, NULL, 0, &errorCode);
1568 if(errorCode!=U_BUFFER_OVERFLOW_ERROR || length!=2) { 1567 if(errorCode!=U_BUFFER_OVERFLOW_ERROR || length!=2) {
1569 log_err("unorm2_getDecomposition(nfkc, Hangul syllable U+AC01) overflow failed\n"); 1568 log_err("unorm2_getDecomposition(nfkc, Hangul syllable U+AC01) overflow failed\n");
1570 } 1569 }
1571 errorCode=U_ZERO_ERROR; 1570 errorCode=U_ZERO_ERROR;
1572 length=unorm2_getRawDecomposition(n2, 0xac01, decomp, -1, &errorCode); 1571 length=unorm2_getRawDecomposition(n2, 0xac01, decomp, -1, &errorCode);
(...skipping 20 matching lines...) Expand all
1593 log_err_status(errorCode, "unorm2_getNFCInstance() failed: %s\n", u_erro rName(errorCode)); 1592 log_err_status(errorCode, "unorm2_getNFCInstance() failed: %s\n", u_erro rName(errorCode));
1594 return; 1593 return;
1595 } 1594 }
1596 /* 1595 /*
1597 * Use length=-1 to fool the estimate of the ReorderingBuffer capacity. 1596 * Use length=-1 to fool the estimate of the ReorderingBuffer capacity.
1598 * Use a capacity of 6 or 7 so that the middle sequence <41 327 30A> 1597 * Use a capacity of 6 or 7 so that the middle sequence <41 327 30A>
1599 * still fits into a[] but the full result still overflows this capacity. 1598 * still fits into a[] but the full result still overflows this capacity.
1600 * (Let it modify the destination buffer before reallocating internally.) 1599 * (Let it modify the destination buffer before reallocating internally.)
1601 */ 1600 */
1602 length=unorm2_append(n2, a, -1, 6, b, -1, &errorCode); 1601 length=unorm2_append(n2, a, -1, 6, b, -1, &errorCode);
1603 if(errorCode!=U_BUFFER_OVERFLOW_ERROR || length!=LENGTHOF(expected)) { 1602 if(errorCode!=U_BUFFER_OVERFLOW_ERROR || length!=UPRV_LENGTHOF(expected)) {
1604 log_err("unorm2_append(preflight) returned wrong length of %d\n", (int)l ength); 1603 log_err("unorm2_append(preflight) returned wrong length of %d\n", (int)l ength);
1605 return; 1604 return;
1606 } 1605 }
1607 /* Verify that the middle is unchanged or restored. (ICU ticket #7848) */ 1606 /* Verify that the middle is unchanged or restored. (ICU ticket #7848) */
1608 if(a[0]!=0x61 || a[1]!=0x62 || a[2]!=0x63 || a[3]!=0x41 || a[4]!=0x327 || a[ 5]!=0) { 1607 if(a[0]!=0x61 || a[1]!=0x62 || a[2]!=0x63 || a[3]!=0x41 || a[4]!=0x327 || a[ 5]!=0) {
1609 log_err("unorm2_append(overflow) modified the first string\n"); 1608 log_err("unorm2_append(overflow) modified the first string\n");
1610 return; 1609 return;
1611 } 1610 }
1612 errorCode=U_ZERO_ERROR; 1611 errorCode=U_ZERO_ERROR;
1613 length=unorm2_append(n2, a, -1, LENGTHOF(a), b, -1, &errorCode); 1612 length=unorm2_append(n2, a, -1, UPRV_LENGTHOF(a), b, -1, &errorCode);
1614 if(U_FAILURE(errorCode) || length!=LENGTHOF(expected) || 0!=u_memcmp(a, expe cted, length)) { 1613 if(U_FAILURE(errorCode) || length!=UPRV_LENGTHOF(expected) || 0!=u_memcmp(a, expected, length)) {
1615 log_err("unorm2_append(real) failed - %s, length %d\n", u_errorName(erro rCode), (int)length); 1614 log_err("unorm2_append(real) failed - %s, length %d\n", u_errorName(erro rCode), (int)length);
1616 return; 1615 return;
1617 } 1616 }
1618 } 1617 }
1619 1618
1620 static void 1619 static void
1621 TestGetEasyToUseInstance() { 1620 TestGetEasyToUseInstance() {
1622 static const UChar in[]={ 1621 static const UChar in[]={
1623 0xA0, /* -> <noBreak> 0020 */ 1622 0xA0, /* -> <noBreak> 0020 */
1624 0xC7, 0x301 /* = 1E08 = 0043 0327 0301 */ 1623 0xC7, 0x301 /* = 1E08 = 0043 0327 0301 */
1625 }; 1624 };
1626 UChar out[32]; 1625 UChar out[32];
1627 int32_t length; 1626 int32_t length;
1628 1627
1629 UErrorCode errorCode=U_ZERO_ERROR; 1628 UErrorCode errorCode=U_ZERO_ERROR;
1630 const UNormalizer2 *n2=unorm2_getNFCInstance(&errorCode); 1629 const UNormalizer2 *n2=unorm2_getNFCInstance(&errorCode);
1631 if(U_FAILURE(errorCode)) { 1630 if(U_FAILURE(errorCode)) {
1632 log_err_status(errorCode, "unorm2_getNFCInstance() failed: %s\n", u_erro rName(errorCode)); 1631 log_err_status(errorCode, "unorm2_getNFCInstance() failed: %s\n", u_erro rName(errorCode));
1633 return; 1632 return;
1634 } 1633 }
1635 length=unorm2_normalize(n2, in, LENGTHOF(in), out, LENGTHOF(out), &errorCode ); 1634 length=unorm2_normalize(n2, in, UPRV_LENGTHOF(in), out, UPRV_LENGTHOF(out), &errorCode);
1636 if(U_FAILURE(errorCode) || length!=2 || out[0]!=0xa0 || out[1]!=0x1e08) { 1635 if(U_FAILURE(errorCode) || length!=2 || out[0]!=0xa0 || out[1]!=0x1e08) {
1637 log_err("unorm2_getNFCInstance() did not return an NFC instance (normali zed length=%d; %s)\n", 1636 log_err("unorm2_getNFCInstance() did not return an NFC instance (normali zed length=%d; %s)\n",
1638 (int)length, u_errorName(errorCode)); 1637 (int)length, u_errorName(errorCode));
1639 } 1638 }
1640 1639
1641 errorCode=U_ZERO_ERROR; 1640 errorCode=U_ZERO_ERROR;
1642 n2=unorm2_getNFDInstance(&errorCode); 1641 n2=unorm2_getNFDInstance(&errorCode);
1643 if(U_FAILURE(errorCode)) { 1642 if(U_FAILURE(errorCode)) {
1644 log_err_status(errorCode, "unorm2_getNFDInstance() failed: %s\n", u_erro rName(errorCode)); 1643 log_err_status(errorCode, "unorm2_getNFDInstance() failed: %s\n", u_erro rName(errorCode));
1645 return; 1644 return;
1646 } 1645 }
1647 length=unorm2_normalize(n2, in, LENGTHOF(in), out, LENGTHOF(out), &errorCode ); 1646 length=unorm2_normalize(n2, in, UPRV_LENGTHOF(in), out, UPRV_LENGTHOF(out), &errorCode);
1648 if(U_FAILURE(errorCode) || length!=4 || out[0]!=0xa0 || out[1]!=0x43 || out[ 2]!=0x327 || out[3]!=0x301) { 1647 if(U_FAILURE(errorCode) || length!=4 || out[0]!=0xa0 || out[1]!=0x43 || out[ 2]!=0x327 || out[3]!=0x301) {
1649 log_err("unorm2_getNFDInstance() did not return an NFD instance (normali zed length=%d; %s)\n", 1648 log_err("unorm2_getNFDInstance() did not return an NFD instance (normali zed length=%d; %s)\n",
1650 (int)length, u_errorName(errorCode)); 1649 (int)length, u_errorName(errorCode));
1651 } 1650 }
1652 1651
1653 errorCode=U_ZERO_ERROR; 1652 errorCode=U_ZERO_ERROR;
1654 n2=unorm2_getNFKCInstance(&errorCode); 1653 n2=unorm2_getNFKCInstance(&errorCode);
1655 if(U_FAILURE(errorCode)) { 1654 if(U_FAILURE(errorCode)) {
1656 log_err_status(errorCode, "unorm2_getNFKCInstance() failed: %s\n", u_err orName(errorCode)); 1655 log_err_status(errorCode, "unorm2_getNFKCInstance() failed: %s\n", u_err orName(errorCode));
1657 return; 1656 return;
1658 } 1657 }
1659 length=unorm2_normalize(n2, in, LENGTHOF(in), out, LENGTHOF(out), &errorCode ); 1658 length=unorm2_normalize(n2, in, UPRV_LENGTHOF(in), out, UPRV_LENGTHOF(out), &errorCode);
1660 if(U_FAILURE(errorCode) || length!=2 || out[0]!=0x20 || out[1]!=0x1e08) { 1659 if(U_FAILURE(errorCode) || length!=2 || out[0]!=0x20 || out[1]!=0x1e08) {
1661 log_err("unorm2_getNFKCInstance() did not return an NFKC instance (norma lized length=%d; %s)\n", 1660 log_err("unorm2_getNFKCInstance() did not return an NFKC instance (norma lized length=%d; %s)\n",
1662 (int)length, u_errorName(errorCode)); 1661 (int)length, u_errorName(errorCode));
1663 } 1662 }
1664 1663
1665 errorCode=U_ZERO_ERROR; 1664 errorCode=U_ZERO_ERROR;
1666 n2=unorm2_getNFKDInstance(&errorCode); 1665 n2=unorm2_getNFKDInstance(&errorCode);
1667 if(U_FAILURE(errorCode)) { 1666 if(U_FAILURE(errorCode)) {
1668 log_err_status(errorCode, "unorm2_getNFKDInstance() failed: %s\n", u_err orName(errorCode)); 1667 log_err_status(errorCode, "unorm2_getNFKDInstance() failed: %s\n", u_err orName(errorCode));
1669 return; 1668 return;
1670 } 1669 }
1671 length=unorm2_normalize(n2, in, LENGTHOF(in), out, LENGTHOF(out), &errorCode ); 1670 length=unorm2_normalize(n2, in, UPRV_LENGTHOF(in), out, UPRV_LENGTHOF(out), &errorCode);
1672 if(U_FAILURE(errorCode) || length!=4 || out[0]!=0x20 || out[1]!=0x43 || out[ 2]!=0x327 || out[3]!=0x301) { 1671 if(U_FAILURE(errorCode) || length!=4 || out[0]!=0x20 || out[1]!=0x43 || out[ 2]!=0x327 || out[3]!=0x301) {
1673 log_err("unorm2_getNFKDInstance() did not return an NFKD instance (norma lized length=%d; %s)\n", 1672 log_err("unorm2_getNFKDInstance() did not return an NFKD instance (norma lized length=%d; %s)\n",
1674 (int)length, u_errorName(errorCode)); 1673 (int)length, u_errorName(errorCode));
1675 } 1674 }
1676 1675
1677 errorCode=U_ZERO_ERROR; 1676 errorCode=U_ZERO_ERROR;
1678 n2=unorm2_getNFKCCasefoldInstance(&errorCode); 1677 n2=unorm2_getNFKCCasefoldInstance(&errorCode);
1679 if(U_FAILURE(errorCode)) { 1678 if(U_FAILURE(errorCode)) {
1680 log_err_status(errorCode, "unorm2_getNFKCCasefoldInstance() failed: %s\n ", u_errorName(errorCode)); 1679 log_err_status(errorCode, "unorm2_getNFKCCasefoldInstance() failed: %s\n ", u_errorName(errorCode));
1681 return; 1680 return;
1682 } 1681 }
1683 length=unorm2_normalize(n2, in, LENGTHOF(in), out, LENGTHOF(out), &errorCode ); 1682 length=unorm2_normalize(n2, in, UPRV_LENGTHOF(in), out, UPRV_LENGTHOF(out), &errorCode);
1684 if(U_FAILURE(errorCode) || length!=2 || out[0]!=0x20 || out[1]!=0x1e09) { 1683 if(U_FAILURE(errorCode) || length!=2 || out[0]!=0x20 || out[1]!=0x1e09) {
1685 log_err("unorm2_getNFKCCasefoldInstance() did not return an NFKC_Casefol d instance (normalized length=%d; %s)\n", 1684 log_err("unorm2_getNFKCCasefoldInstance() did not return an NFKC_Casefol d instance (normalized length=%d; %s)\n",
1686 (int)length, u_errorName(errorCode)); 1685 (int)length, u_errorName(errorCode));
1687 } 1686 }
1688 } 1687 }
1689 1688
1690 #endif /* #if !UCONFIG_NO_NORMALIZATION */ 1689 #endif /* #if !UCONFIG_NO_NORMALIZATION */
OLDNEW
« no previous file with comments | « source/test/cintltst/cnmdptst.c ('k') | source/test/cintltst/cnumtst.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698