From 719eacfd9b63cbed2e85474b5e03b3551a699a11 Mon Sep 17 00:00:00 2001 From: George Rhoten Date: Wed, 30 Aug 2000 01:11:09 +0000 Subject: [PATCH] ICU-535 fixed some compiler warnings X-SVN-Rev: 2390 --- icu4c/source/test/cintltst/udatatst.c | 747 +++++++++++++------------- 1 file changed, 374 insertions(+), 373 deletions(-) diff --git a/icu4c/source/test/cintltst/udatatst.c b/icu4c/source/test/cintltst/udatatst.c index 49ebb27938..c91de60ce9 100644 --- a/icu4c/source/test/cintltst/udatatst.c +++ b/icu4c/source/test/cintltst/udatatst.c @@ -9,7 +9,7 @@ * Modification History: * * Date Name Description -* 02/22/2000 Madhu Creation +* 02/22/2000 Madhu Creation ******************************************************************************* */ @@ -33,114 +33,114 @@ void TestErrorConditions(); void addUDataTest(TestNode** root) { - addTest(root, &TestUDataOpen, "udatatst/TestUDataOpen" ); - addTest(root, &TestUDataOpenChoiceDemo1, "udatatst/TestUDataOpenChoiceDemo1"); - addTest(root, &TestUDataOpenChoiceDemo2, "udatatst/TestUDataOpenChoiceDemo2"); - addTest(root, &TestUDataGetInfo, "udatatst/TestUDataGetInfo" ); - addTest(root, &TestUDataGetMemory, "udatatst/TestUDataGetMemory" ); - addTest(root, &TestErrorConditions, "udatatst/TestErrorConditions"); + addTest(root, &TestUDataOpen, "udatatst/TestUDataOpen" ); + addTest(root, &TestUDataOpenChoiceDemo1, "udatatst/TestUDataOpenChoiceDemo1"); + addTest(root, &TestUDataOpenChoiceDemo2, "udatatst/TestUDataOpenChoiceDemo2"); + addTest(root, &TestUDataGetInfo, "udatatst/TestUDataGetInfo" ); + addTest(root, &TestUDataGetMemory, "udatatst/TestUDataGetMemory" ); + addTest(root, &TestErrorConditions, "udatatst/TestErrorConditions"); } void TestUDataOpen(){ - int i; - UDataMemory *result; - UErrorCode status=U_ZERO_ERROR; - const char* memMap[][2]={ - {"tz", "dat"}, - {"cnvalias", "dat"}, - {"unames", "dat"}, - {"ibm-1141", "cnv"} - }; - const char* name = "test"; - const char* type="dat"; - - char* path=(char*)malloc(sizeof(char) * (strlen(u_getDataDirectory()) + strlen("icudata") +1 ) ); - char* testPath=(char*)malloc(sizeof(char) * (strlen(u_getDataDirectory()) + strlen("base") +1 ) ); + int i; + UDataMemory *result; + UErrorCode status=U_ZERO_ERROR; + const char* memMap[][2]={ + {"tz", "dat"}, + {"cnvalias", "dat"}, + {"unames", "dat"}, + {"ibm-1141", "cnv"} + }; + const char* name = "test"; + const char* type="dat"; - strcat(strcpy(path, u_getDataDirectory()), "icudata"); - strcat(strcpy(testPath, u_getDataDirectory()), "base"); + char* path=(char*)malloc(sizeof(char) * (strlen(u_getDataDirectory()) + strlen("icudata") +1 ) ); + char* testPath=(char*)malloc(sizeof(char) * (strlen(u_getDataDirectory()) + strlen("base") +1 ) ); - - log_verbose("Testing udata_open()\n"); - result=udata_open(testPath, type, name, &status); - if(U_FAILURE(status)){ - log_err("FAIL: udata_open() failed for path = %s, name=%s, type=%s, \n errorcode=%s\n", testPath, name, type, myErrorName(status)); - } else { - log_verbose("PASS: udata_open worked\n"); - udata_close(result); - } + strcat(strcpy(path, u_getDataDirectory()), "icudata"); + strcat(strcpy(testPath, u_getDataDirectory()), "base"); - for(i=0; isize>=20 && + + if( pInfo->size>=20 && pInfo->isBigEndian==U_IS_BIG_ENDIAN && pInfo->charsetFamily==U_CHARSET_FAMILY && pInfo->dataFormat[0]==0x43 && /* dataFormat="CvAl" */ pInfo->dataFormat[1]==0x76 && pInfo->dataFormat[2]==0x41 && pInfo->dataFormat[3]==0x6c && - pInfo->formatVersion[0]==2 ){ - log_verbose("The data from \"%s.%s\" IS acceptable using the verifing function isAcceptable1()\n", name, type); - return TRUE; - } else { - log_verbose("The data from \"%s.%s\" IS NOT acceptable using the verifing function isAcceptable1():-\n" - "\tsize = %d\n" - "\tisBigEndian = %d\n" - "\tcharsetFamily = %d\n" - "\tformatVersion[0] = %d\n" - "\tdataVersion[0] = %d\n" - "\tdataFormat = %c%c%c%c\n", - name, type, pInfo->size, pInfo->isBigEndian, pInfo->charsetFamily, pInfo->formatVersion[0], - pInfo->dataVersion[0], pInfo->dataFormat[0], pInfo->dataFormat[1], pInfo->dataFormat[2], - pInfo->dataFormat[3]); - log_verbose("Call another verifing function to accept the data\n"); - return FALSE; - } + pInfo->formatVersion[0]==2 ) + { + log_verbose("The data from \"%s.%s\" IS acceptable using the verifing function isAcceptable1()\n", name, type); + return TRUE; + } else { + log_verbose("The data from \"%s.%s\" IS NOT acceptable using the verifing function isAcceptable1():-\n" + "\tsize = %d\n" + "\tisBigEndian = %d\n" + "\tcharsetFamily = %d\n" + "\tformatVersion[0] = %d\n" + "\tdataVersion[0] = %d\n" + "\tdataFormat = %c%c%c%c\n", + name, type, pInfo->size, pInfo->isBigEndian, pInfo->charsetFamily, pInfo->formatVersion[0], + pInfo->dataVersion[0], pInfo->dataFormat[0], pInfo->dataFormat[1], pInfo->dataFormat[2], + pInfo->dataFormat[3]); + log_verbose("Call another verifing function to accept the data\n"); + return FALSE; + } } static UBool isAcceptable2(void *context, - const char *type, const char *name, - const UDataInfo *pInfo){ - if( pInfo->size>=20 && + const char *type, const char *name, + const UDataInfo *pInfo){ + if( pInfo->size>=20 && pInfo->isBigEndian==U_IS_BIG_ENDIAN && pInfo->charsetFamily==U_CHARSET_FAMILY && pInfo->dataFormat[0]==0x75 && /* dataFormat="unam" */ @@ -148,23 +148,24 @@ isAcceptable2(void *context, pInfo->dataFormat[2]==0x61 && pInfo->dataFormat[3]==0x6d && pInfo->formatVersion[0]==1 && - pInfo->dataVersion[0]==3 ) { - log_verbose("The data from \"%s.%s\" IS acceptable using the verifing function isAcceptable2()\n", name, type); - return TRUE; - } else { - log_verbose("The data from \"%s.%s\" IS NOT acceptable using the verifing function isAcceptable2()\n", name, type); + pInfo->dataVersion[0]==3 ) + { + log_verbose("The data from \"%s.%s\" IS acceptable using the verifing function isAcceptable2()\n", name, type); + return TRUE; + } else { + log_verbose("The data from \"%s.%s\" IS NOT acceptable using the verifing function isAcceptable2()\n", name, type); - return FALSE; - } + return FALSE; + } } static UBool isAcceptable3(void *context, - const char *type, const char *name, - const UDataInfo *pInfo){ - - if( pInfo->size>=20 && + const char *type, const char *name, + const UDataInfo *pInfo){ + + if( pInfo->size>=20 && pInfo->isBigEndian==U_IS_BIG_ENDIAN && pInfo->charsetFamily==U_CHARSET_FAMILY && pInfo->dataFormat[0]==0x54 && /* dataFormat="test" */ @@ -172,76 +173,76 @@ isAcceptable3(void *context, pInfo->dataFormat[2]==0x73 && pInfo->dataFormat[3]==0x74 && pInfo->formatVersion[0]==1 && - pInfo->dataVersion[0]==1 ) { - log_verbose("The data from \"%s.%s\" IS acceptable using the verifing function isAcceptable3()\n", name, type); + pInfo->dataVersion[0]==1 ) { + log_verbose("The data from \"%s.%s\" IS acceptable using the verifing function isAcceptable3()\n", name, type); + + return TRUE; + } else { + log_verbose("The data from \"%s.%s\" IS NOT acceptable using the verifing function isAcceptable3()\n", name, type); + return FALSE; + } - return TRUE; - } else { - log_verbose("The data from \"%s.%s\" IS NOT acceptable using the verifing function isAcceptable3()\n", name, type); - return FALSE; - } - } void TestUDataOpenChoiceDemo1() { UDataMemory *result; - UErrorCode status=U_ZERO_ERROR; + UErrorCode status=U_ZERO_ERROR; const char* name[]={ - "cnvalias", - "unames", - "test" - }; - char* type="dat"; - - char* testPath=(char*)malloc(sizeof(char) * (strlen(u_getDataDirectory()) + strlen("base") +1 ) ); + "cnvalias", + "unames", + "test" + }; + const char* type="dat"; - strcat(strcpy(testPath, u_getDataDirectory()), "base"); + char* testPath=(char*)malloc(sizeof(char) * (strlen(u_getDataDirectory()) + strlen("base") +1 ) ); + + strcat(strcpy(testPath, u_getDataDirectory()), "base"); result=udata_openChoice(NULL, type, name[0], isAcceptable1, NULL, &status); if(U_FAILURE(status)){ log_err("FAIL: udata_openChoice() failed name=%s, type=%s, \n errorcode=%s\n", name[0], type, myErrorName(status)); - } else { - log_verbose("PASS: udata_openChoice worked\n"); - udata_close(result); - } - - result=udata_openChoice(NULL, type, name[1], isAcceptable1, NULL, &status); - if(U_FAILURE(status)){ - status=U_ZERO_ERROR; - result=udata_openChoice(NULL, type, name[1], isAcceptable2, NULL, &status); - if(U_FAILURE(status)){ - log_err("FAIL: udata_openChoice() failed name=%s, type=%s, \n errorcode=%s\n", name[1], type, myErrorName(status)); - } + } else { + log_verbose("PASS: udata_openChoice worked\n"); + udata_close(result); + } + + result=udata_openChoice(NULL, type, name[1], isAcceptable1, NULL, &status); + if(U_FAILURE(status)){ + status=U_ZERO_ERROR; + result=udata_openChoice(NULL, type, name[1], isAcceptable2, NULL, &status); + if(U_FAILURE(status)){ + log_err("FAIL: udata_openChoice() failed name=%s, type=%s, \n errorcode=%s\n", name[1], type, myErrorName(status)); + } + } + + if(U_SUCCESS(status)){ + udata_close(result); } - - if(U_SUCCESS(status)){ - udata_close(result); - } result=udata_openChoice(testPath, type, name[2], isAcceptable1, NULL, &status); - if(U_FAILURE(status)){ - status=U_ZERO_ERROR; - result=udata_openChoice(testPath, type, name[2], isAcceptable3, NULL, &status); - if(U_FAILURE(status)){ - log_err("FAIL: udata_openChoice() failed path=%s name=%s, type=%s, \n errorcode=%s\n", testPath, name[2], type, myErrorName(status)); - } + if(U_FAILURE(status)){ + status=U_ZERO_ERROR; + result=udata_openChoice(testPath, type, name[2], isAcceptable3, NULL, &status); + if(U_FAILURE(status)){ + log_err("FAIL: udata_openChoice() failed path=%s name=%s, type=%s, \n errorcode=%s\n", testPath, name[2], type, myErrorName(status)); + } } - - if(U_SUCCESS(status)){ - udata_close(result); - } - free(testPath); + if(U_SUCCESS(status)){ + udata_close(result); + } + + free(testPath); } static UBool isAcceptable(void *context, - const char *type, const char *name, - const UDataInfo *pInfo){ - if( pInfo->size>=20 && + const char *type, const char *name, + const UDataInfo *pInfo){ + if( pInfo->size>=20 && pInfo->isBigEndian==U_IS_BIG_ENDIAN && pInfo->charsetFamily==U_CHARSET_FAMILY && pInfo->dataFormat[0]==0x54 && /* dataFormat="test" */ @@ -249,83 +250,83 @@ isAcceptable(void *context, pInfo->dataFormat[2]==0x73 && pInfo->dataFormat[3]==0x74 && pInfo->formatVersion[0]==1 && - pInfo->dataVersion[0]==1 && - *((int*)context) == 2 ) { - log_verbose("The data from\"%s.%s\" IS acceptable using the verifing function isAcceptable()\n", name, type); + pInfo->dataVersion[0]==1 && + *((int*)context) == 2 ) { + log_verbose("The data from\"%s.%s\" IS acceptable using the verifing function isAcceptable()\n", name, type); - return TRUE; - } else { - log_verbose("The data from \"%s.%s\" IS NOT acceptable using the verifing function isAcceptable()\n", name, type); - return FALSE; - } + return TRUE; + } else { + log_verbose("The data from \"%s.%s\" IS NOT acceptable using the verifing function isAcceptable()\n", name, type); + return FALSE; + } } void TestUDataOpenChoiceDemo2() { - UDataMemory *result; - UErrorCode status=U_ZERO_ERROR; - int i; - int p=2; - + UDataMemory *result; + UErrorCode status=U_ZERO_ERROR; + int i; + int p=2; + const char* name="test"; - char* type="dat"; + const char* type="dat"; - const char* base[]={ /* these are the common base names to use for the test */ - "base", /* corresponds to something like 'base.dat', 'base.dll', 'libbase.so', etc.. */ - "base_test" /* libbase_test.so, libbase_test.a, etc... */ - }; - - char* path=(char*)malloc(sizeof(char) * (strlen(u_getDataDirectory()) + strlen(base[0]) + 1) ); + const char* base[]={ /* these are the common base names to use for the test */ + "base", /* corresponds to something like 'base.dat', 'base.dll', 'libbase.so', etc.. */ + "base_test" /* libbase_test.so, libbase_test.a, etc... */ + }; + + char* path=(char*)malloc(sizeof(char) * (strlen(u_getDataDirectory()) + strlen(base[0]) + 1) ); strcpy(path, u_getDataDirectory()); - strcat(path, base[0]); - - result=udata_openChoice(path, type, name, isAcceptable, &p, &status); - if(U_FAILURE(status)){ - log_err("failed to load data at p=%s t=%s n=%s, isAcceptable", path, type, name); - } - if(U_SUCCESS(status) ) { - udata_close(result); - } - strcpy(path, ""); - - p=0; - for(i=0;i