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

Side by Side Diff: source/test/cintltst/ucnvseltst.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/trie2test.c ('k') | source/test/cintltst/udatatst.c » ('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 (c) 1997-2011, International Business Machines 2 * Copyright (c) 1997-2014, International Business Machines
3 * Corporation and others. All Rights Reserved. 3 * Corporation and others. All Rights Reserved.
4 ******************************************************************** 4 ********************************************************************
5 * 5 *
6 * File UCNVSELTST.C 6 * File UCNVSELTST.C
7 * 7 *
8 * Modification History: 8 * Modification History:
9 * Name Description 9 * Name Description
10 * MOHAMED ELDAWY Creation 10 * MOHAMED ELDAWY Creation
11 ******************************************************************** 11 ********************************************************************
12 */ 12 */
13 13
14 /* C API AND FUNCTIONALITY TEST FOR CONVERTER SELECTOR (ucnvsel.h)*/ 14 /* C API AND FUNCTIONALITY TEST FOR CONVERTER SELECTOR (ucnvsel.h)*/
15 15
16 #include "ucnvseltst.h" 16 #include "ucnvseltst.h"
17 17
18 #include <stdio.h> 18 #include <stdio.h>
19 19
20 #include "unicode/utypes.h" 20 #include "unicode/utypes.h"
21 #include "unicode/ucnvsel.h" 21 #include "unicode/ucnvsel.h"
22 #include "unicode/ustring.h" 22 #include "unicode/ustring.h"
23 #include "cmemory.h" 23 #include "cmemory.h"
24 #include "cstring.h" 24 #include "cstring.h"
25 #include "propsvec.h" 25 #include "propsvec.h"
26 26
27 #define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
28
29 #define FILENAME_BUFFER 1024 27 #define FILENAME_BUFFER 1024
30 28
31 #define TDSRCPATH ".." U_FILE_SEP_STRING "test" U_FILE_SEP_STRING "testdata" U_ FILE_SEP_STRING 29 #define TDSRCPATH ".." U_FILE_SEP_STRING "test" U_FILE_SEP_STRING "testdata" U_ FILE_SEP_STRING
32 30
33 static void TestSelector(void); 31 static void TestSelector(void);
34 static void TestUPropsVector(void); 32 static void TestUPropsVector(void);
35 void addCnvSelTest(TestNode** root); /* Declaration required to suppress compil er warnings. */ 33 void addCnvSelTest(TestNode** root); /* Declaration required to suppress compil er warnings. */
36 34
37 void addCnvSelTest(TestNode** root) 35 void addCnvSelTest(TestNode** root)
38 { 36 {
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 } 384 }
387 if (!text_open(&text)) { 385 if (!text_open(&text)) {
388 releaseAvailableNames();; 386 releaseAvailableNames();;
389 } 387 }
390 388
391 excluded_sets[0] = uset_openEmpty(); 389 excluded_sets[0] = uset_openEmpty();
392 for(i = 1 ; i < 3 ; i++) { 390 for(i = 1 ; i < 3 ; i++) {
393 excluded_sets[i] = uset_open(i*30, i*30+500); 391 excluded_sets[i] = uset_open(i*30, i*30+500);
394 } 392 }
395 393
396 for(testCaseIdx = 0; testCaseIdx < LENGTHOF(getEncodingsFns); testCaseIdx++) 394 for(testCaseIdx = 0; testCaseIdx < UPRV_LENGTHOF(getEncodingsFns); testCaseIdx ++)
397 { 395 {
398 int32_t excluded_set_id; 396 int32_t excluded_set_id;
399 int32_t num_encodings; 397 int32_t num_encodings;
400 const char **encodings = getEncodingsFns[testCaseIdx](&num_encodings); 398 const char **encodings = getEncodingsFns[testCaseIdx](&num_encodings);
401 if (getTestOption(QUICK_OPTION) && num_encodings > 25) { 399 if (getTestOption(QUICK_OPTION) && num_encodings > 25) {
402 uprv_free((void *)encodings); 400 uprv_free((void *)encodings);
403 continue; 401 continue;
404 } 402 }
405 403
406 /* 404 /*
407 * for(excluded_set_id = 0 ; excluded_set_id < 3 ; excluded_set_id++) 405 * for(excluded_set_id = 0 ; excluded_set_id < 3 ; excluded_set_id++)
408 * 406 *
409 * This loop was replaced by the following statement because 407 * This loop was replaced by the following statement because
410 * the loop made the test run longer without adding to the code coverage. 408 * the loop made the test run longer without adding to the code coverage.
411 * The handling of the exclusion set is independent of the 409 * The handling of the exclusion set is independent of the
412 * set of encodings, so there is no need to test every combination. 410 * set of encodings, so there is no need to test every combination.
413 */ 411 */
414 excluded_set_id = testCaseIdx % LENGTHOF(excluded_sets); 412 excluded_set_id = testCaseIdx % UPRV_LENGTHOF(excluded_sets);
415 { 413 {
416 UConverterSelector *sel_rt, *sel_fb; 414 UConverterSelector *sel_rt, *sel_fb;
417 char *buffer_fb = NULL; 415 char *buffer_fb = NULL;
418 UErrorCode status = U_ZERO_ERROR; 416 UErrorCode status = U_ZERO_ERROR;
419 sel_rt = ucnvsel_open(encodings, num_encodings, 417 sel_rt = ucnvsel_open(encodings, num_encodings,
420 excluded_sets[excluded_set_id], 418 excluded_sets[excluded_set_id],
421 UCNV_ROUNDTRIP_SET, &status); 419 UCNV_ROUNDTRIP_SET, &status);
422 if (num_encodings == gCountAvailable) { 420 if (num_encodings == gCountAvailable) {
423 /* test the special "all converters" parameter values */ 421 /* test the special "all converters" parameter values */
424 sel_fb = ucnvsel_open(NULL, 0, 422 sel_fb = ucnvsel_open(NULL, 0,
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 excluded_sets[excluded_set_id], 460 excluded_sets[excluded_set_id],
463 UCNV_ROUNDTRIP_AND_FALLBACK_SET); 461 UCNV_ROUNDTRIP_AND_FALLBACK_SET);
464 /* UTF-8 with length */ 462 /* UTF-8 with length */
465 status = U_ZERO_ERROR; 463 status = U_ZERO_ERROR;
466 verifyResult(ucnvsel_selectForUTF8(sel_rt, s, length8, &status), manual_ rt); 464 verifyResult(ucnvsel_selectForUTF8(sel_rt, s, length8, &status), manual_ rt);
467 verifyResult(ucnvsel_selectForUTF8(sel_fb, s, length8, &status), manual_ fb); 465 verifyResult(ucnvsel_selectForUTF8(sel_fb, s, length8, &status), manual_ fb);
468 /* UTF-8 NUL-terminated */ 466 /* UTF-8 NUL-terminated */
469 verifyResult(ucnvsel_selectForUTF8(sel_rt, s, -1, &status), manual_rt); 467 verifyResult(ucnvsel_selectForUTF8(sel_rt, s, -1, &status), manual_rt);
470 verifyResult(ucnvsel_selectForUTF8(sel_fb, s, -1, &status), manual_fb); 468 verifyResult(ucnvsel_selectForUTF8(sel_fb, s, -1, &status), manual_fb);
471 469
472 u_strFromUTF8(utf16, LENGTHOF(utf16), &length16, s, length8, &status); 470 u_strFromUTF8(utf16, UPRV_LENGTHOF(utf16), &length16, s, length8, &statu s);
473 if (U_FAILURE(status)) { 471 if (U_FAILURE(status)) {
474 log_err("error converting the test text (string %ld) to UTF-16 - %s\n" , 472 log_err("error converting the test text (string %ld) to UTF-16 - %s\n" ,
475 (long)text.number, u_errorName(status)); 473 (long)text.number, u_errorName(status));
476 } else { 474 } else {
477 if (text.number == 0) { 475 if (text.number == 0) {
478 sel_fb = serializeAndUnserialize(sel_fb, &buffer_fb, &status); 476 sel_fb = serializeAndUnserialize(sel_fb, &buffer_fb, &status);
479 } 477 }
480 if (U_SUCCESS(status)) { 478 if (U_SUCCESS(status)) {
481 /* UTF-16 with length */ 479 /* UTF-16 with length */
482 verifyResult(ucnvsel_selectForString(sel_rt, utf16, length16, &statu s), manual_rt); 480 verifyResult(ucnvsel_selectForString(sel_rt, utf16, length16, &statu s), manual_rt);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 } 528 }
531 if (upvec_getRow(pv, 0, NULL, NULL) == NULL) { 529 if (upvec_getRow(pv, 0, NULL, NULL) == NULL) {
532 log_err("upvec_getRow should not return NULL.\n"); 530 log_err("upvec_getRow should not return NULL.\n");
533 } 531 }
534 if (upvec_getArray(pv, NULL, NULL) != NULL) { 532 if (upvec_getArray(pv, NULL, NULL) != NULL) {
535 log_err("upvec_getArray should return NULL.\n"); 533 log_err("upvec_getArray should return NULL.\n");
536 } 534 }
537 535
538 upvec_close(pv); 536 upvec_close(pv);
539 } 537 }
OLDNEW
« no previous file with comments | « source/test/cintltst/trie2test.c ('k') | source/test/cintltst/udatatst.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698