mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-07 06:25:30 +00:00
ICU-1874 Make the tests work on individual files when ICU_DATA is set to ....\data\out\build\
X-SVN-Rev: 8514
This commit is contained in:
parent
1cceba1eda
commit
08db07139b
4 changed files with 38 additions and 32 deletions
|
@ -343,12 +343,27 @@ const char* loadTestData(UErrorCode* err){
|
|||
strcat(tdpath, tdrelativepath);
|
||||
strcat(tdpath,"testdata");
|
||||
*err =U_ZERO_ERROR;
|
||||
test=ures_open(tdpath, "ja_data", err);
|
||||
/* Fall back did not succeed either so return */
|
||||
test=ures_open(tdpath, "testtypes", err);
|
||||
/* we could not find the data in tdpath
|
||||
* try one more tdpathFallback
|
||||
*/
|
||||
if(U_FAILURE(*err)){
|
||||
*err = U_FILE_ACCESS_ERROR;
|
||||
log_err("construction of NULL did not succeed : %s \n", u_errorName(*err));
|
||||
return "";
|
||||
strcpy(tdpath,directory);
|
||||
strcat(tdpath,".."U_FILE_SEP_STRING);
|
||||
strcat(tdpath,".."U_FILE_SEP_STRING);
|
||||
strcat(tdpath, tdrelativepath);
|
||||
strcat(tdpath,"testdata");
|
||||
*err =U_ZERO_ERROR;
|
||||
test=ures_open(tdpath, "testtypes", err);
|
||||
/* Fall back did not succeed either so return */
|
||||
if(U_FAILURE(*err)){
|
||||
*err = U_FILE_ACCESS_ERROR;
|
||||
log_err("construction of NULL did not succeed : %s \n", u_errorName(*err));
|
||||
return "";
|
||||
}
|
||||
ures_close(test);
|
||||
_testDataPath = tdpath;
|
||||
return _testDataPath;
|
||||
}
|
||||
ures_close(test);
|
||||
_testDataPath = tdpath;
|
||||
|
|
|
@ -1307,12 +1307,15 @@ static FileStream * getFractionalUCA(void)
|
|||
/* As a fallback, try to guess where the source data was located
|
||||
* at the time ICU was built, and look there.
|
||||
*/
|
||||
#if defined (U_TOPSRCDIR)
|
||||
strcpy(backupPath, U_TOPSRCDIR U_FILE_SEP_STRING "data");
|
||||
#else
|
||||
strcpy(backupPath, u_getDataDirectory());
|
||||
strcat(backupPath, ".." U_FILE_SEP_STRING ".." U_FILE_SEP_STRING "data");
|
||||
#endif
|
||||
#if defined (U_TOPSRCDIR)
|
||||
strcpy(backupPath, U_TOPSRCDIR U_FILE_SEP_STRING "data");
|
||||
#else
|
||||
{
|
||||
UErrorCode errorCode = U_ZERO_ERROR;
|
||||
strcpy(backupPath, loadTestData(&errorCode));
|
||||
strcat(backupPath, U_FILE_SEP_STRING ".." U_FILE_SEP_STRING ".." U_FILE_SEP_STRING ".." U_FILE_SEP_STRING ".." U_FILE_SEP_STRING "data");
|
||||
}
|
||||
#endif
|
||||
strcat(backupPath, U_FILE_SEP_STRING "unidata" U_FILE_SEP_STRING "FractionalUCA.txt");
|
||||
|
||||
result = T_FileStream_open(newPath, "rb");
|
||||
|
|
|
@ -275,11 +275,7 @@ UBool testTag(const char* frag,
|
|||
int32_t i,j;
|
||||
int32_t actual_bundle;
|
||||
int32_t resultLen;
|
||||
char testdatapath[256];
|
||||
const char *directory= u_getDataDirectory();
|
||||
|
||||
uprv_strcpy(testdatapath, directory);
|
||||
uprv_strcat(testdatapath, "testdata");
|
||||
const char *testdatapath = loadTestData(&status);
|
||||
|
||||
is_in[0] = in_Root;
|
||||
is_in[1] = in_te;
|
||||
|
@ -534,7 +530,7 @@ TestOpenDirect(void) {
|
|||
/* falling back to default or root is ok */
|
||||
errorCode=U_ZERO_ERROR;
|
||||
} else {
|
||||
log_err("ures_open(\"translit_index\") succeeded, should fail!\n");
|
||||
log_err("ures_open(\"translit_index\") succeeded, should fail! Got: %s\n", u_errorName(errorCode));
|
||||
}
|
||||
ures_close(translit_index);
|
||||
|
||||
|
|
|
@ -82,12 +82,7 @@ static void TestUDataOpen(){
|
|||
char *icuDataFilePath = 0;
|
||||
struct stat stat_buf;
|
||||
|
||||
const char* tdrelativepath = ".."U_FILE_SEP_STRING".."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");
|
||||
const char* testPath=loadTestData(&status);
|
||||
|
||||
strcat(strcpy(path, u_getDataDirectory()), U_ICUDATA_NAME);
|
||||
|
||||
|
@ -184,8 +179,8 @@ static void TestUDataOpen(){
|
|||
*/
|
||||
log_verbose("Testing udata_open, with base_name.type style fallback to individual file.\n");
|
||||
icuDataFilePath = (char *)malloc(sizeof(char) * (strlen(u_getDataDirectory()) + 50));
|
||||
strcpy(icuDataFilePath, u_getDataDirectory());
|
||||
strcat(icuDataFilePath,tdrelativepath);
|
||||
strcpy(icuDataFilePath, testPath);
|
||||
strrchr(icuDataFilePath, U_FILE_SEP_CHAR)[1] = 0; /* Trncate after the '\' */
|
||||
strcat(icuDataFilePath, "testudata");
|
||||
status = U_ZERO_ERROR;
|
||||
result = udata_open( icuDataFilePath, "typ", "nam", &status);
|
||||
|
@ -202,8 +197,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);
|
||||
strcpy(icuDataFilePath, testPath);
|
||||
status = U_ZERO_ERROR;
|
||||
result = udata_open( icuDataFilePath, "cnv", "test1", &status);
|
||||
if (status != U_ZERO_ERROR) {
|
||||
|
@ -233,7 +227,6 @@ static void TestUDataOpen(){
|
|||
}
|
||||
|
||||
free(path);
|
||||
free(testPath);
|
||||
}
|
||||
|
||||
|
||||
|
@ -250,12 +243,11 @@ static void TestUDataSetAppData(){
|
|||
size_t i;
|
||||
|
||||
/* Open the testdata.dat file, using normal */
|
||||
const char* tdrelativepath = ".."U_FILE_SEP_STRING".."U_FILE_SEP_STRING"test"U_FILE_SEP_STRING"testdata"U_FILE_SEP_STRING"out"U_FILE_SEP_STRING;
|
||||
const char* tdrelativepath = loadTestData(&status);
|
||||
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");
|
||||
strcpy(filePath, tdrelativepath);
|
||||
strcat(filePath, ".dat");
|
||||
|
||||
log_verbose("Testing udata_setAppData()\n");
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue