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

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

Issue 1621843002: ICU 56 update step 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/icu.git@561
Patch Set: Created 4 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/ncnvtst.c ('k') | source/test/cintltst/reapits.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: 2 * COPYRIGHT:
3 * Copyright (c) 1997-2014, International Business Machines Corporation and 3 * Copyright (c) 1997-2015, International Business Machines Corporation and
4 * others. All Rights Reserved. 4 * others. All Rights Reserved.
5 ********************************************************************/ 5 ********************************************************************/
6 /******************************************************************************* 6 /*******************************************************************************
7 * 7 *
8 * File CCONVTST.C 8 * File nucnvtst.c
9 * 9 *
10 * Modification History: 10 * Modification History:
11 * Name Description 11 * Name Description
12 * Steven R. Loomis 7/8/1999 Adding input buffer test 12 * Steven R. Loomis 7/8/1999 Adding input buffer test
13 ******************************************************************************** 13 ********************************************************************************
14 */ 14 */
15 #include <stdio.h> 15 #include <stdio.h>
16 #include "cstring.h" 16 #include "cstring.h"
17 #include "unicode/uloc.h" 17 #include "unicode/uloc.h"
18 #include "unicode/ucnv.h" 18 #include "unicode/ucnv.h"
(...skipping 1802 matching lines...) Expand 10 before | Expand all | Expand 10 after
1821 1, 0x21, 1821 1, 0x21,
1822 2, 0x2b, 1822 2, 0x2b,
1823 7, 0x10401 1823 7, 0x10401
1824 }; 1824 };
1825 1825
1826 const char *cnvName; 1826 const char *cnvName;
1827 const char *source=(const char *)in, *limit=(const char *)in+sizeof(in); 1827 const char *source=(const char *)in, *limit=(const char *)in+sizeof(in);
1828 UErrorCode errorCode=U_ZERO_ERROR; 1828 UErrorCode errorCode=U_ZERO_ERROR;
1829 UConverter *cnv=ucnv_open("UTF-7", &errorCode); 1829 UConverter *cnv=ucnv_open("UTF-7", &errorCode);
1830 if(U_FAILURE(errorCode)) { 1830 if(U_FAILURE(errorCode)) {
1831 log_err("Unable to open a UTF-7 converter: %s\n", u_errorName(errorCode) ); /* sholdn't be a data err */ 1831 log_data_err("Unable to open a UTF-7 converter: %s\n", u_errorName(error Code));
1832 return; 1832 return;
1833 } 1833 }
1834 TestNextUChar(cnv, source, limit, results, "UTF-7"); 1834 TestNextUChar(cnv, source, limit, results, "UTF-7");
1835 /* Test the condition when source >= sourceLimit */ 1835 /* Test the condition when source >= sourceLimit */
1836 TestNextUCharError(cnv, source, source, U_INDEX_OUTOFBOUNDS_ERROR, "sourceLi mit <= source"); 1836 TestNextUCharError(cnv, source, source, U_INDEX_OUTOFBOUNDS_ERROR, "sourceLi mit <= source");
1837 cnvName = ucnv_getName(cnv, &errorCode); 1837 cnvName = ucnv_getName(cnv, &errorCode);
1838 if (U_FAILURE(errorCode) || uprv_strcmp(cnvName, "UTF-7") != 0) { 1838 if (U_FAILURE(errorCode) || uprv_strcmp(cnvName, "UTF-7") != 0) {
1839 log_err("UTF-7 converter is called %s: %s\n", cnvName, u_errorName(error Code)); 1839 log_err("UTF-7 converter is called %s: %s\n", cnvName, u_errorName(error Code));
1840 } 1840 }
1841 ucnv_close(cnv); 1841 ucnv_close(cnv);
(...skipping 22 matching lines...) Expand all
1864 1, 0x21, 1864 1, 0x21,
1865 2, 0x26, 1865 2, 0x26,
1866 7, 0x10401 1866 7, 0x10401
1867 }; 1867 };
1868 1868
1869 const char *cnvName; 1869 const char *cnvName;
1870 const char *source=(const char *)in, *limit=(const char *)in+sizeof(in); 1870 const char *source=(const char *)in, *limit=(const char *)in+sizeof(in);
1871 UErrorCode errorCode=U_ZERO_ERROR; 1871 UErrorCode errorCode=U_ZERO_ERROR;
1872 UConverter *cnv=ucnv_open("IMAP-mailbox-name", &errorCode); 1872 UConverter *cnv=ucnv_open("IMAP-mailbox-name", &errorCode);
1873 if(U_FAILURE(errorCode)) { 1873 if(U_FAILURE(errorCode)) {
1874 log_err("Unable to open a IMAP-mailbox-name converter: %s\n", u_errorNam e(errorCode)); /* sholdn't be a data err */ 1874 log_data_err("Unable to open a IMAP-mailbox-name converter: %s\n", u_err orName(errorCode));
1875 return; 1875 return;
1876 } 1876 }
1877 TestNextUChar(cnv, source, limit, results, "IMAP-mailbox-name"); 1877 TestNextUChar(cnv, source, limit, results, "IMAP-mailbox-name");
1878 /* Test the condition when source >= sourceLimit */ 1878 /* Test the condition when source >= sourceLimit */
1879 TestNextUCharError(cnv, source, source, U_INDEX_OUTOFBOUNDS_ERROR, "sourceLi mit <= source"); 1879 TestNextUCharError(cnv, source, source, U_INDEX_OUTOFBOUNDS_ERROR, "sourceLi mit <= source");
1880 cnvName = ucnv_getName(cnv, &errorCode); 1880 cnvName = ucnv_getName(cnv, &errorCode);
1881 if (U_FAILURE(errorCode) || uprv_strcmp(cnvName, "IMAP-mailbox-name") != 0) { 1881 if (U_FAILURE(errorCode) || uprv_strcmp(cnvName, "IMAP-mailbox-name") != 0) {
1882 log_err("IMAP-mailbox-name converter is called %s: %s\n", cnvName, u_err orName(errorCode)); 1882 log_err("IMAP-mailbox-name converter is called %s: %s\n", cnvName, u_err orName(errorCode));
1883 } 1883 }
1884 ucnv_close(cnv); 1884 ucnv_close(cnv);
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
1997 34, 0x62 1997 34, 0x62
1998 }; 1998 };
1999 1999
2000 UConverterToUCallback cb; 2000 UConverterToUCallback cb;
2001 const void *p; 2001 const void *p;
2002 2002
2003 const char *source=(const char *)in,*limit=(const char *)in+sizeof(in); 2003 const char *source=(const char *)in,*limit=(const char *)in+sizeof(in);
2004 UErrorCode errorCode=U_ZERO_ERROR; 2004 UErrorCode errorCode=U_ZERO_ERROR;
2005 UConverter *cnv=ucnv_open("CESU-8", &errorCode); 2005 UConverter *cnv=ucnv_open("CESU-8", &errorCode);
2006 if(U_FAILURE(errorCode)) { 2006 if(U_FAILURE(errorCode)) {
2007 log_err("Unable to open a CESU-8 converter: %s\n", u_errorName(errorCode )); 2007 log_data_err("Unable to open a CESU-8 converter: %s\n", u_errorName(erro rCode));
2008 return; 2008 return;
2009 } 2009 }
2010 TestNextUChar(cnv, source, limit, results, "CESU-8"); 2010 TestNextUChar(cnv, source, limit, results, "CESU-8");
2011 /* Test the condition when source >= sourceLimit */ 2011 /* Test the condition when source >= sourceLimit */
2012 TestNextUCharError(cnv, source, source, U_INDEX_OUTOFBOUNDS_ERROR, "sourceLi mit <= source"); 2012 TestNextUCharError(cnv, source, source, U_INDEX_OUTOFBOUNDS_ERROR, "sourceLi mit <= source");
2013 2013
2014 /* test error behavior with a skip callback */ 2014 /* test error behavior with a skip callback */
2015 ucnv_setToUCallBack(cnv, UCNV_TO_U_CALLBACK_SKIP, NULL, &cb, &p, &errorCode) ; 2015 ucnv_setToUCallBack(cnv, UCNV_TO_U_CALLBACK_SKIP, NULL, &cb, &p, &errorCode) ;
2016 source=(const char *)in2; 2016 source=(const char *)in2;
2017 limit=(const char *)(in2+sizeof(in2)); 2017 limit=(const char *)(in2+sizeof(in2));
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
2217 4, 0x100f00, 2217 4, 0x100f00,
2218 4, 0xfffd, /* unmatched surrogate */ 2218 4, 0xfffd, /* unmatched surrogate */
2219 4, 0xfffd /* unmatched surrogate */ 2219 4, 0xfffd /* unmatched surrogate */
2220 }; 2220 };
2221 2221
2222 const char *source, *limit; 2222 const char *source, *limit;
2223 2223
2224 UErrorCode errorCode=U_ZERO_ERROR; 2224 UErrorCode errorCode=U_ZERO_ERROR;
2225 UConverter *cnv=ucnv_open("UTF-32", &errorCode); 2225 UConverter *cnv=ucnv_open("UTF-32", &errorCode);
2226 if(U_FAILURE(errorCode)) { 2226 if(U_FAILURE(errorCode)) {
2227 log_err("Unable to open a UTF-32 converter: %s\n", u_errorName(errorCode )); 2227 log_data_err("Unable to open a UTF-32 converter: %s\n", u_errorName(erro rCode));
2228 return; 2228 return;
2229 } 2229 }
2230 2230
2231 source=(const char *)in1, limit=(const char *)in1+sizeof(in1); 2231 source=(const char *)in1, limit=(const char *)in1+sizeof(in1);
2232 TestNextUChar(cnv, source, limit, results1, "UTF-32"); 2232 TestNextUChar(cnv, source, limit, results1, "UTF-32");
2233 2233
2234 source=(const char *)in2, limit=(const char *)in2+sizeof(in2); 2234 source=(const char *)in2, limit=(const char *)in2+sizeof(in2);
2235 ucnv_resetToUnicode(cnv); 2235 ucnv_resetToUnicode(cnv);
2236 TestNextUChar(cnv, source, limit, results2, "UTF-32"); 2236 TestNextUChar(cnv, source, limit, results2, "UTF-32");
2237 2237
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
2293 4, 0x262 2293 4, 0x262
2294 }; 2294 };
2295 2295
2296 UConverterToUCallback cb; 2296 UConverterToUCallback cb;
2297 const void *p; 2297 const void *p;
2298 2298
2299 const char *source=(const char *)in, *limit=(const char *)in+sizeof(in); 2299 const char *source=(const char *)in, *limit=(const char *)in+sizeof(in);
2300 UErrorCode errorCode=U_ZERO_ERROR; 2300 UErrorCode errorCode=U_ZERO_ERROR;
2301 UConverter *cnv=ucnv_open("UTF-32BE", &errorCode); 2301 UConverter *cnv=ucnv_open("UTF-32BE", &errorCode);
2302 if(U_FAILURE(errorCode)) { 2302 if(U_FAILURE(errorCode)) {
2303 log_err("Unable to open a UTF-32BE converter: %s\n", u_errorName(errorCo de)); 2303 log_data_err("Unable to open a UTF-32BE converter: %s\n", u_errorName(er rorCode));
2304 return; 2304 return;
2305 } 2305 }
2306 TestNextUChar(cnv, source, limit, results, "UTF-32BE"); 2306 TestNextUChar(cnv, source, limit, results, "UTF-32BE");
2307 2307
2308 /* Test the condition when source >= sourceLimit */ 2308 /* Test the condition when source >= sourceLimit */
2309 TestNextUCharError(cnv, source, source, U_INDEX_OUTOFBOUNDS_ERROR, "sourceLi mit <= source"); 2309 TestNextUCharError(cnv, source, source, U_INDEX_OUTOFBOUNDS_ERROR, "sourceLi mit <= source");
2310 2310
2311 /* test error behavior with a skip callback */ 2311 /* test error behavior with a skip callback */
2312 ucnv_setToUCallBack(cnv, UCNV_TO_U_CALLBACK_SKIP, NULL, &cb, &p, &errorCode) ; 2312 ucnv_setToUCallBack(cnv, UCNV_TO_U_CALLBACK_SKIP, NULL, &cb, &p, &errorCode) ;
2313 source=(const char *)in2; 2313 source=(const char *)in2;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
2364 4, 0x262, 2364 4, 0x262,
2365 }; 2365 };
2366 2366
2367 UConverterToUCallback cb; 2367 UConverterToUCallback cb;
2368 const void *p; 2368 const void *p;
2369 2369
2370 const char *source=(const char *)in, *limit=(const char *)in+sizeof(in); 2370 const char *source=(const char *)in, *limit=(const char *)in+sizeof(in);
2371 UErrorCode errorCode=U_ZERO_ERROR; 2371 UErrorCode errorCode=U_ZERO_ERROR;
2372 UConverter *cnv=ucnv_open("UTF-32LE", &errorCode); 2372 UConverter *cnv=ucnv_open("UTF-32LE", &errorCode);
2373 if(U_FAILURE(errorCode)) { 2373 if(U_FAILURE(errorCode)) {
2374 log_err("Unable to open a UTF-32LE converter: %s\n", u_errorName(errorCo de)); 2374 log_data_err("Unable to open a UTF-32LE converter: %s\n", u_errorName(er rorCode));
2375 return; 2375 return;
2376 } 2376 }
2377 TestNextUChar(cnv, source, limit, results, "UTF-32LE"); 2377 TestNextUChar(cnv, source, limit, results, "UTF-32LE");
2378 2378
2379 /* Test the condition when source >= sourceLimit */ 2379 /* Test the condition when source >= sourceLimit */
2380 TestNextUCharError(cnv, source, source, U_INDEX_OUTOFBOUNDS_ERROR, "sourceLi mit <= source"); 2380 TestNextUCharError(cnv, source, source, U_INDEX_OUTOFBOUNDS_ERROR, "sourceLi mit <= source");
2381 2381
2382 /* test error behavior with a skip callback */ 2382 /* test error behavior with a skip callback */
2383 ucnv_setToUCallBack(cnv, UCNV_TO_U_CALLBACK_SKIP, NULL, &cb, &p, &errorCode) ; 2383 ucnv_setToUCallBack(cnv, UCNV_TO_U_CALLBACK_SKIP, NULL, &cb, &p, &errorCode) ;
2384 source=(const char *)in2; 2384 source=(const char *)in2;
(...skipping 3145 matching lines...) Expand 10 before | Expand all | Expand 10 after
5530 UErrorCode status = U_ZERO_ERROR; 5530 UErrorCode status = U_ZERO_ERROR;
5531 UConverter* conv = ucnv_open("iscii", &status); 5531 UConverter* conv = ucnv_open("iscii", &status);
5532 UChar dest[100] = {'\0'}; 5532 UChar dest[100] = {'\0'};
5533 UChar* target = dest; 5533 UChar* target = dest;
5534 UChar* targetLimit = dest+100; 5534 UChar* targetLimit = dest+100;
5535 const char* source = data; 5535 const char* source = data;
5536 const char* sourceLimit = data+strlen(data); 5536 const char* sourceLimit = data+strlen(data);
5537 const UChar* exp = expected; 5537 const UChar* exp = expected;
5538 ucnv_toUnicode(conv, &target, targetLimit, &source, sourceLimit, NULL, TRUE, &status); 5538 ucnv_toUnicode(conv, &target, targetLimit, &source, sourceLimit, NULL, TRUE, &status);
5539 if(U_FAILURE(status)){ 5539 if(U_FAILURE(status)){
5540 log_err("conversion failed: %s \n", u_errorName(status)); 5540 log_data_err("conversion failed: %s \n", u_errorName(status));
5541 } 5541 }
5542 targetLimit = target; 5542 targetLimit = target;
5543 target = dest; 5543 target = dest;
5544 5544
5545 printUSeq(target, targetLimit-target); 5545 printUSeq(target, targetLimit-target);
5546 5546
5547 while(target<targetLimit){ 5547 while(target<targetLimit){
5548 if(*exp!=*target){ 5548 if(*exp!=*target){
5549 log_err("did not get the expected output. \\u%04X != \\u%04X (got)\n ", *exp, *target); 5549 log_err("did not get the expected output. \\u%04X != \\u%04X (got)\n ", *exp, *target);
5550 } 5550 }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
5592 log_data_err("Error open converter: %s - %s \n", notFixedWidth[i], u _errorName(status)); 5592 log_data_err("Error open converter: %s - %s \n", notFixedWidth[i], u _errorName(status));
5593 continue; 5593 continue;
5594 } 5594 }
5595 5595
5596 if (ucnv_isFixedWidth(cnv, &status)) { 5596 if (ucnv_isFixedWidth(cnv, &status)) {
5597 log_err("%s is NOT a fixedWidth converter but returned TRUE.\n", not FixedWidth[i]); 5597 log_err("%s is NOT a fixedWidth converter but returned TRUE.\n", not FixedWidth[i]);
5598 } 5598 }
5599 ucnv_close(cnv); 5599 ucnv_close(cnv);
5600 } 5600 }
5601 } 5601 }
OLDNEW
« no previous file with comments | « source/test/cintltst/ncnvtst.c ('k') | source/test/cintltst/reapits.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698