ICU-583 Added more test cases for ISO-2022-jp

X-SVN-Rev: 2443
This commit is contained in:
Ram Viswanadha 2000-09-19 02:38:40 +00:00
parent 9b218b255a
commit 8f68e5fb1d

View File

@ -41,6 +41,8 @@ void TestDBCS(void);
void TestMBCS(void);
void TestISO_2022(void);
void TestISO_2022_JP(void);
void TestISO_2022_KR(void);
void TestISO_2022_CN(void);
void TestEBCDIC_STATEFUL(void);
void TestLMBCS(void);
void TestJitterbug255(void);
@ -166,6 +168,7 @@ void addTestNewConvert(TestNode** root)
addTest(root, &TestISO_2022, "tsconv/nucnvtst/TestISO_2022");
addTest(root, &TestISO_2022_JP, "tsconv/nucnvtst/TestISO_2022_JP");
addTest(root, &TestISO_2022_KR, "tsconv/nucnvtst/TestISO_2022_KR");
/*addTest(root, &TestISO_2022_CN, "tsconv/nucnvtst/TestISO_2022_CN");*/
addTest(root, &TestEBCDIC_STATEFUL, "tsconv/nucnvtst/TestEBCDIC_STATEFUL");
addTest(root, &TestLMBCS, "tsconv/nucnvtst/TestLMBCS");
addTest(root, &TestJitterbug255, "tsconv/nucnvtst/TestJitterbug255");
@ -1299,17 +1302,25 @@ void
TestISO_2022_JP() {
/* test input */
static const uint16_t in[]={
0x4E00, 0x4E20, 0x000A, 0x000D, 0x4E30, 0x4E40, 0x4E71, 0x4E73, 0x4E38, 0x000A,
0x000D, 0x4E15, 0x4EC5, 0x4EF3, 0x4EF1, 0x4EB1, 0x4E56, 0x4E14, 0x4E12, 0x000A,
0x000D, 0x4E01, 0x4E01, 0x4E12, 0x4E56, 0x4E86, 0x4E69, 0x4E46, 0x4E72, 0x4E21,
0xAC13, 0xACA8, 0x000A, 0x000D, 0x4E01, 0x4E33, 0x4EA9, 0x4EA1, 0xF9D9, 0xF978,
0xF978, 0xF983, 0xF9D2, 0xF990, 0xF931, 0xF937, 0xF9B9, 0xF9D7, 0xF9D3, 0x000A,
0x000D, 0xFE40, 0xFF15, 0xFF2D, 0xFF0E, 0xFE33, 0xFE30, 0xFF21, 0xFF26, 0xFF19,
0xFE40, 0xFE44, 0xFE61, 0x000A, 0x000D, 0xF9B7, 0xF9EB, 0xF98C, 0xF962, 0xF912,
0xF911, 0xF9D1, 0x3053, 0x30A4, 0x30B9, 0x307C, 0x3055, 0x3093, 0x3109, 0x3109,
0x000A, 0x000D, 0x30CB, 0x315B, 0x317B, 0x3177, 0x3172, 0x318B, 0x313B, 0x30EB,
0x30CA, 0x30B6, 0x3127, 0x3168, 0x000A, 0x000D, 0x3155, 0x3167, 0x3145, 0x3181,
0x3173, 0x3204, 0x3207, 0x3228, 0x320B, 0x320F, 0x3221, 0x000A, 0x000D
0x00A8, 0x3003, 0x3005, 0x2015, 0xFF5E, 0x2016, 0x2026, 0x2018, 0x000A, 0x000D,
0x2019, 0x201C, 0x201D, 0x3014, 0x3015, 0x3008, 0x3009, 0x300A, 0x000A, 0x000D,
0x300B, 0x300C, 0x300D, 0x300E, 0x300F, 0x3016, 0x3017, 0x3010, 0x000A, 0x000D,
0x3011, 0x00B1, 0x00D7, 0x00F7, 0x2236, 0x2227, 0x7FC1, 0x8956, 0x000A, 0x000D,
0x9D2C, 0x9D0E, 0x9EC4, 0x5CA1, 0x6C96, 0x837B, 0x5104, 0x5C4B, 0x000A, 0x000D,
0x61B6, 0x81C6, 0x6876, 0x7261, 0x4E59, 0x4FFA, 0x5378, 0x57F7, 0x000A, 0x000D,
0x57F4, 0x57F9, 0x57FA, 0x57FC, 0x5800, 0x5802, 0x5805, 0x5806, 0x000A, 0x000D,
0x580A, 0x581E, 0x6BB5, 0x6BB7, 0x6BBA, 0x6BBC, 0x9CE2, 0x977C, 0x000A, 0x000D,
0x6BBF, 0x6BC1, 0x6BC5, 0x6BC6, 0x6BCB, 0x6BCD, 0x6BCF, 0x6BD2, 0x000A, 0x000D,
0x6BD3, 0x6BD4, 0x6BD6, 0x6BD7, 0x6BD8, 0x6BDB, 0x6BEB, 0x6BEC, 0x000A, 0x000D,
0x6C05, 0x6C08, 0x6C0F, 0x6C11, 0x6C13, 0x6C23, 0x6C34, 0x0041, 0x000A, 0x000D,
0x0043, 0x0044, 0x0045, 0x0046, 0x0047, 0x0048, 0x0049, 0x004A, 0x000A, 0x000D,
0x004B, 0x004C, 0x004D, 0x004E, 0x004F, 0x0050, 0x0051, 0x0052, 0x000A, 0x000D,
0x0053, 0x0054, 0x0055, 0x0056, 0x0057, 0x0058, 0x0059, 0x005A, 0x000A, 0x000D,
0x005B, 0x9792, 0x9CCC, 0x9CCD, 0x9CCE, 0x9CCF, 0x9CD0, 0x9CD3, 0x000A, 0x000D,
0x9CD4, 0x9CD5, 0x9CD7, 0x9CD8, 0x9CD9, 0x9CDC, 0x9CDD, 0x9CDF, 0x000A, 0x000D,
0x9785, 0x9791, 0x00BD, 0x0390, 0x0385, 0x0386, 0x0388, 0x0389, 0x000A, 0x000D,
0x038E, 0x038F, 0x0390, 0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x000A, 0x000D,
0x0396, 0x0397, 0x0398, 0x0399, 0x039A, 0x038A, 0x038C, 0x039C, 0x000A, 0x000D
};
const UChar* uSource;
const UChar* uSourceLimit;
@ -1355,6 +1366,7 @@ TestISO_2022_JP() {
uSource = (const UChar*)&in[0];
while(uSource<uSourceLimit){
if(*test!=*uSource){
log_err("Expected : \\u%04X \t Got: \\u%04X\n",*uSource,(int)*test) ;
}
*uSource++;
@ -1431,6 +1443,70 @@ TestISO_2022_KR() {
free(uBuf);
free(cBuf);
}
void
TestISO_2022_CN() {
/* test input */
static const uint16_t in[]={
0x4DB3, 0x4DB4, 0x4DB5, 0x4E00, 0x4E00, 0x4E01, 0x4E02, 0x4E03, 0x4E04, 0x4E05, 0x4E07,
0x4E08, 0x4E08, 0x4E09, 0x4E0A, 0x4E0B, 0x4E0C, 0x0021, 0x0022, 0x0023, 0x0024, 0xFF40,
0xFF41, 0xFF42, 0xFF43, 0xFF44, 0xFF45, 0xFF46, 0xFF47, 0xFF48, 0xFF49, 0xFF4A, 0xFF4B,
0xFF4C, 0xFF4D, 0xFF4E, 0xFF4F, 0x6332, 0x63B0, 0x643F, 0x64D8, 0x8004, 0x6BEA, 0x6BF3,
0x6BFD, 0x6BF5, 0x6BF9, 0x6C05, 0x6C07, 0x6C06, 0x6C0D, 0x6C15
};
const UChar* uSource;
const UChar* uSourceLimit;
const char* cSource;
const char* cSourceLimit;
UChar *uTargetLimit =NULL;
UChar *uTarget;
char *cTarget;
const char *cTargetLimit;
char *cBuf;
UChar *uBuf,*test;
int32_t uBufSize = 120;
UErrorCode errorCode=U_ZERO_ERROR;
UConverter *cnv;
cnv=ucnv_open("ISO_2022,locale=cn", &errorCode);
if(U_FAILURE(errorCode)) {
log_err("Unable to open a iso-2022 converter: %s\n", u_errorName(errorCode));
return;
}
uBuf = (UChar*)malloc(uBufSize * sizeof(UChar)*5);
cBuf =(char*)malloc(uBufSize * sizeof(char) * 5);
uSource = (const UChar*)&in[0];
uSourceLimit=(const UChar*)&in[sizeof(in)/2];
cTarget = cBuf;
cTargetLimit = cBuf +uBufSize*5;
uTarget = uBuf;
uTargetLimit = uBuf+ uBufSize*5;
ucnv_fromUnicode( cnv , &cTarget, cTargetLimit,&uSource,uSourceLimit,NULL,TRUE, &errorCode);
if(U_FAILURE(errorCode)){
log_err("ucnv_fromUnicode conversion failed reason %s\n", u_errorName(errorCode));
return;
}
cSource = cBuf;
cSourceLimit =cTarget;
test =uBuf;
ucnv_toUnicode(cnv,&uTarget,uTargetLimit,&cSource,cSourceLimit,NULL,TRUE,&errorCode);
if(U_FAILURE(errorCode)){
log_err("ucnv_toUnicode conversion failed reason %s\n", u_errorName(errorCode));
return;
}
uSource = (const UChar*)&in[0];
while(uSource<uSourceLimit){
if(*test!=*uSource){
log_err("Expected : \\u%04X \t Got: \\u%04X\n",*uSource,(int)*test) ;
}
*uSource++;
*test++;
}
ucnv_close(cnv);
free(uBuf);
free(cBuf);
}
void
TestEBCDIC_STATEFUL() {