ICU-452 Tests for ISCII
X-SVN-Rev: 5237
This commit is contained in:
parent
25edbe02ca
commit
1460f5bdb2
@ -1084,7 +1084,7 @@ static void TestAlias() {
|
||||
|
||||
static void TestConvertSafeClone()
|
||||
{
|
||||
#define CLONETEST_CONVERTER_COUNT 5
|
||||
#define CLONETEST_CONVERTER_COUNT 6
|
||||
|
||||
char charBuffer [10];
|
||||
char *pCharBuffer;
|
||||
@ -1108,6 +1108,7 @@ static void TestConvertSafeClone()
|
||||
someConverters[2] = ucnv_open("SCSU", &err);
|
||||
someConverters[3] = ucnv_open("HZ", &err);
|
||||
someConverters[4] = ucnv_open("lmbcs", &err);
|
||||
someConverters[5] = ucnv_open("ISCII,version=0",&err);
|
||||
|
||||
/* Check the various error & informational states: */
|
||||
|
||||
|
@ -402,6 +402,24 @@ static void TestSkip(int32_t inputsize, int32_t outputsize)
|
||||
2,
|
||||
|
||||
};
|
||||
/* ISCII */
|
||||
UChar iscii_inputText[]={ 0x0041, 0x3712/*unassigned*/, 0x0042, };
|
||||
const uint8_t to_iscii[]={
|
||||
0x41,
|
||||
0x42,
|
||||
};
|
||||
int32_t from_isciiOffs [] ={
|
||||
0,2,
|
||||
|
||||
};
|
||||
/*ISCII*/
|
||||
UChar iscii_inputText1[]={0x0044, 0x3712/*unassigned*/,0x43,0xd800/*illegal*/,0x0042, };
|
||||
const uint8_t to_iscii1[]={
|
||||
0x44,
|
||||
0x43,
|
||||
|
||||
};
|
||||
int32_t from_isciiOffs1 [] ={0,2};
|
||||
|
||||
if(!testConvertFromUnicode(inputTest, sizeof(inputTest)/sizeof(inputTest[0]),
|
||||
toIBM943, sizeof(toIBM943), "ibm-943",
|
||||
@ -473,7 +491,16 @@ static void TestSkip(int32_t inputsize, int32_t outputsize)
|
||||
UCNV_FROM_U_CALLBACK_SKIP, from_SCSUOffs, NULL, 0 ))
|
||||
log_err("u-> SCSU with skip did not match.\n");
|
||||
|
||||
|
||||
/*ISCII*/
|
||||
if(!testConvertFromUnicode(iscii_inputText, sizeof(iscii_inputText)/sizeof(iscii_inputText[0]),
|
||||
to_iscii, sizeof(to_iscii), "ISCII,version=0",
|
||||
UCNV_FROM_U_CALLBACK_SKIP, from_isciiOffs, NULL, 0 ))
|
||||
log_err("u-> iscii with skip did not match.\n");
|
||||
/*with context*/
|
||||
if(!testConvertFromUnicodeWithContext(iscii_inputText1, sizeof(iscii_inputText1)/sizeof(iscii_inputText1[0]),
|
||||
to_iscii1, sizeof(to_iscii1), "ISCII,version=0",
|
||||
UCNV_FROM_U_CALLBACK_SKIP, from_isciiOffs1, NULL, 0,UCNV_SKIP_STOP_ON_ILLEGAL,U_ILLEGAL_CHAR_FOUND ))
|
||||
log_err("u-> iscii with skip & UCNV_SKIP_STOP_ON_ILLEGAL did not match.\n");
|
||||
|
||||
}
|
||||
|
||||
@ -622,6 +649,28 @@ static void TestSkip(int32_t inputsize, int32_t outputsize)
|
||||
|
||||
int32_t from_hzOffs [] ={0,3,7,11,18, };
|
||||
|
||||
/*ISCII*/
|
||||
const uint8_t sampleTxt_iscii[]={
|
||||
0x41,
|
||||
0xa1,
|
||||
0x80, /*unassigned*/
|
||||
0x26,
|
||||
0x30,
|
||||
0xa2,
|
||||
0x8E,/*unassigned*/
|
||||
0x42,
|
||||
};
|
||||
UChar isciitoUnicode[]={
|
||||
0x41,
|
||||
0x0901,
|
||||
0x26,
|
||||
0x30,
|
||||
0x0902,
|
||||
0x42,
|
||||
};
|
||||
|
||||
int32_t from_isciiOffs [] ={0,1,3,4,5,7 };
|
||||
|
||||
/*LMBCS*/
|
||||
const uint8_t sampleTxtLMBCS[]={ 0x12, 0xc9, 0x50,
|
||||
0x12, 0x92, 0xa0, /*unassigned*/
|
||||
@ -669,6 +718,11 @@ static void TestSkip(int32_t inputsize, int32_t outputsize)
|
||||
hztoUnicode, sizeof(hztoUnicode)/sizeof(hztoUnicode[0]),"HZ",
|
||||
UCNV_TO_U_CALLBACK_SKIP, from_hzOffs , NULL, 0))
|
||||
log_err("HZ->u with skip did not match.\n");
|
||||
|
||||
if(!testConvertToUnicode(sampleTxt_iscii, sizeof(sampleTxt_iscii),
|
||||
isciitoUnicode, sizeof(isciitoUnicode)/sizeof(isciitoUnicode[0]),"ISCII,version=0",
|
||||
UCNV_TO_U_CALLBACK_SKIP, from_isciiOffs , NULL, 0))
|
||||
log_err("iscii->u with skip did not match.\n");
|
||||
|
||||
if(/* broken for icu 1.6 and 1.6.0.1, do not test */uprv_strcmp("1.7", U_ICU_VERSION) != 0 && !testConvertToUnicode(sampleTxtLMBCS, sizeof(sampleTxtLMBCS),
|
||||
LMBCSToUnicode, sizeof(LMBCSToUnicode)/sizeof(LMBCSToUnicode[0]),"LMBCS-1",
|
||||
@ -807,6 +861,14 @@ static void TestStop(int32_t inputsize, int32_t outputsize)
|
||||
1,1,1,1,
|
||||
};
|
||||
|
||||
/*ISCII*/
|
||||
UChar iscii_inputText[]={ 0x0041, 0x3712, 0x0042, };
|
||||
const uint8_t to_iscii[]={
|
||||
0x41,
|
||||
};
|
||||
int32_t from_isciiOffs [] ={
|
||||
0,
|
||||
};
|
||||
|
||||
if(!testConvertFromUnicode(inputTest, sizeof(inputTest)/sizeof(inputTest[0]),
|
||||
toIBM943, sizeof(toIBM943), "ibm-943",
|
||||
@ -846,7 +908,12 @@ static void TestStop(int32_t inputsize, int32_t outputsize)
|
||||
if(!testConvertFromUnicode(hz_inputText, sizeof(hz_inputText)/sizeof(hz_inputText[0]),
|
||||
to_hz, sizeof(to_hz), "HZ",
|
||||
UCNV_FROM_U_CALLBACK_STOP, from_hzOffs, NULL, 0 ))
|
||||
log_err("u-> HZ with stop did not match.\n");
|
||||
log_err("u-> HZ with stop did not match.\n");\
|
||||
|
||||
if(!testConvertFromUnicode(iscii_inputText, sizeof(iscii_inputText)/sizeof(iscii_inputText[0]),
|
||||
to_iscii, sizeof(to_iscii), "ISCII,version=0",
|
||||
UCNV_FROM_U_CALLBACK_STOP, from_isciiOffs, NULL, 0 ))
|
||||
log_err("u-> iscii with stop did not match.\n");
|
||||
|
||||
|
||||
}
|
||||
@ -1527,6 +1594,53 @@ static void TestSubWithValue(int32_t inputsize, int32_t outputsize)
|
||||
8,
|
||||
};
|
||||
|
||||
/*ISCII*/
|
||||
UChar iscii_inputText2[]={ 0x0041, 0x0901,0xD84D, 0xDC56/*unassigned*/,0x0902, 0x0042,0xD84D, 0xDC56/*unassigned*/,0x43 };
|
||||
const uint8_t to_iscii2[]={
|
||||
0x41,
|
||||
0xef, 0x42, 0xa1,
|
||||
0x25, 0x55, 0x44, 0x38, 0x34, 0x44,
|
||||
0x25, 0x55, 0x44, 0x43, 0x35, 0x36,
|
||||
0xa2,
|
||||
0x42,
|
||||
0x25, 0x55, 0x44, 0x38, 0x34, 0x44,
|
||||
0x25, 0x55, 0x44, 0x43, 0x35, 0x36,
|
||||
0x43
|
||||
};
|
||||
int32_t from_isciiOffs2 [] ={
|
||||
0,
|
||||
1,1,1,
|
||||
2,2,2,2,2,2,
|
||||
2,2,2,2,2,2,
|
||||
4,
|
||||
5,
|
||||
6,6,6,6,6,6,
|
||||
6,6,6,6,6,6,
|
||||
8,
|
||||
};
|
||||
|
||||
UChar iscii_inputText[]={ 0x0041, 0x0901,0x3712/*unassigned*/,0x0902, 0x0042,0x3712/*unassigned*/,0x43 };
|
||||
const uint8_t to_iscii[]={
|
||||
0x41,
|
||||
0xef, 0x42, 0xa1,
|
||||
0x25, 0x55, 0x33, 0x37, 0x31, 0x32, /*unassigned*/
|
||||
0xa2,
|
||||
0x42,
|
||||
0x25, 0x55, 0x33, 0x37, 0x31, 0x32, /*unassigned*/
|
||||
0x43
|
||||
};
|
||||
|
||||
|
||||
int32_t from_isciiOffs [] ={
|
||||
0,
|
||||
1,1,1,
|
||||
2,2,2,2,2,2,
|
||||
3,
|
||||
4,
|
||||
5,5,5,5,5,5,
|
||||
6,
|
||||
};
|
||||
|
||||
if(!testConvertFromUnicode(inputTest, sizeof(inputTest)/sizeof(inputTest[0]),
|
||||
toIBM943, sizeof(toIBM943), "ibm-943",
|
||||
UCNV_FROM_U_CALLBACK_ESCAPE, offset, NULL, 0 ))
|
||||
@ -1702,6 +1816,16 @@ static void TestSubWithValue(int32_t inputsize, int32_t outputsize)
|
||||
to_hz2, sizeof(to_hz2), "HZ",
|
||||
UCNV_FROM_U_CALLBACK_ESCAPE, from_hzOffs2, NULL, 0 ))
|
||||
log_err("u-> hz with subst with value did not match.\n");
|
||||
|
||||
if(!testConvertFromUnicode(iscii_inputText, sizeof(iscii_inputText)/sizeof(iscii_inputText[0]),
|
||||
to_iscii, sizeof(to_iscii), "ISCII,version=0",
|
||||
UCNV_FROM_U_CALLBACK_ESCAPE, from_isciiOffs, NULL, 0 ))
|
||||
log_err("u-> iscii with subst with value did not match.\n");
|
||||
|
||||
if(!testConvertFromUnicode(iscii_inputText2, sizeof(iscii_inputText2)/sizeof(iscii_inputText2[0]),
|
||||
to_iscii2, sizeof(to_iscii2), "ISCII,version=0",
|
||||
UCNV_FROM_U_CALLBACK_ESCAPE, from_isciiOffs2, NULL, 0 ))
|
||||
log_err("u-> iscii2 with subst with value did not match.\n");
|
||||
}
|
||||
|
||||
|
||||
@ -1797,6 +1921,29 @@ static void TestSubWithValue(int32_t inputsize, int32_t outputsize)
|
||||
|
||||
int32_t from_hzOffs [] ={0,3,5,5,5,5,5,5,5,5,7,11,14,14,14,14,14,14,14,14,18, };
|
||||
|
||||
|
||||
/*hz*/
|
||||
const uint8_t sampleTxt_iscii[]={
|
||||
0x41,
|
||||
0x30,
|
||||
0x8E, /*unassigned*/
|
||||
0xa3,
|
||||
0x42,
|
||||
0x8E,/*unassigned*/
|
||||
0x42,
|
||||
};
|
||||
UChar isciitoUnicode[]={
|
||||
0x41,
|
||||
0x30,
|
||||
0x25, 0x58, 0x38, 0x45,
|
||||
0x0903,
|
||||
0x42,
|
||||
0x25, 0x58, 0x38, 0x45,
|
||||
0x42,};
|
||||
|
||||
int32_t from_isciiOffs [] ={0,1,2,2,2,2,3,4,5,5,5,5,6 };
|
||||
|
||||
|
||||
/*LMBCS*/
|
||||
const uint8_t sampleTxtLMBCS[]={ 0x12, 0xc9, 0x50,
|
||||
0x12, 0x92, 0xa0, /*unassigned*/
|
||||
@ -1843,8 +1990,12 @@ static void TestSubWithValue(int32_t inputsize, int32_t outputsize)
|
||||
if(!testConvertToUnicode(sampleTxt_hz, sizeof(sampleTxt_hz),
|
||||
hztoUnicode, sizeof(hztoUnicode)/sizeof(hztoUnicode[0]),"HZ",
|
||||
UCNV_TO_U_CALLBACK_ESCAPE, from_hzOffs, NULL, 0))
|
||||
log_err("iso-2022-kr->u with substitute with value did not match.\n");
|
||||
log_err("hz->u with substitute with value did not match.\n");
|
||||
|
||||
if(!testConvertToUnicode(sampleTxt_iscii, sizeof(sampleTxt_iscii),
|
||||
isciitoUnicode, sizeof(isciitoUnicode)/sizeof(isciitoUnicode[0]),"ISCII,version=0",
|
||||
UCNV_TO_U_CALLBACK_ESCAPE, from_isciiOffs, NULL, 0))
|
||||
log_err("ISCII ->u with substitute with value did not match.\n");
|
||||
/*got to confirm this*/
|
||||
if(/* broken for icu 1.6.0.1, do not test */uprv_strcmp("1.7", U_ICU_VERSION) != 0 && !testConvertToUnicode(sampleTxtLMBCS, sizeof(sampleTxtLMBCS),
|
||||
LMBCSToUnicode, sizeof(LMBCSToUnicode)/sizeof(LMBCSToUnicode[0]),"LMBCS",
|
||||
|
@ -55,6 +55,13 @@ static void TestJitterbug255(void);
|
||||
static void TestJitterbug792(void);
|
||||
static void TestEBCDICUS4XML(void);
|
||||
static void TestJitterbug915(void);
|
||||
static void TestISCII(void);
|
||||
static void TestConv(const uint16_t in[],
|
||||
int len,
|
||||
const char* conv,
|
||||
const char* lang,
|
||||
char byteArr[],
|
||||
int byteArrLen);
|
||||
|
||||
void addTestNewConvert(TestNode** root);
|
||||
|
||||
@ -205,6 +212,8 @@ void addTestNewConvert(TestNode** root)
|
||||
addTest(root, &TestJitterbug255, "tsconv/nucnvtst/TestJitterbug255");
|
||||
addTest(root, &TestJitterbug792, "tsconv/nucnvtst/TestJitterbug792");
|
||||
addTest(root, &TestEBCDICUS4XML, "tsconv/nucnvtst/TestEBCDICUS4XML");
|
||||
addTest(root, &TestISCII, "tsconv/nucnvtst/TestISCII");
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -1667,7 +1676,94 @@ TestLATIN1() {
|
||||
1, 0xf0,
|
||||
1, 0xf4,
|
||||
};
|
||||
|
||||
static const uint16_t in1[] = {
|
||||
0x08, 0x00, 0x1b, 0x4c, 0xea, 0x16, 0xca, 0xd3, 0x94, 0x0f, 0x53, 0xef, 0x61, 0x1b, 0xe5, 0x84,
|
||||
0xc4, 0x0f, 0x53, 0xef, 0x61, 0x1b, 0xe5, 0x84, 0xc4, 0x16, 0xca, 0xd3, 0x94, 0x08, 0x02, 0x0f,
|
||||
0x53, 0x4a, 0x4e, 0x16, 0x7d, 0x00, 0x30, 0x82, 0x52, 0x4d, 0x30, 0x6b, 0x6d, 0x41, 0x88, 0x4c,
|
||||
0xe5, 0x97, 0x9f, 0x08, 0x0c, 0x16, 0xca, 0xd3, 0x94, 0x15, 0xae, 0x0e, 0x6b, 0x4c, 0x08, 0x0d,
|
||||
0x8c, 0xb4, 0xa3, 0x9f, 0xca, 0x99, 0xcb, 0x8b, 0xc2, 0x97, 0xcc, 0xaa, 0x84, 0x08, 0x02, 0x0e,
|
||||
0x7c, 0x73, 0xe2, 0x16, 0xa3, 0xb7, 0xcb, 0x93, 0xd3, 0xb4, 0xc5, 0xdc, 0x9f, 0x0e, 0x79, 0x3e,
|
||||
0x06, 0xae, 0xb1, 0x9d, 0x93, 0xd3, 0x08, 0x0c, 0xbe, 0xa3, 0x8f, 0x08, 0x88, 0xbe, 0xa3, 0x8d,
|
||||
0xd3, 0xa8, 0xa3, 0x97, 0xc5, 0x17, 0x89, 0x08, 0x0d, 0x15, 0xd2, 0x08, 0x01, 0x93, 0xc8, 0xaa,
|
||||
0x8f, 0x0e, 0x61, 0x1b, 0x99, 0xcb, 0x0e, 0x4e, 0xba, 0x9f, 0xa1, 0xae, 0x93, 0xa8, 0xa0, 0x08,
|
||||
0x02, 0x08, 0x0c, 0xe2, 0x16, 0xa3, 0xb7, 0xcb, 0x0f, 0x4f, 0xe1, 0x80, 0x05, 0xec, 0x60, 0x8d,
|
||||
0xea, 0x06, 0xd3, 0xe6, 0x0f, 0x8a, 0x00, 0x30, 0x44, 0x65, 0xb9, 0xe4, 0xfe, 0xe7, 0xc2, 0x06,
|
||||
0xcb, 0x82
|
||||
};
|
||||
static const uint8_t out1[] = {
|
||||
0x08, 0x00, 0x1b, 0x4c, 0xea, 0x16, 0xca, 0xd3, 0x94, 0x0f, 0x53, 0xef, 0x61, 0x1b, 0xe5, 0x84,
|
||||
0xc4, 0x0f, 0x53, 0xef, 0x61, 0x1b, 0xe5, 0x84, 0xc4, 0x16, 0xca, 0xd3, 0x94, 0x08, 0x02, 0x0f,
|
||||
0x53, 0x4a, 0x4e, 0x16, 0x7d, 0x00, 0x30, 0x82, 0x52, 0x4d, 0x30, 0x6b, 0x6d, 0x41, 0x88, 0x4c,
|
||||
0xe5, 0x97, 0x9f, 0x08, 0x0c, 0x16, 0xca, 0xd3, 0x94, 0x15, 0xae, 0x0e, 0x6b, 0x4c, 0x08, 0x0d,
|
||||
0x8c, 0xb4, 0xa3, 0x9f, 0xca, 0x99, 0xcb, 0x8b, 0xc2, 0x97, 0xcc, 0xaa, 0x84, 0x08, 0x02, 0x0e,
|
||||
0x7c, 0x73, 0xe2, 0x16, 0xa3, 0xb7, 0xcb, 0x93, 0xd3, 0xb4, 0xc5, 0xdc, 0x9f, 0x0e, 0x79, 0x3e,
|
||||
0x06, 0xae, 0xb1, 0x9d, 0x93, 0xd3, 0x08, 0x0c, 0xbe, 0xa3, 0x8f, 0x08, 0x88, 0xbe, 0xa3, 0x8d,
|
||||
0xd3, 0xa8, 0xa3, 0x97, 0xc5, 0x17, 0x89, 0x08, 0x0d, 0x15, 0xd2, 0x08, 0x01, 0x93, 0xc8, 0xaa,
|
||||
0x8f, 0x0e, 0x61, 0x1b, 0x99, 0xcb, 0x0e, 0x4e, 0xba, 0x9f, 0xa1, 0xae, 0x93, 0xa8, 0xa0, 0x08,
|
||||
0x02, 0x08, 0x0c, 0xe2, 0x16, 0xa3, 0xb7, 0xcb, 0x0f, 0x4f, 0xe1, 0x80, 0x05, 0xec, 0x60, 0x8d,
|
||||
0xea, 0x06, 0xd3, 0xe6, 0x0f, 0x8a, 0x00, 0x30, 0x44, 0x65, 0xb9, 0xe4, 0xfe, 0xe7, 0xc2, 0x06,
|
||||
0xcb, 0x82
|
||||
};
|
||||
static const uint16_t in2[]={
|
||||
0x1B, 0x24, 0x29, 0x47, 0x0E, 0x23, 0x21, 0x23, 0x22, 0x23,
|
||||
0x23, 0x23, 0x24, 0x23, 0x25, 0x23, 0x26, 0x23, 0x27, 0x23,
|
||||
0x28, 0x23, 0x29, 0x23, 0x2A, 0x23, 0x2B, 0x0F, 0x2F, 0x2A,
|
||||
0x70, 0x6C, 0x61, 0x6E, 0x65, 0x20, 0x31, 0x20, 0x2A, 0x2F,
|
||||
0x0D, 0x0A, 0x1B, 0x24, 0x2A, 0x48, 0x1B, 0x4E, 0x22, 0x21,
|
||||
0x1B, 0x4E, 0x22, 0x22, 0x1B, 0x4E, 0x22, 0x23, 0x1B, 0x4E,
|
||||
0x22, 0x24, 0x1B, 0x4E, 0x22, 0x25, 0x0F, 0x2F, 0x2A, 0x70,
|
||||
0x6C, 0x61, 0x6E, 0x65, 0x32, 0x2A, 0x2F, 0x20, 0x0D, 0x0A,
|
||||
0x1B, 0x24, 0x2B, 0x49, 0x1B, 0x4F, 0x22, 0x44, 0x1B, 0x4F,
|
||||
0x22, 0x45, 0x1B, 0x4F, 0x22, 0x46, 0x1B, 0x4F, 0x22, 0x47,
|
||||
0x1B, 0x4F, 0x22, 0x48, 0x0F, 0x2F, 0x2A, 0x70, 0x6C, 0x61,
|
||||
0x6E, 0x65, 0x20, 0x33, 0x20, 0x2A, 0x2F, 0x0D, 0x0A, 0x1B,
|
||||
0x24, 0x2B, 0x4A, 0x1B, 0x4F, 0x21, 0x44, 0x1B, 0x4F, 0x21,
|
||||
0x45, 0x1B, 0x4F, 0x22, 0x6A, 0x1B, 0x4F, 0x22, 0x6B, 0x1B,
|
||||
0x4F, 0x22, 0x6C, 0x0F, 0x2F, 0x2A, 0x70, 0x6C, 0x61, 0x6E,
|
||||
0x65, 0x20, 0x34, 0x20, 0x2A, 0x2F, 0x0D, 0x0A, 0x1B, 0x24,
|
||||
0x2B, 0x4B, 0x1B, 0x4F, 0x21, 0x74, 0x1B, 0x4F, 0x22, 0x50,
|
||||
0x1B, 0x4F, 0x22, 0x51, 0x1B, 0x4F, 0x23, 0x37, 0x1B, 0x4F,
|
||||
0x22, 0x5C, 0x0F, 0x2F, 0x2A, 0x70, 0x6C, 0x61, 0x6E,
|
||||
0x65, 0x20, 0x35, 0x20, 0x2A, 0x2F, 0x0D, 0x0A, 0x1B, 0x24,
|
||||
0x2B, 0x4C, 0x1B, 0x4F, 0x21, 0x23, 0x1B, 0x4F, 0x22, 0x2C,
|
||||
0x1B, 0x4F, 0x23, 0x4E, 0x1B, 0x4F, 0x21, 0x6E, 0x1B, 0x4F,
|
||||
0x23, 0x71, 0x0F, 0x2F, 0x2A, 0x70, 0x6C, 0x61, 0x6E, 0x65,
|
||||
0x20, 0x36, 0x20, 0x2A, 0x2F, 0x0D, 0x0A, 0x1B, 0x24, 0x2B,
|
||||
0x4D, 0x1B, 0x4F, 0x22, 0x71, 0x1B, 0x4F, 0x21, 0x4E, 0x1B,
|
||||
0x4F, 0x21, 0x6A, 0x1B, 0x4F, 0x23, 0x3A, 0x1B, 0x4F, 0x23,
|
||||
0x6F, 0x0F, 0x2F, 0x2A, 0x70, 0x6C, 0x61, 0x6E, 0x65, 0x20,
|
||||
0x37, 0x20, 0x2A, 0x2F,
|
||||
};
|
||||
static const unsigned char out2[]={
|
||||
0x1B, 0x24, 0x29, 0x47, 0x0E, 0x23, 0x21, 0x23, 0x22, 0x23,
|
||||
0x23, 0x23, 0x24, 0x23, 0x25, 0x23, 0x26, 0x23, 0x27, 0x23,
|
||||
0x28, 0x23, 0x29, 0x23, 0x2A, 0x23, 0x2B, 0x0F, 0x2F, 0x2A,
|
||||
0x70, 0x6C, 0x61, 0x6E, 0x65, 0x20, 0x31, 0x20, 0x2A, 0x2F,
|
||||
0x0D, 0x0A, 0x1B, 0x24, 0x2A, 0x48, 0x1B, 0x4E, 0x22, 0x21,
|
||||
0x1B, 0x4E, 0x22, 0x22, 0x1B, 0x4E, 0x22, 0x23, 0x1B, 0x4E,
|
||||
0x22, 0x24, 0x1B, 0x4E, 0x22, 0x25, 0x0F, 0x2F, 0x2A, 0x70,
|
||||
0x6C, 0x61, 0x6E, 0x65, 0x32, 0x2A, 0x2F, 0x20, 0x0D, 0x0A,
|
||||
0x1B, 0x24, 0x2B, 0x49, 0x1B, 0x4F, 0x22, 0x44, 0x1B, 0x4F,
|
||||
0x22, 0x45, 0x1B, 0x4F, 0x22, 0x46, 0x1B, 0x4F, 0x22, 0x47,
|
||||
0x1B, 0x4F, 0x22, 0x48, 0x0F, 0x2F, 0x2A, 0x70, 0x6C, 0x61,
|
||||
0x6E, 0x65, 0x20, 0x33, 0x20, 0x2A, 0x2F, 0x0D, 0x0A, 0x1B,
|
||||
0x24, 0x2B, 0x4A, 0x1B, 0x4F, 0x21, 0x44, 0x1B, 0x4F, 0x21,
|
||||
0x45, 0x1B, 0x4F, 0x22, 0x6A, 0x1B, 0x4F, 0x22, 0x6B, 0x1B,
|
||||
0x4F, 0x22, 0x6C, 0x0F, 0x2F, 0x2A, 0x70, 0x6C, 0x61, 0x6E,
|
||||
0x65, 0x20, 0x34, 0x20, 0x2A, 0x2F, 0x0D, 0x0A, 0x1B, 0x24,
|
||||
0x2B, 0x4B, 0x1B, 0x4F, 0x21, 0x74, 0x1B, 0x4F, 0x22, 0x50,
|
||||
0x1B, 0x4F, 0x22, 0x51, 0x1B, 0x4F, 0x23, 0x37, 0x1B, 0x4F,
|
||||
0x22, 0x5C, 0x0F, 0x2F, 0x2A, 0x70, 0x6C, 0x61, 0x6E,
|
||||
0x65, 0x20, 0x35, 0x20, 0x2A, 0x2F, 0x0D, 0x0A, 0x1B, 0x24,
|
||||
0x2B, 0x4C, 0x1B, 0x4F, 0x21, 0x23, 0x1B, 0x4F, 0x22, 0x2C,
|
||||
0x1B, 0x4F, 0x23, 0x4E, 0x1B, 0x4F, 0x21, 0x6E, 0x1B, 0x4F,
|
||||
0x23, 0x71, 0x0F, 0x2F, 0x2A, 0x70, 0x6C, 0x61, 0x6E, 0x65,
|
||||
0x20, 0x36, 0x20, 0x2A, 0x2F, 0x0D, 0x0A, 0x1B, 0x24, 0x2B,
|
||||
0x4D, 0x1B, 0x4F, 0x22, 0x71, 0x1B, 0x4F, 0x21, 0x4E, 0x1B,
|
||||
0x4F, 0x21, 0x6A, 0x1B, 0x4F, 0x23, 0x3A, 0x1B, 0x4F, 0x23,
|
||||
0x6F, 0x0F, 0x2F, 0x2A, 0x70, 0x6C, 0x61, 0x6E, 0x65, 0x20,
|
||||
0x37, 0x20, 0x2A, 0x2F,
|
||||
};
|
||||
const char *source=(const char *)in;
|
||||
const char *limit=(const char *)in+sizeof(in);
|
||||
|
||||
@ -1680,6 +1776,9 @@ TestLATIN1() {
|
||||
TestNextUChar(cnv, source, limit, results, "LATIN_1");
|
||||
/* Test the condition when source >= sourceLimit */
|
||||
TestNextUCharError(cnv, source, source, U_INDEX_OUTOFBOUNDS_ERROR, "sourceLimit <= source");
|
||||
TestConv((uint16_t*)in1,sizeof(in1)/2,"LATIN_1","LATIN-1",(unsigned char*)out1,sizeof(out1));
|
||||
TestConv((uint16_t*)in2,sizeof(in2)/2,"ASCII","ASCII",(unsigned char*)out2,sizeof(out2));
|
||||
|
||||
ucnv_close(cnv);
|
||||
}
|
||||
|
||||
@ -2237,6 +2336,87 @@ TestHZ() {
|
||||
free(cBuf);
|
||||
}
|
||||
|
||||
static void
|
||||
TestISCII(){
|
||||
/* test input */
|
||||
static const uint16_t in[]={
|
||||
/* test full range of Devanagari */
|
||||
0x0901,0x0902,0x0903,0x0905,0x0906,0x0907,0x0908,0x0909,0x090A,
|
||||
0x090B,0x090E,0x090F,0x0910,0x090D,0x0912,0x0913,0x0914,0x0911,
|
||||
0x0915,0x0916,0x0917,0x0918,0x0919,0x091A,0x091B,0x091C,0x091D,
|
||||
0x091E,0x091F,0x0920,0x0921,0x0922,0x0923,0x0924,0x0925,0x0926,
|
||||
0x0927,0x0928,0x0929,0x092A,0x092B,0x092C,0x092D,0x092E,0x092F,
|
||||
0x095F,0x0930,0x0931,0x0932,0x0933,0x0934,0x0935,0x0936,0x0937,
|
||||
0x0938,0x0939,0x200D,0x093E,0x093F,0x0940,0x0941,0x0942,0x0943,
|
||||
0x0946,0x0947,0x0948,0x0945,0x094A,0x094B,0x094C,0x0949,0x094D,
|
||||
0x0964,0x093C,0x0966,0x0967,0x0968,0x0969,0x096A,0x096B,0x096C,
|
||||
0x096D,0x096E,0x096F,
|
||||
/* test Soft halant*/
|
||||
0x0915,0x094d, 0x200D,
|
||||
/* test explicit halant */
|
||||
0x0915,0x094d, 0x200c,
|
||||
/* test double danda */
|
||||
0x965,
|
||||
/* test ASCII */
|
||||
0x1B, 0x24, 0x29, 0x47, 0x0E, 0x23, 0x21, 0x23, 0x22, 0x23,
|
||||
0x23, 0x23, 0x24, 0x23, 0x25, 0x23, 0x26, 0x23, 0x27, 0x23,
|
||||
0x28, 0x23, 0x29, 0x23, 0x2A, 0x23, 0x2B, 0x0F, 0x2F, 0x2A,
|
||||
/* tests from Lotus */
|
||||
0x0061,0x0915,0x000D,0x000A,0x0996,0x0043,
|
||||
0x0930,0x094D,0x200D,
|
||||
0x0901,0x000D,0x000A,0x0905,0x0985,0x0043,
|
||||
0x0915,0x0921,0x002B,0x095F,
|
||||
/* tamil range */
|
||||
0x0B86, 0xB87, 0xB88,
|
||||
/* telugu range */
|
||||
0x0C05, 0x0C02, 0x0C03,0x0c31,
|
||||
/* kannada range */
|
||||
0x0C85, 0xC82, 0x0C83
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
static const unsigned char byteArr[]={
|
||||
|
||||
0xa1,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,
|
||||
0xaa,0xab,0xac,0xad,0xae,0xaf,0xb0,0xb1,0xb2,
|
||||
0xb3,0xb4,0xb5,0xb6,0xb7,0xb8,0xb9,0xba,0xbb,
|
||||
0xbc,0xbd,0xbe,0xbf,0xc0,0xc1,0xc2,0xc3,0xc4,
|
||||
0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xcb,0xcc,0xcd,
|
||||
0xce,0xcf,0xd0,0xd1,0xd2,0xd3,0xd4,0xd5,0xd6,
|
||||
0xd7,0xd8,0xd9,0xda,0xdb,0xdc,0xdd,0xde,0xdf,
|
||||
0xe0,0xe1,0xe2,0xe3,0xe4,0xe5,0xe6,0xe7,0xe8,
|
||||
0xea,0xe9,0xf1,0xf2,0xf3,0xf4,0xf5,0xf6,0xf7,
|
||||
0xf8,0xf9,0xfa,
|
||||
/* test soft halant */
|
||||
0xb3, 0xE8, 0xE9,
|
||||
/* test explicit halant */
|
||||
0xb3, 0xE8, 0xE8,
|
||||
/* test double danda */
|
||||
0xea, 0xea,
|
||||
/* test ASCII */
|
||||
0x1B, 0x24, 0x29, 0x47, 0x0E, 0x23, 0x21, 0x23, 0x22, 0x23,
|
||||
0x23, 0x23, 0x24, 0x23, 0x25, 0x23, 0x26, 0x23, 0x27, 0x23,
|
||||
0x28, 0x23, 0x29, 0x23, 0x2A, 0x23, 0x2B, 0x0F, 0x2F, 0x2A,
|
||||
/* test ATR code */
|
||||
|
||||
/* tests from Lotus */
|
||||
0x61,0xEF,0x42,0xEF,0x30,0xB3,0x0D,0x0A,0xEF,0x43,0xB4,0x43,
|
||||
0xEF,0x42,0xCF,0xE8,0xD9,
|
||||
0xEF,0x42,0xA1,0x0D,0x0A,0xEF,0x42,0xA4,0xEF,0x43,0xA4,0x43,
|
||||
0xEF,0x42,0xB3,0xBF,0x2B,0xEF,0x42,0xCE,
|
||||
/* tamil range */
|
||||
0xEF, 0x44, 0xa5, 0xa6, 0xa7,
|
||||
/* telugu range */
|
||||
0xEF, 0x45,0xa4, 0xa2, 0xa3,0xd0,
|
||||
/* kannada range */
|
||||
0xEF, 0x48,0xa4, 0xa2, 0xa3
|
||||
};
|
||||
|
||||
TestConv(in,(sizeof(in)/2),"ISCII,version=0","hindi", (char *)byteArr,sizeof(byteArr));
|
||||
|
||||
}
|
||||
static void
|
||||
TestISO_2022_JP() {
|
||||
/* test input */
|
||||
@ -2315,7 +2495,7 @@ TestISO_2022_JP() {
|
||||
free(offsets);
|
||||
}
|
||||
|
||||
static void TestConv(uint16_t in[],int len, const char* conv, const char* lang, char byteArr[],int byteArrLen){
|
||||
static void TestConv(const uint16_t in[],int len, const char* conv, const char* lang, char byteArr[],int byteArrLen){
|
||||
const UChar* uSource;
|
||||
const UChar* uSourceLimit;
|
||||
const char* cSource;
|
||||
@ -2333,7 +2513,7 @@ static void TestConv(uint16_t in[],int len, const char* conv, const char* lang,
|
||||
int32_t* myOff= offsets;
|
||||
cnv=ucnv_open(conv, &errorCode);
|
||||
if(U_FAILURE(errorCode)) {
|
||||
log_err("Unable to open a SCSU converter: %s\n", u_errorName(errorCode));
|
||||
log_err("Unable to open a %s converter: %s\n", conv, u_errorName(errorCode));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -2350,7 +2530,7 @@ static void TestConv(uint16_t in[],int len, const char* conv, const char* lang,
|
||||
log_err("ucnv_fromUnicode conversion failed reason %s\n", u_errorName(errorCode));
|
||||
return;
|
||||
}
|
||||
log_verbose("length of compressed string for language %s using SCSU:%i \n",lang,(cTarget-cBuf));
|
||||
log_verbose("length of compressed string for language %s using %s:%i \n",conv,lang,(cTarget-cBuf));
|
||||
cSource = cBuf;
|
||||
cSourceLimit =cTarget;
|
||||
test =uBuf;
|
||||
@ -2372,28 +2552,31 @@ static void TestConv(uint16_t in[],int len, const char* conv, const char* lang,
|
||||
TestSmallTargetBuffer(&in[0],(const UChar*)&in[len],cnv);
|
||||
TestSmallSourceBuffer(&in[0],(const UChar*)&in[len],cnv);
|
||||
TestGetNextUChar2022(cnv, cBuf, cTarget, in, conv);
|
||||
TestGetNextUChar2022(cnv, byteArr, (byteArr+byteArrLen), in, lang);
|
||||
TestToAndFromUChars(&in[0],(const UChar*)&in[len],cnv);
|
||||
{
|
||||
cSource = byteArr;
|
||||
cSourceLimit = cSource+byteArrLen;
|
||||
test=uBuf;
|
||||
myOff = offsets;
|
||||
ucnv_toUnicode(cnv,&uTarget,uTargetLimit,&cSource,cSourceLimit,myOff,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) ;
|
||||
if(byteArr && byteArrLen!=0){
|
||||
TestGetNextUChar2022(cnv, byteArr, (byteArr+byteArrLen), in, lang);
|
||||
TestToAndFromUChars(&in[0],(const UChar*)&in[len],cnv);
|
||||
{
|
||||
cSource = byteArr;
|
||||
cSourceLimit = cSource+byteArrLen;
|
||||
test=uBuf;
|
||||
myOff = offsets;
|
||||
ucnv_toUnicode(cnv,&uTarget,uTargetLimit,&cSource,cSourceLimit,myOff,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++;
|
||||
}
|
||||
uSource++;
|
||||
test++;
|
||||
}
|
||||
}
|
||||
|
||||
ucnv_close(cnv);
|
||||
free(uBuf);
|
||||
free(cBuf);
|
||||
@ -2468,12 +2651,51 @@ TestSCSU() {
|
||||
0x41, 0x10, 0xdf, 0x12, 0x81, 0x03, 0x5f, 0x10, 0xdf, 0x13,
|
||||
0xdf, 0x14, 0x80, 0x15, 0xff
|
||||
};
|
||||
TestConv(allFeaturesUTF16,(sizeof(allFeaturesUTF16)/2),"SCSU,locale=ja","all features", (char *)allFeaturesSCSU,sizeof(allFeaturesSCSU));
|
||||
static const uint16_t monkeyIn[]={
|
||||
0x00A8, 0x3003, 0x3005, 0x2015, 0xFF5E, 0x2016, 0x2026, 0x2018, 0x000D, 0x000A,
|
||||
0x2019, 0x201C, 0x201D, 0x3014, 0x3015, 0x3008, 0x3009, 0x300A, 0x000D, 0x000A,
|
||||
0x300B, 0x300C, 0x300D, 0x300E, 0x300F, 0x3016, 0x3017, 0x3010, 0x000D, 0x000A,
|
||||
0x3011, 0x00B1, 0x00D7, 0x00F7, 0x2236, 0x2227, 0x7FC1, 0x8956, 0x000D, 0x000A,
|
||||
0x9D2C, 0x9D0E, 0x9EC4, 0x5CA1, 0x6C96, 0x837B, 0x5104, 0x5C4B, 0x000D, 0x000A,
|
||||
0x61B6, 0x81C6, 0x6876, 0x7261, 0x4E59, 0x4FFA, 0x5378, 0x57F7, 0x000D, 0x000A,
|
||||
0x57F4, 0x57F9, 0x57FA, 0x57FC, 0x5800, 0x5802, 0x5805, 0x5806, 0x000D, 0x000A,
|
||||
0x580A, 0x581E, 0x6BB5, 0x6BB7, 0x6BBA, 0x6BBC, 0x9CE2, 0x977C, 0x000D, 0x000A,
|
||||
0x6BBF, 0x6BC1, 0x6BC5, 0x6BC6, 0x6BCB, 0x6BCD, 0x6BCF, 0x6BD2, 0x000D, 0x000A,
|
||||
0x6BD3, 0x6BD4, 0x6BD6, 0x6BD7, 0x6BD8, 0x6BDB, 0x6BEB, 0x6BEC, 0x000D, 0x000A,
|
||||
0x6C05, 0x6C08, 0x6C0F, 0x6C11, 0x6C13, 0x6C23, 0x6C34, 0x0041, 0x000D, 0x000A,
|
||||
0x0043, 0x0044, 0x0045, 0x0046, 0x0047, 0x0048, 0x0049, 0x004A, 0x000D, 0x000A,
|
||||
0x004B, 0x004C, 0x004D, 0x004E, 0x004F, 0x0050, 0x0051, 0x0052, 0x000D, 0x000A,
|
||||
0x0053, 0x0054, 0x0055, 0x0056, 0x0057, 0x0058, 0x0059, 0x005A, 0x000D, 0x000A,
|
||||
0x005B, 0x9792, 0x9CCC, 0x9CCD, 0x9CCE, 0x9CCF, 0x9CD0, 0x9CD3, 0x000D, 0x000A,
|
||||
0x9CD4, 0x9CD5, 0x9CD7, 0x9CD8, 0x9CD9, 0x9CDC, 0x9CDD, 0x9CDF, 0x000D, 0x000A,
|
||||
0x9785, 0x9791, 0x00BD, 0x0390, 0x0385, 0x0386, 0x0388, 0x0389, 0x000D, 0x000A,
|
||||
0x038E, 0x038F, 0x0390, 0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x000D, 0x000A,
|
||||
0x0396, 0x0397, 0x0398, 0x0399, 0x039A, 0x038A, 0x038C, 0x039C, 0x000D, 0x000A,
|
||||
/* test non-BMP code points */
|
||||
0xD869, 0xDE99, 0xD869, 0xDE9C, 0xD869, 0xDE9D, 0xD869, 0xDE9E, 0xD869, 0xDE9F,
|
||||
0xD869, 0xDEA0, 0xD869, 0xDEA5, 0xD869, 0xDEA6, 0xD869, 0xDEA7, 0xD869, 0xDEA8,
|
||||
0xD869, 0xDEAB, 0xD869, 0xDEAC, 0xD869, 0xDEAD, 0xD869, 0xDEAE, 0xD869, 0xDEAF,
|
||||
0xD869, 0xDEB0, 0xD869, 0xDEB1, 0xD869, 0xDEB3, 0xD869, 0xDEB5, 0xD869, 0xDEB6,
|
||||
0xD869, 0xDEB7, 0xD869, 0xDEB8, 0xD869, 0xDEB9, 0xD869, 0xDEBA, 0xD869, 0xDEBB,
|
||||
0xD869, 0xDEBC, 0xD869, 0xDEBD, 0xD869, 0xDEBE, 0xD869, 0xDEBF, 0xD869, 0xDEC0,
|
||||
0xD869, 0xDEC1, 0xD869, 0xDEC2, 0xD869, 0xDEC3, 0xD869, 0xDEC4, 0xD869, 0xDEC8,
|
||||
0xD869, 0xDECA, 0xD869, 0xDECB, 0xD869, 0xDECD, 0xD869, 0xDECE, 0xD869, 0xDECF,
|
||||
0xD869, 0xDED0, 0xD869, 0xDED1, 0xD869, 0xDED2, 0xD869, 0xDED3, 0xD869, 0xDED4,
|
||||
0xD869, 0xDED5,
|
||||
|
||||
0x4DB3, 0x4DB4, 0x4DB5, 0x4E00, 0x4E00, 0x4E01, 0x4E02, 0x4E03, 0x000D, 0x000A,
|
||||
0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397, 0x33E0, 0x33E6, 0x000D, 0x000A,
|
||||
0x4E05, 0x4E07, 0x4E04, 0x4E08, 0x4E08, 0x4E09, 0x4E0A, 0x4E0B, 0x000D, 0x000A,
|
||||
0x4E0C, 0x0021, 0x0022, 0x0023, 0x0024, 0xFF40, 0xFF41, 0xFF42, 0x000D, 0x000A,
|
||||
0xFF43, 0xFF44, 0xFF45, 0xFF46, 0xFF47, 0xFF48, 0xFF49, 0xFF4A, 0x000D, 0x000A,
|
||||
};
|
||||
TestConv(allFeaturesUTF16,(sizeof(allFeaturesUTF16)/2),"SCSU","all features", (char *)allFeaturesSCSU,sizeof(allFeaturesSCSU));
|
||||
TestConv(allFeaturesUTF16,(sizeof(allFeaturesUTF16)/2),"SCSU","all features",(char *)allFeaturesSCSU,sizeof(allFeaturesSCSU));
|
||||
TestConv(japaneseUTF16,(sizeof(japaneseUTF16)/2),"SCSU","japaneese",(char *)japaneseSCSU,sizeof(japaneseSCSU));
|
||||
TestConv(japaneseUTF16,(sizeof(japaneseUTF16)/2),"SCSU,locale=ja","japaneese",(char *)japaneseSCSU,sizeof(japaneseSCSU));
|
||||
TestConv(germanUTF16,(sizeof(germanUTF16)/2),"SCSU","german",(char *)germanSCSU,sizeof(germanSCSU));
|
||||
TestConv(russianUTF16,(sizeof(russianUTF16)/2), "SCSU","russian",(char *)russianSCSU,sizeof(russianSCSU));
|
||||
TestConv(monkeyIn,(sizeof(monkeyIn)/2),"SCSU","monkey",NULL,0);
|
||||
}
|
||||
static void
|
||||
TestISO_2022_JP_1() {
|
||||
|
Loading…
Reference in New Issue
Block a user