mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-10 15:42:14 +00:00
ICU-3594 tests for U_IDNA_STD3_ASCII_RULES_ERROR
X-SVN-Rev: 14878
This commit is contained in:
parent
daba6ddfe6
commit
623c46d430
3 changed files with 264 additions and 237 deletions
|
@ -81,104 +81,36 @@ testAPI(const UChar* src, const UChar* expected, const char* testName,
|
|||
}
|
||||
|
||||
/* test null-terminated source and return value of number of UChars required */
|
||||
if( expectedStatus != U_IDNA_STD3_ASCII_RULES_ERROR ){
|
||||
destLen = func(src,-1,NULL,0,options, &parseError , &status);
|
||||
|
||||
destLen = func(src,-1,NULL,0,options, &parseError , &status);
|
||||
if(status == U_BUFFER_OVERFLOW_ERROR){
|
||||
status = U_ZERO_ERROR; /* reset error code */
|
||||
if(destLen+1 < MAX_DEST_SIZE){
|
||||
dest = destStack;
|
||||
destLen = func(src,-1,dest,destLen+1,options, &parseError, &status);
|
||||
/* TODO : compare output with expected */
|
||||
if(U_SUCCESS(status) && expectedStatus != U_IDNA_STD3_ASCII_RULES_ERROR&& (doCompare==TRUE) && u_strCaseCompare(dest,destLen, expected,expectedLen,0,&status)!=0){
|
||||
log_err("Did not get the expected result for null terminated source.\n" );
|
||||
}
|
||||
}else{
|
||||
log_err( "%s null terminated source failed. Requires destCapacity > 300\n",testName);
|
||||
}
|
||||
}
|
||||
|
||||
if(status != expectedStatus){
|
||||
log_err( "Did not get the expected error for %s null terminated source failed. Expected: %s Got: %s\n",testName, u_errorName(expectedStatus), u_errorName(status));
|
||||
free(tSrc);
|
||||
return;
|
||||
}
|
||||
if(testUnassigned ){
|
||||
status = U_ZERO_ERROR;
|
||||
destLen = func(src,-1,NULL,0,options | UIDNA_ALLOW_UNASSIGNED, &parseError, &status);
|
||||
if(status == U_BUFFER_OVERFLOW_ERROR){
|
||||
status = U_ZERO_ERROR; /* reset error code */
|
||||
if(destLen+1 < MAX_DEST_SIZE){
|
||||
dest = destStack;
|
||||
destLen = func(src,-1,dest,destLen+1,options, &parseError, &status);
|
||||
destLen = func(src,-1,dest,destLen+1,options | UIDNA_ALLOW_UNASSIGNED, &parseError, &status);
|
||||
/* TODO : compare output with expected */
|
||||
if(U_SUCCESS(status) && expectedStatus != U_IDNA_STD3_ASCII_RULES_ERROR&& (doCompare==TRUE) && u_strCaseCompare(dest,destLen, expected,expectedLen,0,&status)!=0){
|
||||
log_err("Did not get the expected result for null terminated source.\n" );
|
||||
}
|
||||
}else{
|
||||
log_err( "%s null terminated source failed. Requires destCapacity > 300\n",testName);
|
||||
}
|
||||
}
|
||||
|
||||
if(status != expectedStatus){
|
||||
log_err( "Did not get the expected error for %s null terminated source failed. Expected: %s Got: %s\n",testName, u_errorName(expectedStatus), u_errorName(status));
|
||||
free(tSrc);
|
||||
return;
|
||||
}
|
||||
if(testUnassigned ){
|
||||
status = U_ZERO_ERROR;
|
||||
destLen = func(src,-1,NULL,0,options | UIDNA_ALLOW_UNASSIGNED, &parseError, &status);
|
||||
if(status == U_BUFFER_OVERFLOW_ERROR){
|
||||
status = U_ZERO_ERROR; /* reset error code */
|
||||
if(destLen+1 < MAX_DEST_SIZE){
|
||||
dest = destStack;
|
||||
destLen = func(src,-1,dest,destLen+1,options | UIDNA_ALLOW_UNASSIGNED, &parseError, &status);
|
||||
/* TODO : compare output with expected */
|
||||
if(U_SUCCESS(status) && (doCompare==TRUE) && u_strCaseCompare(dest,destLen, expected,expectedLen,0,&status)!=0){
|
||||
log_err("Did not get the expected result for %s null terminated source with both options set.\n",testName);
|
||||
|
||||
}
|
||||
}else{
|
||||
log_err( "%s null terminated source failed. Requires destCapacity > 300\n",testName);
|
||||
}
|
||||
}
|
||||
/*testing query string*/
|
||||
if(status != expectedStatus && expectedStatus != U_IDNA_UNASSIGNED_ERROR){
|
||||
log_err( "Did not get the expected error for %s null terminated source with options set. Expected: %s Got: %s\n",testName, u_errorName(expectedStatus), u_errorName(status));
|
||||
}
|
||||
}
|
||||
|
||||
status = U_ZERO_ERROR;
|
||||
|
||||
/* test source with lengthand return value of number of UChars required*/
|
||||
destLen = func(tSrc, tSrcLen, NULL,0,options, &parseError, &status);
|
||||
if(status == U_BUFFER_OVERFLOW_ERROR){
|
||||
status = U_ZERO_ERROR; /* reset error code */
|
||||
if(destLen+1 < MAX_DEST_SIZE){
|
||||
dest = destStack;
|
||||
destLen = func(src,u_strlen(src),dest,destLen+1,options, &parseError, &status);
|
||||
/* TODO : compare output with expected */
|
||||
if(U_SUCCESS(status) && (doCompare==TRUE) && u_strCaseCompare(dest,destLen, expected,expectedLen,0,&status)!=0){
|
||||
log_err("Did not get the expected result for %s with source length.\n",testName);
|
||||
}
|
||||
}else{
|
||||
log_err( "%s with source length failed. Requires destCapacity > 300\n",testName);
|
||||
}
|
||||
}
|
||||
|
||||
if(status != expectedStatus){
|
||||
log_err( "Did not get the expected error for %s with source length. Expected: %s Got: %s\n",testName, u_errorName(expectedStatus), u_errorName(status));
|
||||
}
|
||||
if(testUnassigned){
|
||||
status = U_ZERO_ERROR;
|
||||
|
||||
destLen = func(tSrc,tSrcLen,NULL,0,options | UIDNA_ALLOW_UNASSIGNED, &parseError, &status);
|
||||
|
||||
if(status == U_BUFFER_OVERFLOW_ERROR){
|
||||
status = U_ZERO_ERROR; /* reset error code */
|
||||
if(destLen+1 < MAX_DEST_SIZE){
|
||||
dest = destStack;
|
||||
destLen = func(src,u_strlen(src),dest,destLen+1,options | UIDNA_ALLOW_UNASSIGNED, &parseError, &status);
|
||||
/* TODO : compare output with expected */
|
||||
if(U_SUCCESS(status) && (doCompare==TRUE) && u_strCaseCompare(dest,destLen, expected,expectedLen,0,&status)!=0){
|
||||
log_err("Did not get the expected result for %s with source length and both options set.\n",testName);
|
||||
}
|
||||
}else{
|
||||
log_err( "%s with source length failed. Requires destCapacity > 300\n",testName);
|
||||
}
|
||||
}
|
||||
/*testing query string*/
|
||||
if(status != expectedStatus && expectedStatus != U_IDNA_UNASSIGNED_ERROR){
|
||||
log_err( "Did not get the expected error for %s with source length and options set. Expected: %s Got: %s\n",testName, u_errorName(expectedStatus), u_errorName(status));
|
||||
}
|
||||
}
|
||||
}else{
|
||||
|
||||
status = U_ZERO_ERROR;
|
||||
destLen = func(src,-1,NULL,0,options | UIDNA_USE_STD3_RULES, &parseError, &status);
|
||||
if(status == U_BUFFER_OVERFLOW_ERROR){
|
||||
status = U_ZERO_ERROR; /* reset error code*/
|
||||
if(destLen+1 < MAX_DEST_SIZE){
|
||||
dest = destStack;
|
||||
destLen = func(src,-1,dest,destLen+1,options | UIDNA_USE_STD3_RULES, &parseError, &status);
|
||||
/* TODO : compare output with expected*/
|
||||
if(U_SUCCESS(status) && (doCompare==TRUE) && u_strCaseCompare(dest,destLen, expected,expectedLen,0,&status)!=0){
|
||||
log_err("Did not get the expected result for %s null terminated source with both options set.\n",testName);
|
||||
|
||||
|
@ -188,20 +120,43 @@ testAPI(const UChar* src, const UChar* expected, const char* testName,
|
|||
}
|
||||
}
|
||||
/*testing query string*/
|
||||
if(status != expectedStatus){
|
||||
if(status != expectedStatus && expectedStatus != U_IDNA_UNASSIGNED_ERROR){
|
||||
log_err( "Did not get the expected error for %s null terminated source with options set. Expected: %s Got: %s\n",testName, u_errorName(expectedStatus), u_errorName(status));
|
||||
}
|
||||
}
|
||||
|
||||
status = U_ZERO_ERROR;
|
||||
|
||||
/* test source with lengthand return value of number of UChars required*/
|
||||
destLen = func(tSrc, tSrcLen, NULL,0,options, &parseError, &status);
|
||||
if(status == U_BUFFER_OVERFLOW_ERROR){
|
||||
status = U_ZERO_ERROR; /* reset error code */
|
||||
if(destLen+1 < MAX_DEST_SIZE){
|
||||
dest = destStack;
|
||||
destLen = func(src,u_strlen(src),dest,destLen+1,options, &parseError, &status);
|
||||
/* TODO : compare output with expected */
|
||||
if(U_SUCCESS(status) && (doCompare==TRUE) && u_strCaseCompare(dest,destLen, expected,expectedLen,0,&status)!=0){
|
||||
log_err("Did not get the expected result for %s with source length.\n",testName);
|
||||
}
|
||||
}else{
|
||||
log_err( "%s with source length failed. Requires destCapacity > 300\n",testName);
|
||||
}
|
||||
}
|
||||
|
||||
if(status != expectedStatus){
|
||||
log_err( "Did not get the expected error for %s with source length. Expected: %s Got: %s\n",testName, u_errorName(expectedStatus), u_errorName(status));
|
||||
}
|
||||
if(testUnassigned){
|
||||
status = U_ZERO_ERROR;
|
||||
|
||||
destLen = func(tSrc,tSrcLen,NULL,0,options | UIDNA_USE_STD3_RULES, &parseError, &status);
|
||||
destLen = func(tSrc,tSrcLen,NULL,0,options | UIDNA_ALLOW_UNASSIGNED, &parseError, &status);
|
||||
|
||||
if(status == U_BUFFER_OVERFLOW_ERROR){
|
||||
status = U_ZERO_ERROR; /* reset error code*/
|
||||
status = U_ZERO_ERROR; /* reset error code */
|
||||
if(destLen+1 < MAX_DEST_SIZE){
|
||||
dest = destStack;
|
||||
destLen = func(src,u_strlen(src),dest,destLen+1,options | UIDNA_USE_STD3_RULES, &parseError, &status);
|
||||
/* TODO : compare output with expected*/
|
||||
destLen = func(src,u_strlen(src),dest,destLen+1,options | UIDNA_ALLOW_UNASSIGNED, &parseError, &status);
|
||||
/* TODO : compare output with expected */
|
||||
if(U_SUCCESS(status) && (doCompare==TRUE) && u_strCaseCompare(dest,destLen, expected,expectedLen,0,&status)!=0){
|
||||
log_err("Did not get the expected result for %s with source length and both options set.\n",testName);
|
||||
}
|
||||
|
@ -214,6 +169,49 @@ testAPI(const UChar* src, const UChar* expected, const char* testName,
|
|||
log_err( "Did not get the expected error for %s with source length and options set. Expected: %s Got: %s\n",testName, u_errorName(expectedStatus), u_errorName(status));
|
||||
}
|
||||
}
|
||||
|
||||
status = U_ZERO_ERROR;
|
||||
destLen = func(src,-1,NULL,0,options | UIDNA_USE_STD3_RULES, &parseError, &status);
|
||||
if(status == U_BUFFER_OVERFLOW_ERROR){
|
||||
status = U_ZERO_ERROR; /* reset error code*/
|
||||
if(destLen+1 < MAX_DEST_SIZE){
|
||||
dest = destStack;
|
||||
destLen = func(src,-1,dest,destLen+1,options | UIDNA_USE_STD3_RULES, &parseError, &status);
|
||||
/* TODO : compare output with expected*/
|
||||
if(U_SUCCESS(status) && (doCompare==TRUE) && u_strCaseCompare(dest,destLen, expected,expectedLen,0,&status)!=0){
|
||||
log_err("Did not get the expected result for %s null terminated source with both options set.\n",testName);
|
||||
|
||||
}
|
||||
}else{
|
||||
log_err( "%s null terminated source failed. Requires destCapacity > 300\n",testName);
|
||||
}
|
||||
}
|
||||
/*testing query string*/
|
||||
if(status != expectedStatus){
|
||||
log_err( "Did not get the expected error for %s null terminated source with options set. Expected: %s Got: %s\n",testName, u_errorName(expectedStatus), u_errorName(status));
|
||||
}
|
||||
|
||||
status = U_ZERO_ERROR;
|
||||
|
||||
destLen = func(tSrc,tSrcLen,NULL,0,options | UIDNA_USE_STD3_RULES, &parseError, &status);
|
||||
|
||||
if(status == U_BUFFER_OVERFLOW_ERROR){
|
||||
status = U_ZERO_ERROR; /* reset error code*/
|
||||
if(destLen+1 < MAX_DEST_SIZE){
|
||||
dest = destStack;
|
||||
destLen = func(src,u_strlen(src),dest,destLen+1,options | UIDNA_USE_STD3_RULES, &parseError, &status);
|
||||
/* TODO : compare output with expected*/
|
||||
if(U_SUCCESS(status) && (doCompare==TRUE) && u_strCaseCompare(dest,destLen, expected,expectedLen,0,&status)!=0){
|
||||
log_err("Did not get the expected result for %s with source length and both options set.\n",testName);
|
||||
}
|
||||
}else{
|
||||
log_err( "%s with source length failed. Requires destCapacity > 300\n",testName);
|
||||
}
|
||||
}
|
||||
/*testing query string*/
|
||||
if(status != expectedStatus && expectedStatus != U_IDNA_UNASSIGNED_ERROR){
|
||||
log_err( "Did not get the expected error for %s with source length and options set. Expected: %s Got: %s\n",testName, u_errorName(expectedStatus), u_errorName(status));
|
||||
}
|
||||
free(tSrc);
|
||||
}
|
||||
|
||||
|
@ -394,22 +392,22 @@ static const char *domainNames[] = {
|
|||
"pool029.max2.denver.co.dynip.alter.net",
|
||||
"cust49.max9.new-york.ny.ms.uu.net",
|
||||
"s61.abq-dialin2.hollyberry.com",
|
||||
"http://\\u0917\\u0928\\u0947\\u0936.sanjose.ibm.com",
|
||||
"\\u0917\\u0928\\u0947\\u0936.sanjose.ibm.com", //':'(0x003a) produces U_IDNA_STD3_ASCII_RULES_ERROR
|
||||
"www.xn--vea.com",
|
||||
"www.\\u00E0\\u00B3\\u00AF.com",
|
||||
// "www.\\u00E0\\u00B3\\u00AF.com",//' ' (0x0020) produces U_IDNA_STD3_ASCII_RULES_ERROR
|
||||
"www.\\u00C2\\u00A4.com",
|
||||
"www.\\u00C2\\u00A3.com",
|
||||
"\\u0025",
|
||||
"\\u005C\\u005C",
|
||||
"@",
|
||||
"\\u002F",
|
||||
"www.\\u0021.com",
|
||||
"www.\\u0024.com",
|
||||
"\\u003f",
|
||||
/* These yeild U_IDNA_PROHIBITED_ERROR
|
||||
// "\\u0025", //'%' (0x0025) produces U_IDNA_STD3_ASCII_RULES_ERROR
|
||||
// "\\u005C\\u005C", //'\' (0x005C) produces U_IDNA_STD3_ASCII_RULES_ERROR
|
||||
//"@",
|
||||
//"\\u002F",
|
||||
//"www.\\u0021.com",
|
||||
//"www.\\u0024.com",
|
||||
//"\\u003f",
|
||||
// These yeild U_IDNA_PROHIBITED_ERROR
|
||||
//"\\u00CF\\u0082.com",
|
||||
//"\\u00CE\\u00B2\\u00C3\\u009Fss.com",
|
||||
//"\\u00E2\\u0098\\u00BA.com",*/
|
||||
//"\\u00E2\\u0098\\u00BA.com",
|
||||
"\\u00C3\\u00BC.com",
|
||||
|
||||
};
|
||||
|
@ -499,6 +497,7 @@ TestIDNToASCII(){
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -304,8 +304,11 @@ idnaref_toASCII(const UChar* src, int32_t srcLength,
|
|||
|
||||
// step 3 & 4
|
||||
for( j=0;j<b1Len;j++){
|
||||
if(b1[j] > 0x7F) srcIsASCII = FALSE;
|
||||
srcIsLDH = prep->isLDHChar(b1[j]);
|
||||
if(b1[j] > 0x7F){
|
||||
srcIsASCII = FALSE;
|
||||
}else{
|
||||
srcIsLDH = prep->isLDHChar(b1[j]);
|
||||
}
|
||||
}
|
||||
|
||||
if(useSTD3ASCIIRules == TRUE){
|
||||
|
@ -437,11 +440,10 @@ idnaref_toUnicode(const UChar* src, int32_t srcLength,
|
|||
for(;src[srcLength]!=0;){
|
||||
if(src[srcLength]> 0x7f){
|
||||
srcIsASCII = FALSE;
|
||||
}
|
||||
// here we do not assemble surrogates
|
||||
// since we know that LDH code points
|
||||
// are in the ASCII range only
|
||||
if(prep->isLDHChar(src[srcLength])==FALSE){
|
||||
}if(prep->isLDHChar(src[srcLength])==FALSE){
|
||||
// here we do not assemble surrogates
|
||||
// since we know that LDH code points
|
||||
// are in the ASCII range only
|
||||
srcIsLDH = FALSE;
|
||||
failPos = srcLength;
|
||||
}
|
||||
|
@ -451,11 +453,10 @@ idnaref_toUnicode(const UChar* src, int32_t srcLength,
|
|||
for(int32_t j=0; j<srcLength; j++){
|
||||
if(src[j]> 0x7f){
|
||||
srcIsASCII = FALSE;
|
||||
}
|
||||
// here we do not assemble surrogates
|
||||
// since we know that LDH code points
|
||||
// are in the ASCII range only
|
||||
if(prep->isLDHChar(src[j])==FALSE){
|
||||
}else if(prep->isLDHChar(src[j])==FALSE){
|
||||
// here we do not assemble surrogates
|
||||
// since we know that LDH code points
|
||||
// are in the ASCII range only
|
||||
srcIsLDH = FALSE;
|
||||
failPos = j;
|
||||
}
|
||||
|
|
|
@ -208,18 +208,18 @@ static const char *domainNames[] = {
|
|||
"pool029.max2.denver.co.dynip.alter.net",
|
||||
"cust49.max9.new-york.ny.ms.uu.net",
|
||||
"s61.abq-dialin2.hollyberry.com",
|
||||
"http://\\u0917\\u0928\\u0947\\u0936.sanjose.ibm.com",
|
||||
"\\u0917\\u0928\\u0947\\u0936.sanjose.ibm.com", //':'(0x003a) produces U_IDNA_STD3_ASCII_RULES_ERROR
|
||||
"www.xn--vea.com",
|
||||
"www.\\u00E0\\u00B3\\u00AF.com",
|
||||
// "www.\\u00E0\\u00B3\\u00AF.com",//' ' (0x0020) produces U_IDNA_STD3_ASCII_RULES_ERROR
|
||||
"www.\\u00C2\\u00A4.com",
|
||||
"www.\\u00C2\\u00A3.com",
|
||||
"\\u0025",
|
||||
"\\u005C\\u005C",
|
||||
"@",
|
||||
"\\u002F",
|
||||
"www.\\u0021.com",
|
||||
"www.\\u0024.com",
|
||||
"\\u003f",
|
||||
// "\\u0025", //'%' (0x0025) produces U_IDNA_STD3_ASCII_RULES_ERROR
|
||||
// "\\u005C\\u005C", //'\' (0x005C) produces U_IDNA_STD3_ASCII_RULES_ERROR
|
||||
//"@",
|
||||
//"\\u002F",
|
||||
//"www.\\u0021.com",
|
||||
//"www.\\u0024.com",
|
||||
//"\\u003f",
|
||||
// These yeild U_IDNA_PROHIBITED_ERROR
|
||||
//"\\u00CF\\u0082.com",
|
||||
//"\\u00CE\\u00B2\\u00C3\\u009Fss.com",
|
||||
|
@ -641,116 +641,51 @@ void TestIDNA::testAPI(const UChar* src, const UChar* expected, const char* test
|
|||
}
|
||||
|
||||
// test null-terminated source and return value of number of UChars required
|
||||
if( expectedStatus != U_IDNA_STD3_ASCII_RULES_ERROR ){
|
||||
destLen = func(src,-1,NULL,0,options, &parseError , &status);
|
||||
if(status == U_BUFFER_OVERFLOW_ERROR){
|
||||
status = U_ZERO_ERROR; // reset error code
|
||||
if(destLen+1 < MAX_DEST_SIZE){
|
||||
dest = destStack;
|
||||
destLen = func(src,-1,dest,destLen+1,options, &parseError, &status);
|
||||
// TODO : compare output with expected
|
||||
if(U_SUCCESS(status) && expectedStatus != U_IDNA_STD3_ASCII_RULES_ERROR&& (doCompare==TRUE) && u_strCaseCompare(dest,destLen, expected,expectedLen,0,&status)!=0){
|
||||
errln("Did not get the expected result for "+UnicodeString(testName) +" null terminated source. Expected : "
|
||||
+ prettify(UnicodeString(expected,expectedLen))
|
||||
+ " Got: " + prettify(UnicodeString(dest,destLen))
|
||||
);
|
||||
}
|
||||
}else{
|
||||
errln( "%s null terminated source failed. Requires destCapacity > 300\n",testName);
|
||||
destLen = func(src,-1,NULL,0,options, &parseError , &status);
|
||||
if(status == U_BUFFER_OVERFLOW_ERROR){
|
||||
status = U_ZERO_ERROR; // reset error code
|
||||
if(destLen+1 < MAX_DEST_SIZE){
|
||||
dest = destStack;
|
||||
destLen = func(src,-1,dest,destLen+1,options, &parseError, &status);
|
||||
// TODO : compare output with expected
|
||||
if(U_SUCCESS(status) && expectedStatus != U_IDNA_STD3_ASCII_RULES_ERROR&& (doCompare==TRUE) && u_strCaseCompare(dest,destLen, expected,expectedLen,0,&status)!=0){
|
||||
errln("Did not get the expected result for "+UnicodeString(testName) +" null terminated source. Expected : "
|
||||
+ prettify(UnicodeString(expected,expectedLen))
|
||||
+ " Got: " + prettify(UnicodeString(dest,destLen))
|
||||
);
|
||||
}
|
||||
}else{
|
||||
errln( "%s null terminated source failed. Requires destCapacity > 300\n",testName);
|
||||
}
|
||||
}
|
||||
|
||||
if(status != expectedStatus){
|
||||
errln( "Did not get the expected error for %s null terminated source failed. Expected: %s Got: %s\n",testName, u_errorName(expectedStatus), u_errorName(status));
|
||||
uprv_free(tSrc);
|
||||
return;
|
||||
}
|
||||
if(testUnassigned ){
|
||||
status = U_ZERO_ERROR;
|
||||
destLen = func(src,-1,NULL,0,options | UIDNA_ALLOW_UNASSIGNED, &parseError, &status);
|
||||
if(status == U_BUFFER_OVERFLOW_ERROR){
|
||||
status = U_ZERO_ERROR; // reset error code
|
||||
if(destLen+1 < MAX_DEST_SIZE){
|
||||
dest = destStack;
|
||||
destLen = func(src,-1,dest,destLen+1,options | UIDNA_ALLOW_UNASSIGNED, &parseError, &status);
|
||||
// TODO : compare output with expected
|
||||
if(U_SUCCESS(status) && (doCompare==TRUE) && u_strCaseCompare(dest,destLen, expected,expectedLen,0,&status)!=0){
|
||||
//errln("Did not get the expected result for %s null terminated source with both options set.\n",testName);
|
||||
errln("Did not get the expected result for "+UnicodeString(testName) +
|
||||
" null terminated source "+ prettify(src) +
|
||||
" with both options set. Expected: "+ prettify(UnicodeString(expected,expectedLen))+
|
||||
"Got: " + prettify(UnicodeString(dest,destLen)));
|
||||
|
||||
debug(src,-1,options | UIDNA_ALLOW_UNASSIGNED);
|
||||
|
||||
}
|
||||
}else{
|
||||
errln( "%s null terminated source failed. Requires destCapacity > 300\n",testName);
|
||||
}
|
||||
}
|
||||
//testing query string
|
||||
if(status != expectedStatus && expectedStatus != U_IDNA_UNASSIGNED_ERROR){
|
||||
errln( "Did not get the expected error for %s null terminated source with options set. Expected: %s Got: %s\n",testName, u_errorName(expectedStatus), u_errorName(status));
|
||||
}
|
||||
}
|
||||
|
||||
if(status != expectedStatus){
|
||||
errln( "Did not get the expected error for"+
|
||||
UnicodeString(testName)+
|
||||
"null terminated source. Expected: " +UnicodeString(u_errorName(expectedStatus))
|
||||
+ " Got: "+ UnicodeString(u_errorName(status))
|
||||
+ " Source: " + prettify(UnicodeString(src))
|
||||
);
|
||||
uprv_free(tSrc);
|
||||
return;
|
||||
}
|
||||
if(testUnassigned ){
|
||||
status = U_ZERO_ERROR;
|
||||
|
||||
// test source with lengthand return value of number of UChars required
|
||||
destLen = func(tSrc, tSrcLen, NULL,0,options, &parseError, &status);
|
||||
destLen = func(src,-1,NULL,0,options | UIDNA_ALLOW_UNASSIGNED, &parseError, &status);
|
||||
if(status == U_BUFFER_OVERFLOW_ERROR){
|
||||
status = U_ZERO_ERROR; // reset error code
|
||||
if(destLen+1 < MAX_DEST_SIZE){
|
||||
dest = destStack;
|
||||
destLen = func(src,u_strlen(src),dest,destLen+1,options, &parseError, &status);
|
||||
// TODO : compare output with expected
|
||||
if(U_SUCCESS(status) && (doCompare==TRUE) && u_strCaseCompare(dest,destLen, expected,expectedLen,0,&status)!=0){
|
||||
errln("Did not get the expected result for %s with source length.\n",testName);
|
||||
}
|
||||
}else{
|
||||
errln( "%s with source length failed. Requires destCapacity > 300\n",testName);
|
||||
}
|
||||
}
|
||||
|
||||
if(status != expectedStatus){
|
||||
errln( "Did not get the expected error for %s with source length. Expected: %s Got: %s\n",testName, u_errorName(expectedStatus), u_errorName(status));
|
||||
}
|
||||
if(testUnassigned){
|
||||
status = U_ZERO_ERROR;
|
||||
|
||||
destLen = func(tSrc,tSrcLen,NULL,0,options | UIDNA_ALLOW_UNASSIGNED, &parseError, &status);
|
||||
|
||||
if(status == U_BUFFER_OVERFLOW_ERROR){
|
||||
status = U_ZERO_ERROR; // reset error code
|
||||
if(destLen+1 < MAX_DEST_SIZE){
|
||||
dest = destStack;
|
||||
destLen = func(src,u_strlen(src),dest,destLen+1,options | UIDNA_ALLOW_UNASSIGNED, &parseError, &status);
|
||||
// TODO : compare output with expected
|
||||
if(U_SUCCESS(status) && (doCompare==TRUE) && u_strCaseCompare(dest,destLen, expected,expectedLen,0,&status)!=0){
|
||||
errln("Did not get the expected result for %s with source length and both options set.\n",testName);
|
||||
}
|
||||
}else{
|
||||
errln( "%s with source length failed. Requires destCapacity > 300\n",testName);
|
||||
}
|
||||
}
|
||||
//testing query string
|
||||
if(status != expectedStatus && expectedStatus != U_IDNA_UNASSIGNED_ERROR){
|
||||
errln( "Did not get the expected error for %s with source length and options set. Expected: %s Got: %s\n",testName, u_errorName(expectedStatus), u_errorName(status));
|
||||
}
|
||||
}
|
||||
}else{
|
||||
|
||||
status = U_ZERO_ERROR;
|
||||
destLen = func(src,-1,NULL,0,options | UIDNA_USE_STD3_RULES, &parseError, &status);
|
||||
if(status == U_BUFFER_OVERFLOW_ERROR){
|
||||
status = U_ZERO_ERROR; // reset error code
|
||||
if(destLen+1 < MAX_DEST_SIZE){
|
||||
dest = destStack;
|
||||
destLen = func(src,-1,dest,destLen+1,options | UIDNA_USE_STD3_RULES, &parseError, &status);
|
||||
destLen = func(src,-1,dest,destLen+1,options | UIDNA_ALLOW_UNASSIGNED, &parseError, &status);
|
||||
// TODO : compare output with expected
|
||||
if(U_SUCCESS(status) && (doCompare==TRUE) && u_strCaseCompare(dest,destLen, expected,expectedLen,0,&status)!=0){
|
||||
//errln("Did not get the expected result for %s null terminated source with both options set.\n",testName);
|
||||
errln("Did not get the expected result for "+UnicodeString(testName) +" null terminated source with both options set. Expected: "+ prettify(UnicodeString(expected,expectedLen)));
|
||||
errln("Did not get the expected result for "+UnicodeString(testName) +
|
||||
" null terminated source "+ prettify(src) +
|
||||
" with both options set. Expected: "+ prettify(UnicodeString(expected,expectedLen))+
|
||||
"Got: " + prettify(UnicodeString(dest,destLen)));
|
||||
|
||||
debug(src,-1,options | UIDNA_ALLOW_UNASSIGNED);
|
||||
|
||||
}
|
||||
}else{
|
||||
|
@ -758,19 +693,52 @@ void TestIDNA::testAPI(const UChar* src, const UChar* expected, const char* test
|
|||
}
|
||||
}
|
||||
//testing query string
|
||||
if(status != expectedStatus){
|
||||
errln( "Did not get the expected error for %s null terminated source with options set. Expected: %s Got: %s\n",testName, u_errorName(expectedStatus), u_errorName(status));
|
||||
}
|
||||
if(status != expectedStatus && expectedStatus != U_IDNA_UNASSIGNED_ERROR){
|
||||
errln( "Did not get the expected error for"+
|
||||
UnicodeString(testName)+
|
||||
"null terminated source with options set. Expected: " +UnicodeString(u_errorName(expectedStatus))
|
||||
+ " Got: "+ UnicodeString(u_errorName(status))
|
||||
+ " Source: " + prettify(UnicodeString(src))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
status = U_ZERO_ERROR;
|
||||
|
||||
// test source with lengthand return value of number of UChars required
|
||||
destLen = func(tSrc, tSrcLen, NULL,0,options, &parseError, &status);
|
||||
if(status == U_BUFFER_OVERFLOW_ERROR){
|
||||
status = U_ZERO_ERROR; // reset error code
|
||||
if(destLen+1 < MAX_DEST_SIZE){
|
||||
dest = destStack;
|
||||
destLen = func(src,u_strlen(src),dest,destLen+1,options, &parseError, &status);
|
||||
// TODO : compare output with expected
|
||||
if(U_SUCCESS(status) && (doCompare==TRUE) && u_strCaseCompare(dest,destLen, expected,expectedLen,0,&status)!=0){
|
||||
errln("Did not get the expected result for %s with source length.\n",testName);
|
||||
}
|
||||
}else{
|
||||
errln( "%s with source length failed. Requires destCapacity > 300\n",testName);
|
||||
}
|
||||
}
|
||||
|
||||
if(status != expectedStatus){
|
||||
errln( "Did not get the expected error for"+
|
||||
UnicodeString(testName)+
|
||||
"with source length. Expected: " +UnicodeString(u_errorName(expectedStatus))
|
||||
+ " Got: "+ UnicodeString(u_errorName(status))
|
||||
+ " Source: " + prettify(UnicodeString(src))
|
||||
);
|
||||
}
|
||||
if(testUnassigned){
|
||||
status = U_ZERO_ERROR;
|
||||
|
||||
destLen = func(tSrc,tSrcLen,NULL,0,options | UIDNA_USE_STD3_RULES, &parseError, &status);
|
||||
destLen = func(tSrc,tSrcLen,NULL,0,options | UIDNA_ALLOW_UNASSIGNED, &parseError, &status);
|
||||
|
||||
if(status == U_BUFFER_OVERFLOW_ERROR){
|
||||
status = U_ZERO_ERROR; // reset error code
|
||||
if(destLen+1 < MAX_DEST_SIZE){
|
||||
dest = destStack;
|
||||
destLen = func(src,u_strlen(src),dest,destLen+1,options | UIDNA_USE_STD3_RULES, &parseError, &status);
|
||||
destLen = func(src,u_strlen(src),dest,destLen+1,options | UIDNA_ALLOW_UNASSIGNED, &parseError, &status);
|
||||
// TODO : compare output with expected
|
||||
if(U_SUCCESS(status) && (doCompare==TRUE) && u_strCaseCompare(dest,destLen, expected,expectedLen,0,&status)!=0){
|
||||
errln("Did not get the expected result for %s with source length and both options set.\n",testName);
|
||||
|
@ -781,9 +749,68 @@ void TestIDNA::testAPI(const UChar* src, const UChar* expected, const char* test
|
|||
}
|
||||
//testing query string
|
||||
if(status != expectedStatus && expectedStatus != U_IDNA_UNASSIGNED_ERROR){
|
||||
errln( "Did not get the expected error for %s with source length and options set. Expected: %s Got: %s\n",testName, u_errorName(expectedStatus), u_errorName(status));
|
||||
errln( "Did not get the expected error for"+
|
||||
UnicodeString(testName)+
|
||||
"with source length and options set. Expected: " +UnicodeString(u_errorName(expectedStatus))
|
||||
+ " Got: "+ UnicodeString(u_errorName(status))
|
||||
+ " Source: " + prettify(UnicodeString(src))
|
||||
);
|
||||
}
|
||||
}
|
||||
status = U_ZERO_ERROR;
|
||||
destLen = func(src,-1,NULL,0,options | UIDNA_USE_STD3_RULES, &parseError, &status);
|
||||
if(status == U_BUFFER_OVERFLOW_ERROR){
|
||||
status = U_ZERO_ERROR; // reset error code
|
||||
if(destLen+1 < MAX_DEST_SIZE){
|
||||
dest = destStack;
|
||||
destLen = func(src,-1,dest,destLen+1,options | UIDNA_USE_STD3_RULES, &parseError, &status);
|
||||
// TODO : compare output with expected
|
||||
if(U_SUCCESS(status) && (doCompare==TRUE) && u_strCaseCompare(dest,destLen, expected,expectedLen,0,&status)!=0){
|
||||
//errln("Did not get the expected result for %s null terminated source with both options set.\n",testName);
|
||||
errln("Did not get the expected result for "+UnicodeString(testName) +" null terminated source with both options set. Expected: "+ prettify(UnicodeString(expected,expectedLen)));
|
||||
|
||||
}
|
||||
}else{
|
||||
errln( "%s null terminated source failed. Requires destCapacity > 300\n",testName);
|
||||
}
|
||||
}
|
||||
//testing query string
|
||||
if(status != expectedStatus){
|
||||
errln( "Did not get the expected error for"+
|
||||
UnicodeString(testName)+
|
||||
"null terminated source with options set. Expected: " +UnicodeString(u_errorName(expectedStatus))
|
||||
+ " Got: "+ UnicodeString(u_errorName(status))
|
||||
+ " Source: " + prettify(UnicodeString(src))
|
||||
);
|
||||
}
|
||||
|
||||
status = U_ZERO_ERROR;
|
||||
|
||||
destLen = func(tSrc,tSrcLen,NULL,0,options | UIDNA_USE_STD3_RULES, &parseError, &status);
|
||||
|
||||
if(status == U_BUFFER_OVERFLOW_ERROR){
|
||||
status = U_ZERO_ERROR; // reset error code
|
||||
if(destLen+1 < MAX_DEST_SIZE){
|
||||
dest = destStack;
|
||||
destLen = func(src,u_strlen(src),dest,destLen+1,options | UIDNA_USE_STD3_RULES, &parseError, &status);
|
||||
// TODO : compare output with expected
|
||||
if(U_SUCCESS(status) && (doCompare==TRUE) && u_strCaseCompare(dest,destLen, expected,expectedLen,0,&status)!=0){
|
||||
errln("Did not get the expected result for %s with source length and both options set.\n",testName);
|
||||
}
|
||||
}else{
|
||||
errln( "%s with source length failed. Requires destCapacity > 300\n",testName);
|
||||
}
|
||||
}
|
||||
//testing query string
|
||||
if(status != expectedStatus && expectedStatus != U_IDNA_UNASSIGNED_ERROR){
|
||||
errln( "Did not get the expected error for"+
|
||||
UnicodeString(testName)+
|
||||
"with source length and options set. Expected: " +UnicodeString(u_errorName(expectedStatus))
|
||||
+ " Got: "+ UnicodeString(u_errorName(status))
|
||||
+ " Source: " + prettify(UnicodeString(src))
|
||||
);
|
||||
}
|
||||
|
||||
uprv_free(tSrc);
|
||||
}
|
||||
|
||||
|
@ -1069,8 +1096,8 @@ void TestIDNA::testErrorCases(const char* toASCIIName, TestFunc toASCII,
|
|||
errorCase.expected, TRUE, TRUE, IDNToASCII);
|
||||
if(errorCase.testLabel ==TRUE){
|
||||
testAPI(src,buf,
|
||||
toASCIIName, errorCase.useSTD3ASCIIRules,
|
||||
errorCase.expected, FALSE,TRUE, toASCII);
|
||||
IDNToASCIIName, errorCase.useSTD3ASCIIRules,
|
||||
errorCase.expected, FALSE,TRUE, IDNToASCII);
|
||||
}
|
||||
if(errorCase.testToUnicode ==TRUE){
|
||||
testAPI((src==NULL)? NULL : buf,src,
|
||||
|
|
Loading…
Add table
Reference in a new issue