ICU-447 Fixed errors in regression test

X-SVN-Rev: 2055
This commit is contained in:
Madhu K 2000-07-27 01:13:21 +00:00
parent ea283ab003
commit 8995149618

View File

@ -28,6 +28,8 @@
#endif #endif
#define TEST_BUFFER_SIZE 5555555 #define TEST_BUFFER_SIZE 5555555
#define UNICODE_LIMIT 0x10FFFF
static void printSeq(const unsigned char* a, int len); static void printSeq(const unsigned char* a, int len);
static void printSeqErr(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 printUSeq(const UChar* a, int len);
@ -410,7 +412,9 @@ void TestRegression(){
UChar *sourceLimit=0; UChar *sourceLimit=0;
UChar *extractedTargetBuffer=0; UChar *extractedTargetBuffer=0;
UChar *extractedTarget=0; UChar *extractedTarget=0;
UChar *target=0;
UChar *limit=0; UChar *limit=0;
int32_t count=0;
int32_t offset=0; int32_t offset=0;
int32_t sourceLength=0, i=0; int32_t sourceLength=0, i=0;
@ -428,14 +432,15 @@ void TestRegression(){
source[i]=(UChar)0xFFFE; source[i]=(UChar)0xFFFE;
extractedTargetBuffer[i]=(UChar)0xFFFE; extractedTargetBuffer[i]=(UChar)0xFFFE;
} }
for(c=0x0000; c <= 0x10FFFF; c++){ for(c=0x0000; c <= UNICODE_LIMIT; c++){
UTF_APPEND_CHAR_SAFE(source, offset, u_strlen(source), c); UTF_APPEND_CHAR_SAFE(source, offset, u_strlen(source), c);
count++;
} }
src=source; src=source;
sourceLimit=src+(i * (sizeof(UChar))); sourceLimit=src+(offset);
targ=buffer; targ=buffer;
targetLimit=targ+TEST_BUFFER_SIZE; targetLimit=targ+(TEST_BUFFER_SIZE);
ucnv_fromUnicode (conv, ucnv_fromUnicode (conv,
&targ, &targ,
targetLimit, targetLimit,
@ -444,6 +449,14 @@ void TestRegression(){
NULL, NULL,
TRUE, TRUE,
&status); &status);
if(U_FAILURE(status)){
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;
extractedTarget=extractedTargetBuffer; extractedTarget=extractedTargetBuffer;
limit=extractedTarget+TEST_BUFFER_SIZE; limit=extractedTarget+TEST_BUFFER_SIZE;
@ -459,13 +472,21 @@ void TestRegression(){
/*if(memcmp(source, extractedTarget, extractedTarget-extractedTargetBuffer) != 0){ /*if(memcmp(source, extractedTarget, extractedTarget-extractedTargetBuffer) != 0){
log_err("FAILED\n"); log_err("FAILED\n");
}*/ }*/
for(i=0; i<extractedTarget-extractedTargetBuffer; i++){ src=source;
if(source[i] != extractedTarget[i]){ target=extractedTargetBuffer;
log_err("FAILED: comparision failed at offset=%ld, source=0x%04X, extracted=0x%04X\n", i, source[i], extractedTarget[i]); while(target < extractedTarget){
if(*src != *target){
log_err("FAILED: comparision failed at source=0x%04X, extracted=0x%04X\n", *src, *target);
break; break;
} }
} src++;
target++;
}
if((extractedTarget-extractedTargetBuffer) != (sourceLimit-source)){
log_err("The conversion didn't go through the whole range: Expected= %d, Got=%d\n", count, (extractedTarget-extractedTargetBuffer));
}
ucnv_close(conv); ucnv_close(conv);
free(source); free(source);
free(extractedTargetBuffer); free(extractedTargetBuffer);