OLD | NEW |
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 CCONVTST.C | 8 * File CCONVTST.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" |
19 #include "unicode/ucnv_err.h" | 19 #include "unicode/ucnv_err.h" |
20 #include "unicode/ucnv_cb.h" | 20 #include "unicode/ucnv_cb.h" |
21 #include "cintltst.h" | 21 #include "cintltst.h" |
22 #include "unicode/utypes.h" | 22 #include "unicode/utypes.h" |
23 #include "unicode/ustring.h" | 23 #include "unicode/ustring.h" |
24 #include "unicode/ucol.h" | 24 #include "unicode/ucol.h" |
25 #include "unicode/utf16.h" | 25 #include "unicode/utf16.h" |
26 #include "cmemory.h" | 26 #include "cmemory.h" |
27 #include "nucnvtst.h" | 27 #include "nucnvtst.h" |
28 | 28 |
29 #define LENGTHOF(array) (sizeof(array)/sizeof((array)[0])) | |
30 | |
31 static void TestNextUChar(UConverter* cnv, const char* source, const char* limit
, const int32_t results[], const char* message); | 29 static void TestNextUChar(UConverter* cnv, const char* source, const char* limit
, const int32_t results[], const char* message); |
32 static void TestNextUCharError(UConverter* cnv, const char* source, const char*
limit, UErrorCode expected, const char* message); | 30 static void TestNextUCharError(UConverter* cnv, const char* source, const char*
limit, UErrorCode expected, const char* message); |
33 #if !UCONFIG_NO_COLLATION | 31 #if !UCONFIG_NO_COLLATION |
34 static void TestJitterbug981(void); | 32 static void TestJitterbug981(void); |
35 #endif | 33 #endif |
36 #if !UCONFIG_NO_LEGACY_CONVERSION | 34 #if !UCONFIG_NO_LEGACY_CONVERSION |
37 static void TestJitterbug1293(void); | 35 static void TestJitterbug1293(void); |
38 #endif | 36 #endif |
39 static void TestNewConvertWithBufferSizes(int32_t osize, int32_t isize) ; | 37 static void TestNewConvertWithBufferSizes(int32_t osize, int32_t isize) ; |
40 static void TestConverterTypesAndStarters(void); | 38 static void TestConverterTypesAndStarters(void); |
(...skipping 5349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5390 return; | 5388 return; |
5391 } | 5389 } |
5392 myCollator = ucol_open("zh", &status); | 5390 myCollator = ucol_open("zh", &status); |
5393 if(U_FAILURE(status)){ | 5391 if(U_FAILURE(status)){ |
5394 log_data_err("Could not open collator for zh locale. Error: %s\n", u_err
orName(status)); | 5392 log_data_err("Could not open collator for zh locale. Error: %s\n", u_err
orName(status)); |
5395 ucnv_close(utf8cnv); | 5393 ucnv_close(utf8cnv); |
5396 return; | 5394 return; |
5397 } | 5395 } |
5398 | 5396 |
5399 rules = ucol_getRules(myCollator, &rules_length); | 5397 rules = ucol_getRules(myCollator, &rules_length); |
| 5398 if(rules_length == 0) { |
| 5399 log_data_err("missing zh tailoring rule string\n"); |
| 5400 ucol_close(myCollator); |
| 5401 ucnv_close(utf8cnv); |
| 5402 return; |
| 5403 } |
5400 buff_size = rules_length * ucnv_getMaxCharSize(utf8cnv); | 5404 buff_size = rules_length * ucnv_getMaxCharSize(utf8cnv); |
5401 buff = malloc(buff_size); | 5405 buff = malloc(buff_size); |
5402 | 5406 |
5403 target_cap = 0; | 5407 target_cap = 0; |
5404 do { | 5408 do { |
5405 ucnv_reset(utf8cnv); | 5409 ucnv_reset(utf8cnv); |
5406 status = U_ZERO_ERROR; | 5410 status = U_ZERO_ERROR; |
5407 if(target_cap >= buff_size) { | 5411 if(target_cap >= buff_size) { |
5408 log_err("wanted %d bytes, only %d available\n", target_cap, buff_siz
e); | 5412 log_err("wanted %d bytes, only %d available\n", target_cap, buff_siz
e); |
5409 break; | 5413 break; |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5562 "ibm-5478_P100-1995" | 5566 "ibm-5478_P100-1995" |
5563 }; | 5567 }; |
5564 | 5568 |
5565 const char *notFixedWidth[] = { | 5569 const char *notFixedWidth[] = { |
5566 "GB18030", | 5570 "GB18030", |
5567 "UTF8", | 5571 "UTF8", |
5568 "windows-949-2000", | 5572 "windows-949-2000", |
5569 "UTF16" | 5573 "UTF16" |
5570 }; | 5574 }; |
5571 | 5575 |
5572 for (i = 0; i < LENGTHOF(fixedWidth); i++) { | 5576 for (i = 0; i < UPRV_LENGTHOF(fixedWidth); i++) { |
5573 cnv = ucnv_open(fixedWidth[i], &status); | 5577 cnv = ucnv_open(fixedWidth[i], &status); |
5574 if (cnv == NULL || U_FAILURE(status)) { | 5578 if (cnv == NULL || U_FAILURE(status)) { |
5575 log_data_err("Error open converter: %s - %s \n", fixedWidth[i], u_er
rorName(status)); | 5579 log_data_err("Error open converter: %s - %s \n", fixedWidth[i], u_er
rorName(status)); |
5576 continue; | 5580 continue; |
5577 } | 5581 } |
5578 | 5582 |
5579 if (!ucnv_isFixedWidth(cnv, &status)) { | 5583 if (!ucnv_isFixedWidth(cnv, &status)) { |
5580 log_err("%s is a fixedWidth converter but returned FALSE.\n", fixedW
idth[i]); | 5584 log_err("%s is a fixedWidth converter but returned FALSE.\n", fixedW
idth[i]); |
5581 } | 5585 } |
5582 ucnv_close(cnv); | 5586 ucnv_close(cnv); |
5583 } | 5587 } |
5584 | 5588 |
5585 for (i = 0; i < LENGTHOF(notFixedWidth); i++) { | 5589 for (i = 0; i < UPRV_LENGTHOF(notFixedWidth); i++) { |
5586 cnv = ucnv_open(notFixedWidth[i], &status); | 5590 cnv = ucnv_open(notFixedWidth[i], &status); |
5587 if (cnv == NULL || U_FAILURE(status)) { | 5591 if (cnv == NULL || U_FAILURE(status)) { |
5588 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)); |
5589 continue; | 5593 continue; |
5590 } | 5594 } |
5591 | 5595 |
5592 if (ucnv_isFixedWidth(cnv, &status)) { | 5596 if (ucnv_isFixedWidth(cnv, &status)) { |
5593 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]); |
5594 } | 5598 } |
5595 ucnv_close(cnv); | 5599 ucnv_close(cnv); |
5596 } | 5600 } |
5597 } | 5601 } |
OLD | NEW |