mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-08 06:53:45 +00:00
ICU-535 fixed some compiler warnings
X-SVN-Rev: 2190
This commit is contained in:
parent
8767d1596f
commit
f2f6b304bd
1 changed files with 218 additions and 229 deletions
|
@ -8,7 +8,7 @@
|
|||
* File CCONVTST.C
|
||||
*
|
||||
* Modification History:
|
||||
* Name Description
|
||||
* Name Description
|
||||
* Madhu Katragadda 7/7/2000 Converter Tests for extended code coverage
|
||||
*********************************************************************************
|
||||
*/
|
||||
|
@ -40,14 +40,14 @@ static void printSeq(const unsigned char* a, int len);
|
|||
static void printSeqErr(const unsigned char* a, int len);
|
||||
static void printUSeq(const UChar* a, int len);
|
||||
static void printUSeqErr(const UChar* a, int len);
|
||||
static UBool convertFromU( const UChar *source, int sourceLen, const char *expect, int expectLen,
|
||||
static UBool convertFromU( const UChar *source, int sourceLen, const uint8_t *expect, int expectLen,
|
||||
const char *codepage, int32_t *expectOffsets, UBool doFlush, UErrorCode expectedStatus);
|
||||
static UBool convertToU( const char *source, int sourceLen, const UChar *expect, int expectLen,
|
||||
static UBool convertToU( const uint8_t *source, int sourceLen, const UChar *expect, int expectLen,
|
||||
const char *codepage, int32_t *expectOffsets, UBool doFlush, UErrorCode expectedStatus);
|
||||
|
||||
static UBool testConvertFromU( const UChar *source, int sourceLen, const char *expect, int expectLen,
|
||||
static UBool testConvertFromU( const UChar *source, int sourceLen, const uint8_t *expect, int expectLen,
|
||||
const char *codepage, UConverterFromUCallback callback, int32_t *expectOffsets);
|
||||
static UBool testConvertToU( const char *source, int sourcelen, const UChar *expect, int expectlen,
|
||||
static UBool testConvertToU( const uint8_t *source, int sourcelen, const UChar *expect, int expectlen,
|
||||
const char *codepage, UConverterToUCallback callback, int32_t *expectOffsets);
|
||||
|
||||
static void setNuConvTestName(const char *codepage, const char *direction)
|
||||
|
@ -116,27 +116,25 @@ void addExtraTests(TestNode** root)
|
|||
void TestSurrogateBehaviour(){
|
||||
log_verbose("Testing for SBCS and LATIN_1\n");
|
||||
{
|
||||
UChar sampleText[] = { 0x0031, 0xd801, 0xdc01, 0x0032};
|
||||
const char expected[] =
|
||||
{ (char)0x31, (char)0x1a, (char)0x32};
|
||||
UChar sampleText[] = {0x0031, 0xd801, 0xdc01, 0x0032};
|
||||
const uint8_t expected[] = {0x31, 0x1a, 0x32};
|
||||
/*SBCS*/
|
||||
if(!convertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
|
||||
expected, sizeof(expected), "ibm-920", 0 , TRUE, U_ZERO_ERROR))
|
||||
log_err("u-> ibm-920 [UCNV_SBCS] not match.\n");
|
||||
|
||||
|
||||
/*LATIN_1*/
|
||||
if(!convertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
|
||||
expected, sizeof(expected), "LATIN_1", 0, TRUE, U_ZERO_ERROR ))
|
||||
log_err("u-> LATIN_1 not match.\n");
|
||||
|
||||
|
||||
}
|
||||
log_verbose("Testing for DBCS and MBCS\n");
|
||||
{
|
||||
UChar sampleText[] = { 0x00a1, 0xd801, 0xdc01, 0x00a4};
|
||||
const char expected[] =
|
||||
{ (char)0xa2, (char)0xae, (char)0xa1, (char)0xe0, (char)0xa2, (char)0xb4};
|
||||
int32_t offsets[]={(char)0x00, (char)0x00, (char)0x01, (char)0x01, (char)0x03 };
|
||||
|
||||
UChar sampleText[] = {0x00a1, 0xd801, 0xdc01, 0x00a4};
|
||||
const uint8_t expected[] = {0xa2, 0xae, 0xa1, 0xe0, 0xa2, 0xb4};
|
||||
int32_t offsets[] = {0x00, 0x00, 0x01, 0x01, 0x03 };
|
||||
|
||||
/*DBCS*/
|
||||
if(!convertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
|
||||
expected, sizeof(expected), "ibm-1362", 0 , TRUE, U_ZERO_ERROR))
|
||||
|
@ -156,14 +154,13 @@ void TestSurrogateBehaviour(){
|
|||
log_verbose("Testing for UTF8\n");
|
||||
{
|
||||
UChar sampleText[] = { 0x4e00, 0x0701, 0x0031, 0xbfc1, 0xd801, 0xdc01, 0x0032};
|
||||
int32_t offsets[]={(char)0x00, (char)0x00, (char)0x00, (char)0x01, (char)0x01, (char)0x02,
|
||||
(char)0x03, (char)0x03, (char)0x03, (char)0x04, (char)0x04, (char)0x04,
|
||||
(char)0x04, (char)0x06 };
|
||||
const char expected[] =
|
||||
{ (char)0xe4, (char)0xb8, (char)0x80, (char)0xdc, (char)0x81, (char)0x31,
|
||||
(char)0xeb, (char)0xbf, (char)0x81, (char)0xF0, (char)0x90, (char)0x90, (char)0x81, (char)0x32};
|
||||
|
||||
|
||||
int32_t offsets[]={0x00, 0x00, 0x00, 0x01, 0x01, 0x02,
|
||||
0x03, 0x03, 0x03, 0x04, 0x04, 0x04,
|
||||
0x04, 0x06 };
|
||||
const uint8_t expected[] = {0xe4, 0xb8, 0x80, 0xdc, 0x81, 0x31,
|
||||
0xeb, 0xbf, 0x81, 0xF0, 0x90, 0x90, 0x81, 0x32};
|
||||
|
||||
|
||||
int32_t fromOffsets[] = { 0x0000, 0x0003, 0x0005, 0x0006, 0x0009, 0x0009, 0x000D };
|
||||
/*UTF-8*/
|
||||
if(!convertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
|
||||
|
@ -178,7 +175,7 @@ void TestSurrogateBehaviour(){
|
|||
if(!convertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
|
||||
expected, sizeof(expected), "UTF8", 0, FALSE, U_ZERO_ERROR ))
|
||||
log_err("u-> UTF8 with offsets and flush true did not match.\n");
|
||||
|
||||
|
||||
if(!convertToU(expected, sizeof(expected),
|
||||
sampleText, sizeof(sampleText)/sizeof(sampleText[0]), "UTF8", 0, TRUE, U_ZERO_ERROR ))
|
||||
log_err("UTF8 -> did not match.\n");
|
||||
|
@ -191,27 +188,24 @@ void TestSurrogateBehaviour(){
|
|||
if(!convertToU(expected, sizeof(expected),
|
||||
sampleText, sizeof(sampleText)/sizeof(sampleText[0]), "UTF8", fromOffsets, FALSE, U_ZERO_ERROR ))
|
||||
log_err("UTF8 -> did not match.\n");
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/*test various error behaviours*/
|
||||
void TestErrorBehaviour(){
|
||||
log_verbose("Testing for SBCS and LATIN_1\n");
|
||||
log_verbose("Testing for SBCS and LATIN_1\n");
|
||||
{
|
||||
#if 0
|
||||
/*commented untill further modifications in the source*/
|
||||
UChar sampleText[] = { 0x0031, 0xd801};
|
||||
UChar sampleText2[] = { 0x0031, 0xd801, 0x0032};
|
||||
const char expectedFlushTrue[] =
|
||||
{ (char)0x31, (char)0x1a,};
|
||||
const char expected[] =
|
||||
{ (char)0x31, };
|
||||
const char expected2[] =
|
||||
{ (char)0x31, (char)0x1a, (char)0x32};
|
||||
|
||||
#if 0
|
||||
/*commented untill further modifications in the source*/
|
||||
const uint8_t expectedFlushTrue[] = { 0x31, 0x1a};
|
||||
const uint8_t expected[] = { 0x31, };
|
||||
const uint8_t expected2[] = { 0x31, 0x1a, 0x32};
|
||||
|
||||
/*SBCS*/
|
||||
if(!convertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
|
||||
expectedFlushTrue, sizeof(expectedFlushTrue), "ibm-920", 0, TRUE, U_TRUNCATED_CHAR_FOUND))
|
||||
|
@ -222,8 +216,8 @@ void TestErrorBehaviour(){
|
|||
if(!convertFromU(sampleText2, sizeof(sampleText2)/sizeof(sampleText2[0]),
|
||||
expected2, sizeof(expected2), "ibm-920", 0, TRUE, U_ZERO_ERROR))
|
||||
log_err("u-> ibm-920 [UCNV_SBCS] did not match\n");
|
||||
|
||||
|
||||
|
||||
|
||||
/*LATIN_1*/
|
||||
if(!convertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
|
||||
expectedFlushTrue, sizeof(expectedFlushTrue), "LATIN_1", 0, TRUE, U_TRUNCATED_CHAR_FOUND))
|
||||
|
@ -231,39 +225,35 @@ void TestErrorBehaviour(){
|
|||
if(!convertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
|
||||
expected, sizeof(expected), "LATIN_1", 0, FALSE, U_ZERO_ERROR))
|
||||
log_err("u-> LATIN_1 is supposed to fail\n");
|
||||
|
||||
|
||||
if(!convertFromU(sampleText2, sizeof(sampleText2)/sizeof(sampleText2[0]),
|
||||
expected2, sizeof(expected2), "LATIN_1", 0, TRUE, U_ZERO_ERROR))
|
||||
log_err("u-> LATIN_1 did not match\n");
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
log_verbose("Testing for DBCS and MBCS\n");
|
||||
log_verbose("Testing for DBCS and MBCS\n");
|
||||
{
|
||||
UChar sampleText[] = { 0x00a1, 0xd801};
|
||||
const char expected[]=
|
||||
{ (char)0xa2, (char)0xae};
|
||||
int32_t offsets[]={(char)0x00, (char)0x01, (char)0x02};
|
||||
|
||||
UChar sampleText2[] = { 0x00a1, 0xd801, 0x00a4};
|
||||
const char expected2[] =
|
||||
{ (char)0xa2, (char)0xae, (char)0xa1, (char)0xe0, (char)0xa2, (char)0xb4};
|
||||
UChar sampleText[] = { 0x00a1, 0xd801};
|
||||
const uint8_t expected[] = { 0xa2, 0xae};
|
||||
int32_t offsets[] = { 0x00, 0x01, 0x02};
|
||||
|
||||
UChar sampleText3MBCS[] = { 0x0001, 0x00a4, 0xdc01};
|
||||
const char expected3MBCS[] =
|
||||
{ (char)0x01, (char)0xa2, (char)0xb4, (char)0xa1, (char)0xe0};
|
||||
int32_t offsets3MBCS[] = { (char)0x00, (char)0x01, (char)0x02 };
|
||||
UChar sampleText2[] = { 0x00a1, 0xd801, 0x00a4};
|
||||
const uint8_t expected2[] = { 0xa2, 0xae, 0xa1, 0xe0, 0xa2, 0xb4};
|
||||
|
||||
UChar sampleText4MBCS[] = { 0x0061, 0x00a6, 0xdc01};
|
||||
const char expected4MBCS[] =
|
||||
{ (char)0x61, (char)0x8f, (char)0xa2, (char)0xc3, (char)0xf4, (char)0xfe};
|
||||
int32_t offsets4MBCS[] = { (char)0x00, (char)0x01, (char)0x02 };
|
||||
UChar sampleText3MBCS[] = { 0x0001, 0x00a4, 0xdc01};
|
||||
const uint8_t expected3MBCS[] = { 0x01, 0xa2, 0xb4, 0xa1, 0xe0};
|
||||
int32_t offsets3MBCS[] = { 0x00, 0x01, 0x02 };
|
||||
|
||||
|
||||
UChar sampleText4MBCS[] = { 0x0061, 0x00a6, 0xdc01};
|
||||
const uint8_t expected4MBCS[] = { 0x61, 0x8f, 0xa2, 0xc3, 0xf4, 0xfe};
|
||||
int32_t offsets4MBCS[] = { 0x00, 0x01, 0x02 };
|
||||
|
||||
|
||||
|
||||
#if 0
|
||||
|
||||
|
||||
|
||||
|
||||
#if 0
|
||||
/*commented untill further modifications in the source*/
|
||||
/*DBCS*/
|
||||
if(!convertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
|
||||
|
@ -280,7 +270,7 @@ void TestErrorBehaviour(){
|
|||
expected2, sizeof(expected2), "ibm-1362", offsets, TRUE, U_ZERO_ERROR))
|
||||
log_err("u-> ibm-1362 [UCNV_DBCS] did not match \n");
|
||||
#endif
|
||||
|
||||
|
||||
/*MBCS*/
|
||||
if(!convertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
|
||||
expected, sizeof(expected), "ibm-1363", 0, TRUE, U_TRUNCATED_CHAR_FOUND))
|
||||
|
@ -288,7 +278,7 @@ void TestErrorBehaviour(){
|
|||
if(!convertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
|
||||
expected, sizeof(expected), "ibm-1363", 0, FALSE, U_ZERO_ERROR))
|
||||
log_err("u-> ibm-1363 [UCNV_MBCS] \n");
|
||||
|
||||
|
||||
if(!convertFromU(sampleText2, sizeof(sampleText2)/sizeof(sampleText2[0]),
|
||||
expected2, sizeof(expected2), "ibm-1363", 0, TRUE, U_ZERO_ERROR))
|
||||
log_err("u-> ibm-1363 [UCNV_DBCS] did not match\n");
|
||||
|
@ -312,20 +302,20 @@ void TestErrorBehaviour(){
|
|||
if(!convertFromU(sampleText4MBCS, sizeof(sampleText4MBCS)/sizeof(sampleText4MBCS[0]),
|
||||
expected4MBCS, sizeof(expected4MBCS), "euc-jp", offsets4MBCS, FALSE, U_ZERO_ERROR))
|
||||
log_err("u-> euc-jp [UCNV_MBCS] \n");
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/*test different convertToUnicode error behaviours*/
|
||||
void TestToUnicodeErrorBehaviour()
|
||||
{
|
||||
log_verbose("Testing error conditions for DBCS\n");
|
||||
{
|
||||
char sampleText[] = { (char)0xa2, (char)0xae, (char)0x03, (char)0x04};
|
||||
uint8_t sampleText[] = { 0xa2, 0xae, 0x03, 0x04};
|
||||
const UChar expected[] = { 0x00a1 };
|
||||
|
||||
char sampleText2[] = { (char)0xa2, (char)0xae, (char)0xa2};
|
||||
uint8_t sampleText2[] = { 0xa2, 0xae, 0xa2};
|
||||
const UChar expected2[] = { 0x00a1 };
|
||||
|
||||
if(!convertToU(sampleText, sizeof(sampleText),
|
||||
|
@ -341,14 +331,14 @@ void TestToUnicodeErrorBehaviour()
|
|||
|
||||
|
||||
}
|
||||
log_verbose("Testing error conditions for SBCS\n");
|
||||
log_verbose("Testing error conditions for SBCS\n");
|
||||
{
|
||||
char sampleText[] = { (char)0xa2, (char)0xFF};
|
||||
uint8_t sampleText[] = { 0xa2, 0xFF};
|
||||
const UChar expected[] = { 0x00c2 };
|
||||
|
||||
char sampleText2[] = { (char)0xa2, (char)0x70 };
|
||||
uint8_t sampleText2[] = { 0xa2, 0x70 };
|
||||
const UChar expected2[] = { 0x0073 };
|
||||
|
||||
|
||||
if(!convertToU(sampleText, sizeof(sampleText),
|
||||
expected, sizeof(expected)/sizeof(expected[0]), "ibm-1051", 0, TRUE, U_ZERO_ERROR ))
|
||||
log_err("SBCS (ibm-1051)->Unicode did not match.\n");
|
||||
|
@ -356,20 +346,20 @@ void TestToUnicodeErrorBehaviour()
|
|||
expected, sizeof(expected)/sizeof(expected[0]), "ibm-1051", 0, FALSE, U_ZERO_ERROR ))
|
||||
log_err("SBCS (ibm-1051)->Unicode with flush = false did not match.\n");
|
||||
|
||||
}
|
||||
log_verbose("Testing error conditions for UTF8\n");
|
||||
}
|
||||
log_verbose("Testing error conditions for UTF8\n");
|
||||
{
|
||||
const char sampleText[] = { (char)0x31, (char)0xe4, (char)0xba, (char)0x8c, (char)0xe4, (char)0xb8, };
|
||||
const uint8_t sampleText[] = { 0x31, 0xe4, 0xba, 0x8c, 0xe4, 0xb8, };
|
||||
UChar expectedUTF8[] = { 0x0031, 0x4e8c};
|
||||
int32_t offsets[] = { 0x0000, 0x0001};
|
||||
|
||||
const char sampleText2[] = { (char)0x31, (char)0xff, (char)0xe4, (char)0xba, (char)0x8c,
|
||||
(char)0xe0, (char)0x80, (char)0x61,};
|
||||
const uint8_t sampleText2[] = { 0x31, 0xff, 0xe4, 0xba, 0x8c,
|
||||
0xe0, 0x80, 0x61,};
|
||||
UChar expected2UTF8[] = { 0x0031, 0xfffd, 0x4e8c, 0xfffd, 0x0061};
|
||||
int32_t offsets2[] = { 0x0000, 0x0001, 0x0002, 0x0005, 0x0007};
|
||||
|
||||
const char sampleText3[] = { (char)0x31, (char)0xfb, (char)0xbf, (char)0xbf, (char)0xbf, (char)0xbf,
|
||||
(char)0x61,};
|
||||
const uint8_t sampleText3[] = { 0x31, 0xfb, 0xbf, 0xbf, 0xbf, 0xbf,
|
||||
0x61,};
|
||||
UChar expected3UTF8[] = { 0x0031, 0xfffd, 0x0061};
|
||||
int32_t offsets3[] = { 0x0000, 0x0001, 0x0006};
|
||||
|
||||
|
@ -407,12 +397,12 @@ void TestToUnicodeErrorBehaviour()
|
|||
log_err("utf-8->Unicode did not match with flush false.\n");
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
void TestGetNextErrorBehaviour(){
|
||||
/*Test for unassigned character*/
|
||||
static const char input1[]={ (char)0x70 };
|
||||
static const char input1[]={ 0x70 };
|
||||
const char* source=(const char*)input1;
|
||||
UErrorCode err=U_ZERO_ERROR;
|
||||
UChar32 c=0;
|
||||
|
@ -426,14 +416,14 @@ void TestGetNextErrorBehaviour(){
|
|||
log_err("FAIL in TestGetNextErrorBehaviour(unassigned): Expected: U_INVALID_CHAR_ERROR or 0xfffd ----Got:%s and 0x%lx\n", myErrorName(err), c);
|
||||
}
|
||||
ucnv_close(cnv);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/*Regression test for utf8 converter*/
|
||||
void TestRegression(){
|
||||
char *buffer=0;
|
||||
uint8_t *buffer=0;
|
||||
UChar32 c;
|
||||
char *targ;
|
||||
char *targetLimit;
|
||||
|
@ -445,9 +435,9 @@ void TestRegression(){
|
|||
UChar *target=0;
|
||||
UChar *limit=0;
|
||||
int32_t count=0;
|
||||
|
||||
|
||||
int32_t offset=0;
|
||||
int32_t sourceLength=0, i=0;
|
||||
int32_t i=0;
|
||||
UErrorCode status=U_ZERO_ERROR;
|
||||
UConverter *conv=ucnv_open("utf8", &status);
|
||||
if(U_FAILURE(status)) {
|
||||
|
@ -455,10 +445,10 @@ void TestRegression(){
|
|||
}
|
||||
source=(UChar*)malloc(sizeof(UChar) * TEST_BUFFER_SIZE);
|
||||
extractedTargetBuffer=(UChar*)malloc(sizeof(UChar) * TEST_BUFFER_SIZE);
|
||||
buffer=(char*)malloc(sizeof(char) * TEST_BUFFER_SIZE);
|
||||
buffer=(uint8_t*)malloc(sizeof(char) * TEST_BUFFER_SIZE);
|
||||
|
||||
for(i =0; i< TEST_BUFFER_SIZE; i++){
|
||||
buffer[i]=(char)0xF0;
|
||||
buffer[i]=0xF0;
|
||||
source[i]=(UChar)0xFFFE;
|
||||
extractedTargetBuffer[i]=(UChar)0xFFFE;
|
||||
}
|
||||
|
@ -470,7 +460,7 @@ void TestRegression(){
|
|||
|
||||
src=source;
|
||||
sourceLimit=src+(offset);
|
||||
targ=buffer;
|
||||
targ=(char *)buffer;
|
||||
targetLimit=targ+(TEST_BUFFER_SIZE);
|
||||
ucnv_fromUnicode (conv,
|
||||
&targ,
|
||||
|
@ -484,10 +474,10 @@ void TestRegression(){
|
|||
log_err("FAILED: error= %s at offset=0x%04X and target=0x%02X\n", myErrorName(status), (UNICODE_LIMIT-(sourceLimit-src)/sizeof(UChar)) , *targ);
|
||||
}
|
||||
|
||||
log_verbose("The No: of bytes in target buffer =%ld\n", targ-buffer);
|
||||
|
||||
targetLimit=targ;
|
||||
targ=buffer;
|
||||
log_verbose("The No: of bytes in target buffer =%ld\n", (const char *)(targ-(const char *)buffer));
|
||||
|
||||
targetLimit=targ;
|
||||
targ=(char *)buffer;
|
||||
|
||||
extractedTarget=extractedTargetBuffer;
|
||||
limit=extractedTarget+TEST_BUFFER_SIZE;
|
||||
|
@ -558,81 +548,80 @@ void TestWithBufferSize(int32_t insize, int32_t outsize){
|
|||
{
|
||||
UChar sampleText[] =
|
||||
{ 0x0031, 0x0032, 0x0033, 0x0000, 0x4e00, 0x4e8c, 0x4e09, 0x002E };
|
||||
const char expectedUTF8[] =
|
||||
{ (char)0x31, (char)0x32, (char)0x33, (char)0x00, (char)0xe4, (char)0xb8, (char)0x80, (char)0xe4, (char)0xba, (char)0x8c, (char)0xe4, (char)0xb8, (char)0x89, (char)0x2E };
|
||||
const uint8_t expectedUTF8[] =
|
||||
{ 0x31, 0x32, 0x33, 0x00, 0xe4, 0xb8, 0x80, 0xe4, 0xba, 0x8c, 0xe4, 0xb8, 0x89, 0x2E };
|
||||
int32_t toUTF8Offs[] =
|
||||
{ (char)0x00, (char)0x01, (char)0x02, (char)0x03, (char)0x04, (char)0x04, (char)0x04, (char)0x05, (char)0x05, (char)0x05, (char)0x06, (char)0x06, (char)0x06, (char)0x07};
|
||||
{ 0x00, 0x01, 0x02, 0x03, 0x04, 0x04, 0x04, 0x05, 0x05, 0x05, 0x06, 0x06, 0x06, 0x07};
|
||||
int32_t fmUTF8Offs[] =
|
||||
{ 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0007, 0x000a, 0x000d };
|
||||
|
||||
|
||||
/*UTF-8*/
|
||||
if(!testConvertFromU(sampleText, sizeof(sampleText)/sizeof(sampleText[0]),
|
||||
expectedUTF8, sizeof(expectedUTF8), "UTF8", UCNV_FROM_U_CALLBACK_SUBSTITUTE, toUTF8Offs ))
|
||||
log_err("u-> UTF8 did not match.\n");
|
||||
}
|
||||
|
||||
|
||||
log_verbose("Testing fromUnicode with UCNV_FROM_U_CALLBACK_ESCAPE \n");
|
||||
{
|
||||
UChar inputTest[] = { 0x0061, 0xd801, 0xdc01, 0xd801, 0x0061 };
|
||||
const char toIBM943[]= { (char)0x61,
|
||||
(char)0x25, (char)0x55, (char)0x44, (char)0x38, (char)0x30, (char)0x31,
|
||||
(char)0x25, (char)0x55, (char)0x44, (char)0x43, (char)0x30, (char)0x31,
|
||||
(char)0x25, (char)0x55, (char)0x44, (char)0x38, (char)0x30, (char)0x31,
|
||||
(char)0x61 };
|
||||
const uint8_t toIBM943[]= { 0x61,
|
||||
0x25, 0x55, 0x44, 0x38, 0x30, 0x31,
|
||||
0x25, 0x55, 0x44, 0x43, 0x30, 0x31,
|
||||
0x25, 0x55, 0x44, 0x38, 0x30, 0x31,
|
||||
0x61 };
|
||||
int32_t offset[]= {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 3, 4};
|
||||
|
||||
if(!testConvertFromU(inputTest, sizeof(inputTest)/sizeof(inputTest[0]),
|
||||
toIBM943, sizeof(toIBM943), "ibm-943",
|
||||
(UConverterFromUCallback)UCNV_FROM_U_CALLBACK_ESCAPE, offset))
|
||||
log_err("u-> ibm-943 with subst with value did not match.\n");
|
||||
toIBM943, sizeof(toIBM943), "ibm-943",
|
||||
(UConverterFromUCallback)UCNV_FROM_U_CALLBACK_ESCAPE, offset))
|
||||
log_err("u-> ibm-943 with subst with value did not match.\n");
|
||||
}
|
||||
|
||||
log_verbose("Testing fromUnicode for UTF-8 with UCNV_TO_U_CALLBACK_SUBSTITUTE \n");
|
||||
{
|
||||
const char sampleText1[] = { (char)0x31, (char)0xe4, (char)0xba, (char)0x8c,
|
||||
(char)0xe0, (char)0x80, (char)0x61,};
|
||||
const uint8_t sampleText1[] = { 0x31, 0xe4, 0xba, 0x8c,
|
||||
0xe0, 0x80, 0x61,};
|
||||
UChar expected1[] = { 0x0031, 0x4e8c, 0xfffd, 0x0061};
|
||||
int32_t offsets1[] = { 0x0000, 0x0001, 0x0004, 0x0006};
|
||||
|
||||
if(!testConvertToU(sampleText1, sizeof(sampleText1),
|
||||
expected1, sizeof(expected1)/sizeof(expected1[0]),"utf8", UCNV_TO_U_CALLBACK_SUBSTITUTE, offsets1))
|
||||
log_err("utf8->u with substitute did not match.\n");;
|
||||
expected1, sizeof(expected1)/sizeof(expected1[0]),"utf8", UCNV_TO_U_CALLBACK_SUBSTITUTE, offsets1))
|
||||
log_err("utf8->u with substitute did not match.\n");;
|
||||
}
|
||||
|
||||
|
||||
|
||||
log_verbose("Testing toUnicode with UCNV_TO_U_CALLBACK_ESCAPE \n");
|
||||
/*to Unicode*/
|
||||
{
|
||||
const char sampleTxtToU[]= { (char)0x00, (char)0x9f, (char)0xaf,
|
||||
(char)0x81, (char)0xad, /*unassigned*/
|
||||
(char)0x89, (char)0xd3 };
|
||||
UChar IBM_943toUnicode[] = { 0x0000, 0x6D63,
|
||||
const uint8_t sampleTxtToU[]= { 0x00, 0x9f, 0xaf,
|
||||
0x81, 0xad, /*unassigned*/
|
||||
0x89, 0xd3 };
|
||||
UChar IBM_943toUnicode[] = { 0x0000, 0x6D63,
|
||||
0x25, 0x58, 0x38, 0x31, 0x25, 0x58, 0x41, 0x44,
|
||||
0x7B87};
|
||||
int32_t fromIBM943Offs [] = { 0, 1, 3, 3, 3, 3, 3, 3, 3, 3, 5};
|
||||
int32_t fromIBM943Offs [] = { 0, 1, 3, 3, 3, 3, 3, 3, 3, 3, 5};
|
||||
|
||||
if(!testConvertToU(sampleTxtToU, sizeof(sampleTxtToU),
|
||||
IBM_943toUnicode, sizeof(IBM_943toUnicode)/sizeof(IBM_943toUnicode[0]),"ibm-943",
|
||||
(UConverterToUCallback)UCNV_TO_U_CALLBACK_ESCAPE, fromIBM943Offs))
|
||||
log_err("ibm-943->u with substitute with value did not match.\n");
|
||||
IBM_943toUnicode, sizeof(IBM_943toUnicode)/sizeof(IBM_943toUnicode[0]),"ibm-943",
|
||||
(UConverterToUCallback)UCNV_TO_U_CALLBACK_ESCAPE, fromIBM943Offs))
|
||||
log_err("ibm-943->u with substitute with value did not match.\n");
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
UBool convertFromU( const UChar *source, int sourceLen, const char *expect, int expectLen,
|
||||
UBool convertFromU( const UChar *source, int sourceLen, const uint8_t *expect, int expectLen,
|
||||
const char *codepage, int32_t *expectOffsets, UBool doFlush, UErrorCode expectedStatus)
|
||||
{
|
||||
|
||||
|
||||
int32_t i=0;
|
||||
char *p=0;
|
||||
uint8_t *p=0;
|
||||
const UChar *src;
|
||||
char buffer[MAX_LENGTH];
|
||||
uint8_t buffer[MAX_LENGTH];
|
||||
int32_t offsetBuffer[MAX_LENGTH];
|
||||
int32_t *offs=0;
|
||||
char *targ;
|
||||
char *targetLimit;
|
||||
uint8_t *targ;
|
||||
uint8_t *targetLimit;
|
||||
UChar *sourceLimit=0;
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
UConverter *conv = 0;
|
||||
|
@ -643,9 +632,9 @@ UBool convertFromU( const UChar *source, int sourceLen, const char *expect, int
|
|||
return FALSE;
|
||||
}
|
||||
log_verbose("Converter %s opened..\n", ucnv_getName(conv, &status));
|
||||
|
||||
|
||||
for(i=0; i<MAX_LENGTH; i++){
|
||||
buffer[i]=(char)0xF0;
|
||||
buffer[i]=0xF0;
|
||||
offsetBuffer[i]=0xFF;
|
||||
}
|
||||
|
||||
|
@ -655,8 +644,8 @@ UBool convertFromU( const UChar *source, int sourceLen, const char *expect, int
|
|||
targetLimit=targ+MAX_LENGTH;
|
||||
offs=offsetBuffer;
|
||||
ucnv_fromUnicode (conv,
|
||||
&targ,
|
||||
targetLimit,
|
||||
(char **)&targ,
|
||||
(const char *)targetLimit,
|
||||
&src,
|
||||
sourceLimit,
|
||||
expectOffsets ? offs : NULL,
|
||||
|
@ -666,16 +655,16 @@ UBool convertFromU( const UChar *source, int sourceLen, const char *expect, int
|
|||
if(status != expectedStatus){
|
||||
log_err("ucnv_fromUnicode() failed for codepage=%s. Error =%s Expected=%s\n", codepage, myErrorName(status), myErrorName(expectedStatus));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
log_verbose("\nConversion done [%d uchars in -> %d chars out]. \nResult :",
|
||||
sourceLen, targ-buffer);
|
||||
|
||||
|
||||
if(expectLen != targ-buffer)
|
||||
{
|
||||
log_err("Expected %d chars out, got %d FROM Unicode to %s\n", expectLen, targ-buffer, codepage);
|
||||
log_verbose("Expected %d chars out, got %d FROM Unicode to %s\n", expectLen, targ-buffer, codepage);
|
||||
printSeqErr((const unsigned char *)buffer, targ-buffer);
|
||||
printSeqErr((const unsigned char *)buffer, targ-buffer);
|
||||
printSeqErr(expect, expectLen);
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -698,34 +687,34 @@ UBool convertFromU( const UChar *source, int sourceLen, const char *expect, int
|
|||
if(memcmp(offsetBuffer,expectOffsets,(targ-buffer) * sizeof(int32_t) )){
|
||||
log_err("did not get the expected offsets. for FROM Unicode to %s\n", codepage);
|
||||
printf("\nGot : ");
|
||||
printSeqErr(buffer, targ-buffer);
|
||||
for(p=buffer;p<targ;p++)
|
||||
printf("%d, ", offsetBuffer[p-buffer]);
|
||||
printf("\nExpected: ");
|
||||
for(i=0; i< (targ-buffer); i++)
|
||||
printf("%d,", expectOffsets[i]);
|
||||
printSeqErr(buffer, targ-buffer);
|
||||
for(p=buffer;p<targ;p++)
|
||||
printf("%d, ", offsetBuffer[p-buffer]);
|
||||
printf("\nExpected: ");
|
||||
for(i=0; i< (targ-buffer); i++)
|
||||
printf("%d,", expectOffsets[i]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
UBool convertToU( const char *source, int sourceLen, const UChar *expect, int expectLen,
|
||||
UBool convertToU( const uint8_t *source, int sourceLen, const UChar *expect, int expectLen,
|
||||
const char *codepage, int32_t *expectOffsets, UBool doFlush, UErrorCode expectedStatus)
|
||||
{
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
UConverter *conv = 0;
|
||||
int32_t i=0;
|
||||
UChar *p=0;
|
||||
const char* src;
|
||||
const uint8_t* src;
|
||||
UChar buffer[MAX_LENGTH];
|
||||
int32_t offsetBuffer[MAX_LENGTH];
|
||||
int32_t *offs=0;
|
||||
UChar *targ;
|
||||
UChar *targetLimit;
|
||||
char *sourceLimit=0;
|
||||
|
||||
|
||||
uint8_t *sourceLimit=0;
|
||||
|
||||
|
||||
|
||||
conv = ucnv_open(codepage, &status);
|
||||
if(U_FAILURE(status))
|
||||
|
@ -734,69 +723,69 @@ UBool convertToU( const char *source, int sourceLen, const UChar *expect, int ex
|
|||
return FALSE;
|
||||
}
|
||||
log_verbose("Converter %s opened..\n", ucnv_getName(conv, &status));
|
||||
|
||||
|
||||
|
||||
|
||||
for(i=0; i<MAX_LENGTH; i++){
|
||||
buffer[i]=0xFFFE;
|
||||
offsetBuffer[i]=-1;
|
||||
}
|
||||
|
||||
|
||||
src=source;
|
||||
sourceLimit=(char*)src+(sourceLen);
|
||||
sourceLimit=(uint8_t*)(src+(sourceLen));
|
||||
targ=buffer;
|
||||
targetLimit=targ+MAX_LENGTH;
|
||||
offs=offsetBuffer;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
ucnv_toUnicode (conv,
|
||||
&targ,
|
||||
targetLimit,
|
||||
&src,
|
||||
sourceLimit,
|
||||
(const char **)&src,
|
||||
(const char *)sourceLimit,
|
||||
expectOffsets ? offs : NULL,
|
||||
doFlush,
|
||||
&status);
|
||||
|
||||
|
||||
ucnv_close(conv);
|
||||
if(status != expectedStatus){
|
||||
log_err("ucnv_fromUnicode() failed for codepage=%s. Error =%s Expected=%s\n", codepage, myErrorName(status), myErrorName(expectedStatus));
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
log_verbose("\nConversion done [%d uchars in -> %d chars out]. \nResult :",
|
||||
sourceLen, targ-buffer);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
log_verbose("comparing %d uchars (%d bytes)..\n",expectLen,expectLen*2);
|
||||
|
||||
if (expectOffsets != 0)
|
||||
{
|
||||
if(memcmp(offsetBuffer, expectOffsets, (targ-buffer) * sizeof(int32_t))){
|
||||
|
||||
|
||||
log_err("did not get the expected offsets from %s To UNICODE\n", codepage);
|
||||
printf("\nGot : ");
|
||||
for(p=buffer;p<targ;p++)
|
||||
printf("%d, ", offsetBuffer[p-buffer]);
|
||||
printf("\nExpected: ");
|
||||
for(i=0; i<(targ-buffer); i++)
|
||||
printf("%d, ", expectOffsets[i]);
|
||||
printf("\nGot result:");
|
||||
for(i=0; i<(targ-buffer); i++)
|
||||
printf("0x%04X,", buffer[i]);
|
||||
printf("\nFrom Input:");
|
||||
for(i=0; i<(src-source); i++)
|
||||
printf("0x%02X,", (unsigned char)source[i]);
|
||||
printf("%d, ", offsetBuffer[p-buffer]);
|
||||
printf("\nExpected: ");
|
||||
for(i=0; i<(targ-buffer); i++)
|
||||
printf("%d, ", expectOffsets[i]);
|
||||
printf("\nGot result:");
|
||||
for(i=0; i<(targ-buffer); i++)
|
||||
printf("0x%04X,", buffer[i]);
|
||||
printf("\nFrom Input:");
|
||||
for(i=0; i<(src-source); i++)
|
||||
printf("0x%02X,", (unsigned char)source[i]);
|
||||
puts("\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!memcmp(buffer, expect, expectLen*2)){
|
||||
log_verbose("Matches!\n");
|
||||
return TRUE;
|
||||
}
|
||||
else {
|
||||
else {
|
||||
log_err("String does not match. from codePage %s TO Unicode\n", codepage);
|
||||
printf("\nGot:");
|
||||
printUSeqErr(buffer, expectLen);
|
||||
|
@ -804,25 +793,25 @@ UBool convertToU( const char *source, int sourceLen, const UChar *expect, int ex
|
|||
printUSeqErr(expect, expectLen);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
UBool testConvertFromU( const UChar *source, int sourceLen, const char *expect, int expectLen,
|
||||
UBool testConvertFromU( const UChar *source, int sourceLen, const uint8_t *expect, int expectLen,
|
||||
const char *codepage, UConverterFromUCallback callback , int32_t *expectOffsets)
|
||||
{
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
UConverter *conv = 0;
|
||||
char junkout[MAX_LENGTH]; /* FIX */
|
||||
uint8_t junkout[MAX_LENGTH]; /* FIX */
|
||||
int32_t junokout[MAX_LENGTH]; /* FIX */
|
||||
char *p;
|
||||
uint8_t *p;
|
||||
const UChar *src;
|
||||
char *end;
|
||||
char *targ;
|
||||
uint8_t *end;
|
||||
uint8_t *targ;
|
||||
int32_t *offs;
|
||||
int i;
|
||||
int32_t realBufferSize;
|
||||
char *realBufferEnd;
|
||||
uint8_t *realBufferEnd;
|
||||
const UChar *realSourceEnd;
|
||||
const UChar *sourceLimit;
|
||||
UBool checkOffsets = TRUE;
|
||||
|
@ -832,7 +821,7 @@ UBool testConvertFromU( const UChar *source, int sourceLen, const char *expect,
|
|||
void* oldContext = NULL;
|
||||
|
||||
for(i=0;i<MAX_LENGTH;i++)
|
||||
junkout[i] = (char)0xF0;
|
||||
junkout[i] = 0xF0;
|
||||
for(i=0;i<MAX_LENGTH;i++)
|
||||
junokout[i] = 0xFF;
|
||||
|
||||
|
@ -849,10 +838,10 @@ UBool testConvertFromU( const UChar *source, int sourceLen, const char *expect,
|
|||
|
||||
log_verbose("Converter opened..\n");
|
||||
/*----setting the callback routine----*/
|
||||
ucnv_setFromUCallBack (conv, callback, NULL, &oldAction, &oldContext, &status);
|
||||
if (U_FAILURE(status)) {
|
||||
log_err("FAILURE in setting the callback Function! %s\n", myErrorName(status));
|
||||
}
|
||||
ucnv_setFromUCallBack (conv, callback, NULL, &oldAction, &oldContext, &status);
|
||||
if (U_FAILURE(status)) {
|
||||
log_err("FAILURE in setting the callback Function! %s\n", myErrorName(status));
|
||||
}
|
||||
/*------------------------*/
|
||||
|
||||
src = source;
|
||||
|
@ -865,7 +854,7 @@ UBool testConvertFromU( const UChar *source, int sourceLen, const char *expect,
|
|||
|
||||
if ( gOutBufferSize != realBufferSize )
|
||||
checkOffsets = FALSE;
|
||||
|
||||
|
||||
if( gInBufferSize != MAX_LENGTH )
|
||||
checkOffsets = FALSE;
|
||||
|
||||
|
@ -874,7 +863,7 @@ UBool testConvertFromU( const UChar *source, int sourceLen, const char *expect,
|
|||
end = nct_min(targ + gOutBufferSize, realBufferEnd);
|
||||
sourceLimit = nct_min(src + gInBufferSize, realSourceEnd);
|
||||
|
||||
doFlush = (sourceLimit == realSourceEnd);
|
||||
doFlush = (UBool)(sourceLimit == realSourceEnd);
|
||||
|
||||
if(targ == realBufferEnd)
|
||||
{
|
||||
|
@ -882,20 +871,20 @@ UBool testConvertFromU( const UChar *source, int sourceLen, const char *expect,
|
|||
return FALSE;
|
||||
}
|
||||
log_verbose("calling fromUnicode @ SOURCE:%08lx to %08lx TARGET: %08lx to %08lx, flush=%s\n", src,sourceLimit, targ,end, doFlush?"TRUE":"FALSE");
|
||||
|
||||
|
||||
|
||||
status = U_ZERO_ERROR;
|
||||
|
||||
|
||||
ucnv_fromUnicode (conv,
|
||||
&targ,
|
||||
end,
|
||||
(char **)&targ,
|
||||
(const char *)end,
|
||||
&src,
|
||||
sourceLimit,
|
||||
offs,
|
||||
doFlush, /* flush if we're at the end of the input data */
|
||||
&status);
|
||||
} while ( (status == U_INDEX_OUTOFBOUNDS_ERROR) || (U_SUCCESS(status) && sourceLimit < realSourceEnd) );
|
||||
|
||||
|
||||
if(U_FAILURE(status)) {
|
||||
log_err("Problem doing fromUnicode to %s, errcode %s %s\n", codepage, myErrorName(status), gNuConvTestName);
|
||||
return FALSE;
|
||||
|
@ -907,8 +896,8 @@ UBool testConvertFromU( const UChar *source, int sourceLen, const char *expect,
|
|||
{
|
||||
char junk[999];
|
||||
char offset_str[999];
|
||||
char *p;
|
||||
|
||||
uint8_t *p;
|
||||
|
||||
junk[0] = 0;
|
||||
offset_str[0] = 0;
|
||||
for(p = junkout;p<targ;p++)
|
||||
|
@ -934,9 +923,9 @@ UBool testConvertFromU( const UChar *source, int sourceLen, const char *expect,
|
|||
log_err("Expected %d chars out, got %d %s\n", expectLen, targ-junkout, gNuConvTestName);
|
||||
log_verbose("Expected %d chars out, got %d %s\n", expectLen, targ-junkout, gNuConvTestName);
|
||||
printf("\nGot:");
|
||||
printSeqErr(junkout, targ-junkout);
|
||||
printSeqErr(junkout, targ-junkout);
|
||||
printf("\nExpected:");
|
||||
printSeqErr(expect, expectLen);
|
||||
printSeqErr(expect, expectLen);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -946,12 +935,12 @@ UBool testConvertFromU( const UChar *source, int sourceLen, const char *expect,
|
|||
if(memcmp(junokout,expectOffsets,(targ-junkout) * sizeof(int32_t) )){
|
||||
log_err("did not get the expected offsets. %s", gNuConvTestName);
|
||||
log_err("Got : ");
|
||||
printSeqErr(junkout, targ-junkout);
|
||||
for(p=junkout;p<targ;p++)
|
||||
log_err("%d, ", junokout[p-junkout]);
|
||||
log_err("\nExpected: ");
|
||||
for(i=0; i<(targ-junkout); i++)
|
||||
log_err("%d,", expectOffsets[i]);
|
||||
printSeqErr(junkout, targ-junkout);
|
||||
for(p=junkout;p<targ;p++)
|
||||
log_err("%d, ", junokout[p-junkout]);
|
||||
log_err("\nExpected: ");
|
||||
for(i=0; i<(targ-junkout); i++)
|
||||
log_err("%d,", expectOffsets[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -962,28 +951,28 @@ UBool testConvertFromU( const UChar *source, int sourceLen, const char *expect,
|
|||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
log_err("String does not match. %s\n", gNuConvTestName);
|
||||
printUSeqErr(source, sourceLen);
|
||||
printf("\nGot:");
|
||||
printSeqErr((const unsigned char *)junkout, expectLen);
|
||||
printf("\nExpected:");
|
||||
printSeqErr((const unsigned char *)expect, expectLen);
|
||||
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
UBool testConvertToU( const char *source, int sourcelen, const UChar *expect, int expectlen,
|
||||
UBool testConvertToU( const uint8_t *source, int sourcelen, const UChar *expect, int expectlen,
|
||||
const char *codepage, UConverterToUCallback callback, int32_t *expectOffsets)
|
||||
{
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
UConverter *conv = 0;
|
||||
UChar junkout[MAX_LENGTH]; /* FIX */
|
||||
int32_t junokout[MAX_LENGTH]; /* FIX */
|
||||
const char *src;
|
||||
const char *realSourceEnd;
|
||||
const char *srcLimit;
|
||||
const uint8_t *src;
|
||||
const uint8_t *realSourceEnd;
|
||||
const uint8_t *srcLimit;
|
||||
UChar *p;
|
||||
UChar *targ;
|
||||
UChar *end;
|
||||
|
@ -1016,11 +1005,11 @@ UBool testConvertToU( const char *source, int sourcelen, const UChar *expect, in
|
|||
|
||||
log_verbose("Converter opened..\n");
|
||||
/*----setting the callback routine----*/
|
||||
ucnv_setToUCallBack (conv, callback, NULL, &oldAction, &oldContext, &status);
|
||||
if (U_FAILURE(status)) {
|
||||
log_err("FAILURE in setting the callback Function! %s\n", myErrorName(status));
|
||||
}
|
||||
/*-------------------------------------*/
|
||||
ucnv_setToUCallBack (conv, callback, NULL, &oldAction, &oldContext, &status);
|
||||
if (U_FAILURE(status)) {
|
||||
log_err("FAILURE in setting the callback Function! %s\n", myErrorName(status));
|
||||
}
|
||||
/*-------------------------------------*/
|
||||
|
||||
src = source;
|
||||
targ = junkout;
|
||||
|
@ -1055,8 +1044,8 @@ UBool testConvertToU( const char *source, int sourcelen, const UChar *expect, in
|
|||
ucnv_toUnicode (conv,
|
||||
&targ,
|
||||
end,
|
||||
&src,
|
||||
srcLimit,
|
||||
(const char **)&src,
|
||||
(const char *)srcLimit,
|
||||
offs,
|
||||
(UBool)(srcLimit == realSourceEnd), /* flush if we're at the end of hte source data */
|
||||
&status);
|
||||
|
@ -1108,17 +1097,17 @@ UBool testConvertToU( const char *source, int sourcelen, const UChar *expect, in
|
|||
|
||||
log_err("did not get the expected offsets. %s",gNuConvTestName);
|
||||
for(p=junkout;p<targ;p++)
|
||||
log_err("%d, ", junokout[p-junkout]);
|
||||
log_err("\nExpected: ");
|
||||
for(i=0; i<(targ-junkout); i++)
|
||||
log_err("%d,", expectOffsets[i]);
|
||||
log_err("");
|
||||
for(i=0; i<(targ-junkout); i++)
|
||||
log_err("%X,", junkout[i]);
|
||||
log_err("");
|
||||
for(i=0; i<(src-source); i++)
|
||||
log_err("%X,", (unsigned char)source[i]);
|
||||
}
|
||||
log_err("%d, ", junokout[p-junkout]);
|
||||
log_err("\nExpected: ");
|
||||
for(i=0; i<(targ-junkout); i++)
|
||||
log_err("%d,", expectOffsets[i]);
|
||||
log_err("");
|
||||
for(i=0; i<(targ-junkout); i++)
|
||||
log_err("%X,", junkout[i]);
|
||||
log_err("");
|
||||
for(i=0; i<(src-source); i++)
|
||||
log_err("%X,", (unsigned char)source[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if(!memcmp(junkout, expect, expectlen*2))
|
||||
|
@ -1127,11 +1116,11 @@ UBool testConvertToU( const char *source, int sourcelen, const UChar *expect, in
|
|||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
log_err("String does not match. %s\n", gNuConvTestName);
|
||||
log_verbose("String does not match. %s\n", gNuConvTestName);
|
||||
printf("\nGot:");
|
||||
printUSeq(junkout, expectlen);
|
||||
printUSeq(junkout, expectlen);
|
||||
printf("\nExpected:");
|
||||
printUSeq(expect, expectlen);
|
||||
return FALSE;
|
||||
|
|
Loading…
Add table
Reference in a new issue