diff --git a/icu4c/source/test/cintltst/crestst.c b/icu4c/source/test/cintltst/crestst.c index 73fd63a8d28..a8c4b106954 100644 --- a/icu4c/source/test/cintltst/crestst.c +++ b/icu4c/source/test/cintltst/crestst.c @@ -142,21 +142,31 @@ void TestConstruction1() const char* directory=NULL; const char* locale="te_IN"; char testdatapath[256]; - + const char* tdrelativepath = ".."U_FILE_SEP_STRING"test"U_FILE_SEP_STRING"testdata"U_FILE_SEP_STRING"out"U_FILE_SEP_STRING; directory= u_getDataDirectory(); uprv_strcpy(testdatapath, directory); - uprv_strcat(testdatapath, "testdata"); + + /* u_getDataDirectory shoul return \source\data ... set the + * directory to ..\source\data\..\test\testdata\out\testdata + */ + uprv_strcat(testdatapath, tdrelativepath); + uprv_strcat(testdatapath,"testdata"); log_verbose("Testing ures_open()......\n"); test1=ures_open(testdatapath, NULL, &err); - test2=ures_open(testdatapath, locale, &err); if(U_FAILURE(err)) { - log_err("construction did not succeed : %s \n", myErrorName(err)); + log_err("construction of NULL did not succeed : %s \n", myErrorName(err)); return; } + test2=ures_open(testdatapath, locale, &err); + if(U_FAILURE(err)) + { + log_err("construction of %s did not succeed : %s \n",locale, myErrorName(err)); + return; + } result1= ures_getStringByKey(test1, "string_in_Root_te_te_IN", &resultLen, &err); result2= ures_getStringByKey(test2, "string_in_Root_te_te_IN", &resultLen, &err); diff --git a/icu4c/source/test/cintltst/creststn.c b/icu4c/source/test/cintltst/creststn.c index 46b39c3da3d..f1b5fcf3121 100644 --- a/icu4c/source/test/cintltst/creststn.c +++ b/icu4c/source/test/cintltst/creststn.c @@ -291,15 +291,18 @@ static void TestNewTypes() { UChar expected[] = { 'a','b','c','\0','d','e','f' }; const char* expect ="tab:\t cr:\r ff:\f newline:\n backslash:\\\\ quote=\\\' doubleQuote=\\\" singlequoutes=''"; UChar uExpect[200]; + const char* tdrelativepath = ".."U_FILE_SEP_STRING"test"U_FILE_SEP_STRING"testdata"U_FILE_SEP_STRING"out"U_FILE_SEP_STRING; + u_charsToUChars(expect,uExpect,uprv_strlen(expect)+1); strcpy(action, "Construction of testtypes bundle"); strcpy(testdatapath, directory); + strcat(testdatapath,tdrelativepath); strcat(testdatapath, "testdata"); theBundle = ures_open(testdatapath, "testtypes", &status); empty = ures_getStringByKey(theBundle, "emptystring", &len, &status); - if(*empty != 0 || len != 0) { + if(empty && (*empty != 0 || len != 0)) { log_err("Empty string returned invalid value\n"); } @@ -437,9 +440,12 @@ static void TestEmptyTypes() { int32_t intResult = 0; const UChar *zeroString; const int32_t *zeroIntVect; + const char* tdrelativepath = ".."U_FILE_SEP_STRING"test"U_FILE_SEP_STRING"testdata"U_FILE_SEP_STRING"out"U_FILE_SEP_STRING; + strcpy(action, "Construction of testtypes bundle"); strcpy(testdatapath, directory); + strcat(testdatapath,tdrelativepath); strcat(testdatapath, "testdata"); theBundle = ures_open(testdatapath, "testtypes", &status); @@ -568,7 +574,10 @@ static void TestEmptyBundle(){ char testdatapath[256]; const char *directory= u_getDataDirectory(); UResourceBundle *resb=0, *dResB=0; + const char* tdrelativepath = ".."U_FILE_SEP_STRING"test"U_FILE_SEP_STRING"testdata"U_FILE_SEP_STRING"out"U_FILE_SEP_STRING; + strcpy(testdatapath, directory); + strcat(testdatapath,tdrelativepath); strcat(testdatapath, "testdata"); resb = ures_open(testdatapath, "testempty", &status); @@ -594,9 +603,11 @@ static void TestBinaryCollationData(){ uint8_t *binResult = NULL; int32_t len=0; const char* action="testing the binary collaton data"; + const char* tdrelativepath = ".."U_FILE_SEP_STRING"test"U_FILE_SEP_STRING"testdata"U_FILE_SEP_STRING"out"U_FILE_SEP_STRING; directory= u_getDataDirectory(); uprv_strcpy(testdatapath, directory); + uprv_strcat(testdatapath,tdrelativepath); uprv_strcat(testdatapath, "testdata"); log_verbose("Testing binary collation data resource......\n"); @@ -647,8 +658,11 @@ static void TestAPI() { UResourceBundle *teRes = NULL; UResourceBundle *teFillin=NULL; UResourceBundle *teFillin2=NULL; + char* tdrelativepath = ".."U_FILE_SEP_STRING"test"U_FILE_SEP_STRING"testdata"U_FILE_SEP_STRING"out"U_FILE_SEP_STRING; + directory= u_getDataDirectory(); uprv_strcpy(testdatapath, directory); + uprv_strcat(testdatapath,tdrelativepath); uprv_strcat(testdatapath, "testdata"); u_charsToUChars(testdatapath, utestdatapath, strlen(testdatapath)+1); /*u_uastrcpy(utestdatapath, testdatapath);*/ @@ -766,9 +780,12 @@ static void TestErrorConditions(){ UResourceBundle *teFillin2=NULL; uint8_t *binResult = NULL; int32_t resultLen; + const char* tdrelativepath = ".."U_FILE_SEP_STRING"test"U_FILE_SEP_STRING"testdata"U_FILE_SEP_STRING"out"U_FILE_SEP_STRING; + directory= u_getDataDirectory(); uprv_strcpy(testdatapath, directory); + uprv_strcat(testdatapath,tdrelativepath); uprv_strcat(testdatapath, "testdata"); u_uastrcpy(utestdatapath, testdatapath); @@ -1024,6 +1041,9 @@ static void TestConstruction1() const char* directory=NULL; const char* locale="te_IN"; char testdatapath[256]; + + const char* tdrelativepath = ".."U_FILE_SEP_STRING"test"U_FILE_SEP_STRING"testdata"U_FILE_SEP_STRING"out"U_FILE_SEP_STRING; + int32_t len1=0; int32_t len2=0; UVersionInfo versionInfo; @@ -1038,7 +1058,8 @@ static void TestConstruction1() directory= u_getDataDirectory(); uprv_strcpy(testdatapath, directory); - uprv_strcat(testdatapath, "testdata"); + uprv_strcat(testdatapath, tdrelativepath); + uprv_strcat(testdatapath,"testdata"); log_verbose("Testing ures_open()......\n"); empty = ures_open(testdatapath, "testempty", &status); @@ -1048,14 +1069,18 @@ static void TestConstruction1() ures_close(empty); test1=ures_open(testdatapath, NULL, &err); - test2=ures_open(testdatapath, locale, &err); if(U_FAILURE(err)) { - log_err("construction did not succeed : %s \n", myErrorName(status)); + log_err("construction of NULL did not succeed : %s \n", myErrorName(status)); + return; + } + test2=ures_open(testdatapath, locale, &err); + if(U_FAILURE(err)) + { + log_err("construction of %s did not succeed : %s \n", locale, myErrorName(status)); return; } - result1= ures_getStringByKey(test1, "string_in_Root_te_te_IN", &len1, &err); result2= ures_getStringByKey(test2, "string_in_Root_te_te_IN", &len2, &err); if (U_FAILURE(err) || len1==0 || len2==0) { @@ -1182,8 +1207,10 @@ static UBool testTag(const char* frag, UResourceBundle* arrayItem1=NULL; const char* directory = u_getDataDirectory(); + const char* tdrelativepath = ".."U_FILE_SEP_STRING"test"U_FILE_SEP_STRING"testdata"U_FILE_SEP_STRING"out"U_FILE_SEP_STRING; uprv_strcpy(testdatapath, directory); + uprv_strcat(testdatapath,tdrelativepath); uprv_strcat(testdatapath, "testdata"); is_in[0] = in_Root; diff --git a/icu4c/source/test/cintltst/cucdtst.c b/icu4c/source/test/cintltst/cucdtst.c index 2933e133a44..e43ce95ee3f 100644 --- a/icu4c/source/test/cintltst/cucdtst.c +++ b/icu4c/source/test/cintltst/cucdtst.c @@ -657,10 +657,10 @@ static void TestUnicodeData() } errorCode=U_ZERO_ERROR; - u_parseDelimitedFile(backupPath, ';', fields, 15, unicodeDataLineFn, NULL, &errorCode); + u_parseDelimitedFile(newPath, ';', fields, 15, unicodeDataLineFn, NULL, &errorCode); if(errorCode==U_FILE_ACCESS_ERROR) { errorCode=U_ZERO_ERROR; - u_parseDelimitedFile(newPath, ';', fields, 15, unicodeDataLineFn, NULL, &errorCode); + u_parseDelimitedFile(backupPath, ';', fields, 15, unicodeDataLineFn, NULL, &errorCode); } if(U_FAILURE(errorCode)) { log_err("error parsing UnicodeData.txt: %s\n", u_errorName(errorCode)); diff --git a/icu4c/source/test/cintltst/nucnvtst.c b/icu4c/source/test/cintltst/nucnvtst.c index da7f405f933..2b58c4bdbb4 100644 --- a/icu4c/source/test/cintltst/nucnvtst.c +++ b/icu4c/source/test/cintltst/nucnvtst.c @@ -66,6 +66,8 @@ static void TestConv(const uint16_t in[], char byteArr[], int byteArrLen); +static void TestCoverageMBCS(); + void addTestNewConvert(TestNode** root); @@ -219,6 +221,7 @@ void addTestNewConvert(TestNode** root) addTest(root, &TestISCII, "tsconv/nucnvtst/TestISCII"); addTest(root, &TestJitterbug981, "tsconv/nucnvtst/TestJitterbug981"); addTest(root, &TestJitterbug1293, "tsconv/nucnvtst/TestJitterbug1293"); + addTest(root, &TestCoverageMBCS, "tsconv/nucnvtst/TestCoverageMBCS"); } @@ -842,82 +845,6 @@ static void TestNewConvertWithBufferSizes(int32_t outsize, int32_t insize ) LMBCSUChars, sizeof(LMBCSUChars)/sizeof(LMBCSUChars[0]), "LMBCS-1", fmLMBCSOffs,FALSE)) log_err("LMBCS-1 -> u did not match.\n"); - - /*some more test to increase the code coverage in MBCS. Create an test converter from test1.ucm - which is test file for MBCS conversion with single-byte codepage data.*/ - { - - /* MBCS with single byte codepage data test1.ucm*/ - const UChar unicodeInput[] = { 0x20ac, 0x0005, 0x0006, 0xdbc4, 0xde34, 0x0003}; - const uint8_t expectedtest1[] = { 0x00, 0x05, 0xff, 0x07, 0xff,}; - int32_t totest1Offs[] = { 0, 1, 2, 3, 5, }; - - const uint8_t test1input[] = { 0x00, 0x05, 0x06, 0x07, 0x08, 0x09}; - const UChar expectedUnicode[] = { 0x20ac, 0x0005, 0x0006, 0xdbc4, 0xde34, 0xfffd, 0xfffd}; - int32_t fromtest1Offs[] = { 0, 1, 2, 3, 3, 4, 5}; - - /*from Unicode*/ - if(!testConvertFromU(unicodeInput, sizeof(unicodeInput)/sizeof(unicodeInput[0]), - expectedtest1, sizeof(expectedtest1), "test1", totest1Offs,FALSE )) - log_err("u-> test1(MBCS conversion with single-byte) did not match.\n"); - - /*to Unicode*/ - if(!testConvertToU(test1input, sizeof(test1input), - expectedUnicode, sizeof(expectedUnicode)/sizeof(expectedUnicode[0]), "test1", fromtest1Offs ,FALSE)) - log_err("test1(MBCS conversion with single-byte) -> u did not match.\n"); - - } - - /*some more test to increase the code coverage in MBCS. Create an test converter from test3.ucm - which is test file for MBCS conversion with three-byte codepage data.*/ - { - - /* MBCS with three byte codepage data test3.ucm*/ - const UChar unicodeInput[] = { 0x20ac, 0x0005, 0x0006, 0x000b, 0xdbc4, 0xde34, 0xd84d, 0xdc56, 0x000e}; - const uint8_t expectedtest3[] = { 0x00, 0x05, 0xff, 0x01, 0x02, 0x0b, 0x07, 0x01, 0x02, 0x0a, 0xff,}; - int32_t totest3Offs[] = { 0, 1, 2, 3, 3, 3, 4, 6, 6, 6, 8}; - - const uint8_t test3input[] = { 0x00, 0x05, 0x06, 0x01, 0x02, 0x0b, 0x07, 0x01, 0x02, 0x0a, 0x01, 0x02, 0x0c,}; - const UChar expectedUnicode[] = { 0x20ac, 0x0005, 0x0006, 0x000b, 0xdbc4, 0xde34, 0xd84d, 0xdc56, 0xfffd}; - int32_t fromtest3Offs[] = { 0, 1, 2, 3, 6, 6, 7, 7, 10 }; - - /*from Unicode*/ - if(!testConvertFromU(unicodeInput, sizeof(unicodeInput)/sizeof(unicodeInput[0]), - expectedtest3, sizeof(expectedtest3), "test3", totest3Offs,FALSE )) - log_err("u-> test3(MBCS conversion with three-byte) did not match.\n"); - - /*to Unicode*/ - if(!testConvertToU(test3input, sizeof(test3input), - expectedUnicode, sizeof(expectedUnicode)/sizeof(expectedUnicode[0]), "test3", fromtest3Offs ,FALSE)) - log_err("test3(MBCS conversion with three-byte) -> u did not match.\n"); - - } - - /*some more test to increase the code coverage in MBCS. Create an test converter from test4.ucm - which is test file for MBCS conversion with four-byte codepage data.*/ - { - - /* MBCS with three byte codepage data test4.ucm*/ - const UChar unicodeInput[] = { 0x20ac, 0x0005, 0x0006, 0x000b, 0xdbc4, 0xde34, 0xd84d, 0xdc56, 0x000e}; - const uint8_t expectedtest4[] = { 0x00, 0x05, 0xff, 0x01, 0x02, 0x03, 0x0b, 0x07, 0x01, 0x02, 0x03, 0x0a, 0xff,}; - int32_t totest4Offs[] = { 0, 1, 2, 3, 3, 3, 3, 4, 6, 6, 6, 6, 8,}; - - const uint8_t test4input[] = { 0x00, 0x05, 0x06, 0x01, 0x02, 0x03, 0x0b, 0x07, 0x01, 0x02, 0x03, 0x0a, 0x01, 0x02, 0x03, 0x0c,}; - const UChar expectedUnicode[] = { 0x20ac, 0x0005, 0x0006, 0x000b, 0xdbc4, 0xde34, 0xd84d, 0xdc56, 0xfffd}; - int32_t fromtest4Offs[] = { 0, 1, 2, 3, 7, 7, 8, 8, 12,}; - - /*from Unicode*/ - if(!testConvertFromU(unicodeInput, sizeof(unicodeInput)/sizeof(unicodeInput[0]), - expectedtest4, sizeof(expectedtest4), "test4", totest4Offs,FALSE )) - log_err("u-> test4(MBCS conversion with four-byte) did not match.\n"); - - /*to Unicode*/ - if(!testConvertToU(test4input, sizeof(test4input), - expectedUnicode, sizeof(expectedUnicode)/sizeof(expectedUnicode[0]), "test4", fromtest4Offs,FALSE )) - log_err("test4(MBCS conversion with four-byte) -> u did not match.\n"); - - } - /* UTF-7 examples are mostly from http://www.imc.org/rfc2152 */ { /* encode directly set D and set O */ @@ -1103,6 +1030,99 @@ static void TestNewConvertWithBufferSizes(int32_t outsize, int32_t insize ) } } +static void TestCoverageMBCS(){ + char testdatapath[256]; + char saveDirectory[256]; + const char *directory= u_getDataDirectory(); + const char* tdrelativepath = ".."U_FILE_SEP_STRING"test"U_FILE_SEP_STRING"testdata"U_FILE_SEP_STRING"out"U_FILE_SEP_STRING; + + /*save the data directory */ + strcpy(saveDirectory, directory); + + strcpy(testdatapath, directory); + strcat(testdatapath,tdrelativepath); + u_setDataDirectory(testdatapath); + + /*some more test to increase the code coverage in MBCS. Create an test converter from test1.ucm + which is test file for MBCS conversion with single-byte codepage data.*/ + { + + /* MBCS with single byte codepage data test1.ucm*/ + const UChar unicodeInput[] = { 0x20ac, 0x0005, 0x0006, 0xdbc4, 0xde34, 0x0003}; + const uint8_t expectedtest1[] = { 0x00, 0x05, 0xff, 0x07, 0xff,}; + int32_t totest1Offs[] = { 0, 1, 2, 3, 5, }; + + const uint8_t test1input[] = { 0x00, 0x05, 0x06, 0x07, 0x08, 0x09}; + const UChar expectedUnicode[] = { 0x20ac, 0x0005, 0x0006, 0xdbc4, 0xde34, 0xfffd, 0xfffd}; + int32_t fromtest1Offs[] = { 0, 1, 2, 3, 3, 4, 5}; + + /*from Unicode*/ + if(!testConvertFromU(unicodeInput, sizeof(unicodeInput)/sizeof(unicodeInput[0]), + expectedtest1, sizeof(expectedtest1), "test1", totest1Offs,FALSE )) + log_err("u-> test1(MBCS conversion with single-byte) did not match.\n"); + + /*to Unicode*/ + if(!testConvertToU(test1input, sizeof(test1input), + expectedUnicode, sizeof(expectedUnicode)/sizeof(expectedUnicode[0]), "test1", fromtest1Offs ,FALSE)) + log_err("test1(MBCS conversion with single-byte) -> u did not match.\n"); + + } + + /*some more test to increase the code coverage in MBCS. Create an test converter from test3.ucm + which is test file for MBCS conversion with three-byte codepage data.*/ + { + + /* MBCS with three byte codepage data test3.ucm*/ + const UChar unicodeInput[] = { 0x20ac, 0x0005, 0x0006, 0x000b, 0xdbc4, 0xde34, 0xd84d, 0xdc56, 0x000e}; + const uint8_t expectedtest3[] = { 0x00, 0x05, 0xff, 0x01, 0x02, 0x0b, 0x07, 0x01, 0x02, 0x0a, 0xff,}; + int32_t totest3Offs[] = { 0, 1, 2, 3, 3, 3, 4, 6, 6, 6, 8}; + + const uint8_t test3input[] = { 0x00, 0x05, 0x06, 0x01, 0x02, 0x0b, 0x07, 0x01, 0x02, 0x0a, 0x01, 0x02, 0x0c,}; + const UChar expectedUnicode[] = { 0x20ac, 0x0005, 0x0006, 0x000b, 0xdbc4, 0xde34, 0xd84d, 0xdc56, 0xfffd}; + int32_t fromtest3Offs[] = { 0, 1, 2, 3, 6, 6, 7, 7, 10 }; + + /*from Unicode*/ + if(!testConvertFromU(unicodeInput, sizeof(unicodeInput)/sizeof(unicodeInput[0]), + expectedtest3, sizeof(expectedtest3), "test3", totest3Offs,FALSE )) + log_err("u-> test3(MBCS conversion with three-byte) did not match.\n"); + + /*to Unicode*/ + if(!testConvertToU(test3input, sizeof(test3input), + expectedUnicode, sizeof(expectedUnicode)/sizeof(expectedUnicode[0]), "test3", fromtest3Offs ,FALSE)) + log_err("test3(MBCS conversion with three-byte) -> u did not match.\n"); + + } + + /*some more test to increase the code coverage in MBCS. Create an test converter from test4.ucm + which is test file for MBCS conversion with four-byte codepage data.*/ + { + + /* MBCS with three byte codepage data test4.ucm*/ + const UChar unicodeInput[] = { 0x20ac, 0x0005, 0x0006, 0x000b, 0xdbc4, 0xde34, 0xd84d, 0xdc56, 0x000e}; + const uint8_t expectedtest4[] = { 0x00, 0x05, 0xff, 0x01, 0x02, 0x03, 0x0b, 0x07, 0x01, 0x02, 0x03, 0x0a, 0xff,}; + int32_t totest4Offs[] = { 0, 1, 2, 3, 3, 3, 3, 4, 6, 6, 6, 6, 8,}; + + const uint8_t test4input[] = { 0x00, 0x05, 0x06, 0x01, 0x02, 0x03, 0x0b, 0x07, 0x01, 0x02, 0x03, 0x0a, 0x01, 0x02, 0x03, 0x0c,}; + const UChar expectedUnicode[] = { 0x20ac, 0x0005, 0x0006, 0x000b, 0xdbc4, 0xde34, 0xd84d, 0xdc56, 0xfffd}; + int32_t fromtest4Offs[] = { 0, 1, 2, 3, 7, 7, 8, 8, 12,}; + + /*from Unicode*/ + if(!testConvertFromU(unicodeInput, sizeof(unicodeInput)/sizeof(unicodeInput[0]), + expectedtest4, sizeof(expectedtest4), "test4", totest4Offs,FALSE )) + log_err("u-> test4(MBCS conversion with four-byte) did not match.\n"); + + /*to Unicode*/ + if(!testConvertToU(test4input, sizeof(test4input), + expectedUnicode, sizeof(expectedUnicode)/sizeof(expectedUnicode[0]), "test4", fromtest4Offs,FALSE )) + log_err("test4(MBCS conversion with four-byte) -> u did not match.\n"); + + } + + /* restore the original data directory */ + u_setDataDirectory(saveDirectory); + +} + static void TestConverterTypesAndStarters() { diff --git a/icu4c/source/test/cintltst/udatatst.c b/icu4c/source/test/cintltst/udatatst.c index 73c0c7c596c..c55c3690e70 100644 --- a/icu4c/source/test/cintltst/udatatst.c +++ b/icu4c/source/test/cintltst/udatatst.c @@ -78,14 +78,18 @@ static void TestUDataOpen(){ char* path=(char*)malloc(sizeof(char) * (strlen(u_getDataDirectory()) + strlen(U_ICUDATA_NAME) + strlen("/build")+1 ) ); - char* testPath=(char*)malloc(sizeof(char) * (strlen(u_getDataDirectory()) + strlen("testdata") +1 ) ); char *icuDataFilePath = 0; struct stat stat_buf; + + const char* tdrelativepath = ".."U_FILE_SEP_STRING"test"U_FILE_SEP_STRING"testdata"U_FILE_SEP_STRING"out"U_FILE_SEP_STRING; + char* testPath=(char*)malloc(sizeof(char) * (strlen(u_getDataDirectory()) + strlen("testdata") +1 +strlen(tdrelativepath)) ); + + strcpy(testPath, u_getDataDirectory()); + strcat(testPath,tdrelativepath); + strcat(testPath, "testdata"); strcat(strcpy(path, u_getDataDirectory()), U_ICUDATA_NAME); - strcat(strcpy(testPath, u_getDataDirectory()), "testdata"); - log_verbose("Testing udata_open()\n"); result=udata_open(testPath, type, name, &status); @@ -181,6 +185,7 @@ static void TestUDataOpen(){ log_verbose("Testing udata_open, with base_name.type style fallback to individual file.\n"); icuDataFilePath = (char *)malloc(strlen(u_getDataDirectory()) + 50); strcpy(icuDataFilePath, u_getDataDirectory()); + strcat(icuDataFilePath,tdrelativepath); strcat(icuDataFilePath, "testudata"); status = U_ZERO_ERROR; result = udata_open( icuDataFilePath, "typ", "nam", &status); @@ -198,6 +203,7 @@ static void TestUDataOpen(){ log_verbose("Testing udata_open, with path containing a trailing directory separator.\n"); icuDataFilePath = (char *)malloc(strlen(u_getDataDirectory()) + 50); strcpy(icuDataFilePath, u_getDataDirectory()); + strcat(icuDataFilePath,tdrelativepath); status = U_ZERO_ERROR; result = udata_open( icuDataFilePath, "cnv", "test1", &status); if (status != U_ZERO_ERROR) { @@ -237,18 +243,22 @@ static void TestUDataSetAppData(){ UErrorCode status=U_ZERO_ERROR; int fileHandle = 0; /* We are going to read the testdata.dat file */ - char *filePath = 0; struct stat statBuf; size_t fileSize = 0; char *fileBuf = 0; size_t i; - - log_verbose("Testing udata_setAppData()\n"); - + /* Open the testdata.dat file, using normal */ - filePath=(char*)malloc(sizeof(char) * (strlen(u_getDataDirectory()) + 100) ); - strcat(strcpy(filePath, u_getDataDirectory()), "testdata.dat"); + const char* tdrelativepath = ".."U_FILE_SEP_STRING"test"U_FILE_SEP_STRING"testdata"U_FILE_SEP_STRING"out"U_FILE_SEP_STRING; + char* filePath=(char*)malloc(sizeof(char) * (strlen(u_getDataDirectory()) + strlen("testdata.dat") +1 +strlen(tdrelativepath)) ); + + strcpy(filePath, u_getDataDirectory()); + strcat(filePath,tdrelativepath); + strcat(filePath, "testdata.dat"); + + log_verbose("Testing udata_setAppData()\n"); + #ifdef WIN32 fileHandle = open( filePath, O_RDONLY | O_BINARY ); #else diff --git a/icu4c/source/test/intltest/restest.cpp b/icu4c/source/test/intltest/restest.cpp index df1dad2c14b..2e73f3fbbb9 100644 --- a/icu4c/source/test/intltest/restest.cpp +++ b/icu4c/source/test/intltest/restest.cpp @@ -255,13 +255,14 @@ ResourceBundleTest::TestConstruction() { { UErrorCode err = U_ZERO_ERROR; - const char *directory; char testdatapath[256]; Locale locale("te", "IN"); - directory=u_getDataDirectory(); - uprv_strcpy(testdatapath, directory); - uprv_strcat(testdatapath, "testdata"); + const char* tdrelativepath = ".."U_FILE_SEP_STRING"test"U_FILE_SEP_STRING"testdata"U_FILE_SEP_STRING"out"U_FILE_SEP_STRING; + + strcpy(testdatapath, u_getDataDirectory()); + strcat(testdatapath,tdrelativepath); + strcat(testdatapath, "testdata"); ResourceBundle test1((UnicodeString)testdatapath, err); ResourceBundle test2(testdatapath, locale, err); @@ -306,13 +307,14 @@ ResourceBundleTest::TestConstruction() } { UErrorCode err = U_ZERO_ERROR; - const char *directory; char testdatapath[256]; Locale locale("te", "IN"); - directory=u_getDataDirectory(); - uprv_strcpy(testdatapath, directory); - uprv_strcat(testdatapath, "testdata"); + const char* tdrelativepath = ".."U_FILE_SEP_STRING"test"U_FILE_SEP_STRING"testdata"U_FILE_SEP_STRING"out"U_FILE_SEP_STRING; + + strcpy(testdatapath, u_getDataDirectory()); + strcat(testdatapath,tdrelativepath); + strcat(testdatapath, "testdata"); wchar_t* wideDirectory = new wchar_t[256]; @@ -361,12 +363,12 @@ ResourceBundleTest::testTag(const char* frag, int32_t i,j,actual_bundle; // int32_t row,col; int32_t index; - const char *directory; char testdatapath[256]; + const char* tdrelativepath = ".."U_FILE_SEP_STRING"test"U_FILE_SEP_STRING"testdata"U_FILE_SEP_STRING"out"U_FILE_SEP_STRING; - directory=u_getDataDirectory(); - uprv_strcpy(testdatapath, directory); - uprv_strcat(testdatapath, "testdata"); + strcpy(testdatapath, u_getDataDirectory()); + strcat(testdatapath,tdrelativepath); + strcat(testdatapath, "testdata"); for (i=0; i