mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-21 12:40:02 +00:00
ICU-289 Added tests for ISO2022-KR.
X-SVN-Rev: 2321
This commit is contained in:
parent
e8b1308f23
commit
4155f6f6b0
1 changed files with 69 additions and 2 deletions
|
@ -45,7 +45,7 @@ void TestEBCDIC_STATEFUL(void);
|
|||
void TestLMBCS(void);
|
||||
void TestJitterbug255(void);
|
||||
void TestEBCDICUS4XML(void);
|
||||
|
||||
void TestISO_2022_KR(void);
|
||||
#define NEW_MAX_BUFFER 999
|
||||
|
||||
static int32_t gInBufferSize = 0;
|
||||
|
@ -165,6 +165,7 @@ void addTestNewConvert(TestNode** root)
|
|||
addTest(root, &TestMBCS, "tsconv/nucnvtst/TestMBCS");
|
||||
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, &TestEBCDIC_STATEFUL, "tsconv/nucnvtst/TestEBCDIC_STATEFUL");
|
||||
addTest(root, &TestLMBCS, "tsconv/nucnvtst/TestLMBCS");
|
||||
addTest(root, &TestJitterbug255, "tsconv/nucnvtst/TestJitterbug255");
|
||||
|
@ -1352,7 +1353,7 @@ TestISO_2022_JP() {
|
|||
test =uBuf;
|
||||
ucnv_toUnicode(cnv,&uTarget,uTargetLimit,&cSource,cSourceLimit,NULL,TRUE,&errorCode);
|
||||
if(U_FAILURE(errorCode)){
|
||||
log_err("ucnv_fromUnicode conversion failed reason %s\n", u_errorName(errorCode));
|
||||
log_err("ucnv_toUnicode conversion failed reason %s\n", u_errorName(errorCode));
|
||||
return;
|
||||
}
|
||||
uSource = (const UChar*)&in[0];
|
||||
|
@ -1369,6 +1370,72 @@ TestISO_2022_JP() {
|
|||
free(cBuf);
|
||||
}
|
||||
|
||||
void
|
||||
TestISO_2022_KR() {
|
||||
/* test input */
|
||||
static const uint16_t in[]={
|
||||
0x9F4B,0x9F4E,0x9F52,0x9F5F,0x9F61,0x9F66,0x9F67,0x9F6A,0x000A,0x000D
|
||||
,0x9F6C,0x9F77,0x9F8D,0x9F90,0x9F95,0x9F9C,0xAC00,0xAC01,0xAC02,0xAC04
|
||||
,0xAC07,0xAC08,0xAC09,0x0025,0x0026,0x0027,0x000A,0x000D,0x0028,0x0029
|
||||
,0x002A,0x002B,0x002C,0x002D,0x002E,0x53C3,0x53C8,0x53C9,0x53CA,0x53CB
|
||||
,0x53CD,0x53D4,0x53D6,0x53D7,0x53DB,0x000A,0x000D,0x53DF,0x53E1,0x53E2
|
||||
,0x53E3,0x53E4,0x000A,0x000D};
|
||||
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=kr", &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,*test) ;
|
||||
}
|
||||
*uSource++;
|
||||
*test++;
|
||||
}
|
||||
|
||||
ucnv_close(cnv);
|
||||
free(uBuf);
|
||||
free(cBuf);
|
||||
}
|
||||
|
||||
void
|
||||
TestEBCDIC_STATEFUL() {
|
||||
/* test input */
|
||||
|
|
Loading…
Add table
Reference in a new issue