ICU-5348 Fixes for UCONFIG_NO_FILE_IO = 1

X-SVN-Rev: 20174
This commit is contained in:
George Rhoten 2006-08-29 02:09:12 +00:00
parent e33252c102
commit 4c36af547c
7 changed files with 162 additions and 72 deletions

View File

@ -877,7 +877,7 @@ static void TestISOFunctions()
ures_getByKey(res, "Languages", res, &status);
if (U_FAILURE(status)) {
log_err("There is an error in structLocale's ures_getByKey(\"Languages\"), status=%s\n", u_errorName(status));
status = U_ZERO_ERROR;
return;
}
for(count = 0; *(str+count) != 0; count++)

View File

@ -1,6 +1,6 @@
/********************************************************************
* COPYRIGHT:
* Copyright (c) 1997-2005, International Business Machines Corporation and
* Copyright (c) 1997-2006, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************/
/*******************************************************************************
@ -129,6 +129,13 @@ void TestAliasConflict(void) {
void TestResourceBundles()
{
UErrorCode status = U_ZERO_ERROR;
loadTestData(&status);
if(U_FAILURE(status)) {
log_err("Could not load testdata.dat, status = %s\n", u_errorName(status));
return;
}
testTag("only_in_Root", TRUE, FALSE, FALSE);
testTag("in_Root_te", TRUE, TRUE, FALSE);
testTag("in_Root_te_te_IN", TRUE, TRUE, TRUE);

View File

@ -1456,6 +1456,12 @@ static void TestGetVersionColl(){
static void TestResourceBundles()
{
UErrorCode status = U_ZERO_ERROR;
loadTestData(&status);
if(U_FAILURE(status)) {
log_err("Could not load testdata.dat, status = %s\n", u_errorName(status));
return;
}
testTag("only_in_Root", TRUE, FALSE, FALSE);
testTag("in_Root_te", TRUE, TRUE, FALSE);

View File

@ -56,6 +56,12 @@ addUStringPrepTest(TestNode** root)
static void
Test_nfs4_cs_prep_data(void){
UErrorCode errorCode = U_ZERO_ERROR;
loadTestData(&errorCode);
if(U_FAILURE(errorCode)) {
log_err("Could not load testdata.dat, status = %s\n", u_errorName(errorCode));
return;
}
log_verbose("Testing nfs4_cs_prep_ci.txt\n");
doStringPrepTest("nfscsi","nfs4_cs_prep_ci.txt", USPREP_DEFAULT, &errorCode);
@ -74,6 +80,12 @@ Test_nfs4_cis_prep_data(void){
static void
Test_nfs4_mixed_prep_data(void){
UErrorCode errorCode = U_ZERO_ERROR;
loadTestData(&errorCode);
if(U_FAILURE(errorCode)) {
log_err("Could not load testdata.dat, status = %s\n", u_errorName(errorCode));
return;
}
log_verbose("Testing nfs4_mixed_prep_s.txt\n");
doStringPrepTest("nfsmxs","nfs4_mixed_prep_s.txt", USPREP_DEFAULT, &errorCode);
@ -470,6 +482,13 @@ Test_nfs4_mixed_prep(void){
static void
Test_nfs4_cs_prep(void){
UErrorCode errorCode = U_ZERO_ERROR;
loadTestData(&errorCode);
if(U_FAILURE(errorCode)) {
log_err("Could not load testdata.dat, status = %s\n", u_errorName(errorCode));
return;
}
{
/* BiDi checking is turned off */
const char *source = "\\uC138\\uACC4\\uC758\\uBAA8\\uB4E0\\uC0AC\\uB78C\\uB4E4\\uC774\\u0644\\u064A\\u0647\\uD55C\\uAD6D\\uC5B4\\uB97C\\uC774\\uD574\\uD55C\\uB2E4\\uBA74";
@ -577,6 +596,10 @@ static void TestBEAMWarning(){
const char *testdatapath = NULL;
UChar src =0x0000;
testdatapath = loadTestData(&status);
if(U_FAILURE(status)) {
log_err("Could not load testdata.dat, status = %s\n", u_errorName(status));
return;
}
/* open the profile */
profile = usprep_open(testdatapath, "nfscis", &status);
usprep_prepare(profile,&src , 0, NULL, 0, USPREP_DEFAULT, &parseError, &status);

View File

@ -131,6 +131,10 @@ static void TestUDataOpen(){
struct stat stat_buf;
const char* testPath=loadTestData(&status);
if(U_FAILURE(status)) {
log_err("Could not load testdata.dat, status = %s\n", u_errorName(status));
return;
}
/* lots_of_mallocs(); */
@ -354,6 +358,11 @@ static void TestUDataSetAppData(){
const char* tdrelativepath = loadTestData(&status);
char* filePath=(char*)malloc(sizeof(char) * (strlen(tdrelativepath) + strlen(".dat") +1 +strlen(tdrelativepath)) );
if(U_FAILURE(status)) {
log_err("Could not load testdata.dat, status = %s\n", u_errorName(status));
return;
}
strcpy(filePath, tdrelativepath);
strcat(filePath, ".dat");
@ -607,6 +616,10 @@ static void TestUDataOpenChoiceDemo1() {
const char* type="icu";
const char* testPath="testdata";
const char* fullTestDataPath = loadTestData(&status);
if(U_FAILURE(status)) {
log_err("Could not load testdata.dat, status = %s\n", u_errorName(status));
return;
}
result=udata_openChoice(NULL, "icu", name[0], isAcceptable1, NULL, &status);
if(U_FAILURE(status)){
@ -699,6 +712,10 @@ static void TestUDataOpenChoiceDemo2() {
const char* name="test";
const char* type="icu";
const char* path = loadTestData(&status);
if(U_FAILURE(status)) {
log_err("Could not load testdata.dat, status = %s\n", u_errorName(status));
return;
}
result=udata_openChoice(path, type, name, isAcceptable, &p, &status);
if(U_FAILURE(status)){
@ -757,6 +774,10 @@ static void TestUDataGetInfo() {
const char* type="icu";
const char* testPath=loadTestData(&status);
if(U_FAILURE(status)) {
log_err("Could not load testdata.dat, status = %s\n", u_errorName(status));
return;
}
log_verbose("Testing udata_getInfo() for cnvalias.icu\n");
result=udata_open(NULL, "icu", name, &status);
@ -819,6 +840,10 @@ static void TestUDataGetMemory() {
const char* name2="test";
const char* testPath = loadTestData(&status);
if(U_FAILURE(status)) {
log_err("Could not load testdata.dat, status = %s\n", u_errorName(status));
return;
}
type="icu";
log_verbose("Testing udata_getMemory() for \"cnvalias.icu\"\n");
@ -874,6 +899,10 @@ static void TestErrorConditions(){
const char* type="icu";
const char *testPath = loadTestData(&status);
if(U_FAILURE(status)) {
log_err("Could not load testdata.dat, status = %s\n", u_errorName(status));
return;
}
status = U_ILLEGAL_ARGUMENT_ERROR;
/*Try udata_open with status != U_ZERO_ERROR*/
@ -966,85 +995,89 @@ static void TestErrorConditions(){
/* Test whether apps and ICU can each have their own root.res */
static void TestAppData()
{
UResourceBundle *icu, *app;
UResourceBundle *tmp = NULL;
UResourceBundle *tmp2 = NULL;
const UChar *appString;
const UChar *icuString;
UResourceBundle *icu, *app;
UResourceBundle *tmp = NULL;
UResourceBundle *tmp2 = NULL;
int32_t len;
const UChar *appString;
const UChar *icuString;
UErrorCode status = U_ZERO_ERROR;
char testMsgBuf[256];
int32_t len;
const char* testPath=loadTestData(&status);
UErrorCode status = U_ZERO_ERROR;
char testMsgBuf[256];
icu = ures_open(NULL, "root", &status);
if(U_FAILURE(status))
{
log_err("%s:%d: Couldn't open root ICU bundle- %s", __FILE__, __LINE__, u_errorName(status));
return;
}
/* log_info("Open icu root: %s size_%d\n", u_errorName(status), ures_getSize(icu)); */
status = U_ZERO_ERROR;
app = ures_open(testPath, "root", &status);
if(U_FAILURE(status))
{
log_err("%s:%d: Couldn't open app ICU bundle [%s]- %s", __FILE__, __LINE__, testPath, u_errorName(status));
return;
}
/* log_info("Open app: %s, size %d\n", u_errorName(status), ures_getSize(app)); */
const char* testPath=loadTestData(&status);
if(U_FAILURE(status)) {
log_err("Could not load testdata.dat, status = %s\n", u_errorName(status));
return;
}
tmp = ures_getByKey(icu, "Version", tmp, &status);
if(U_FAILURE(status))
{
log_err("%s:%d: Couldn't get Version string from ICU root bundle- %s", __FILE__, __LINE__, u_errorName(status));
return;
}
icu = ures_open(NULL, "root", &status);
if(U_FAILURE(status))
{
log_err("%s:%d: Couldn't open root ICU bundle- %s", __FILE__, __LINE__, u_errorName(status));
return;
}
/* log_info("Open icu root: %s size_%d\n", u_errorName(status), ures_getSize(icu)); */
status = U_ZERO_ERROR;
icuString = ures_getString(tmp, &len, &status);
if(U_FAILURE(status))
{
log_err("%s:%d: Couldn't get string from Version string from ICU root bundle- %s", __FILE__, __LINE__, u_errorName(status));
return;
}
/* log_info("icuString=%p - %s\n", icuString, austrdup(icuString)); */
app = ures_open(testPath, "root", &status);
if(U_FAILURE(status))
{
log_err("%s:%d: Couldn't open app ICU bundle [%s]- %s", __FILE__, __LINE__, testPath, u_errorName(status));
return;
}
/* log_info("Open app: %s, size %d\n", u_errorName(status), ures_getSize(app)); */
tmp = ures_getByKey(icu, "Version", tmp, &status);
if(U_FAILURE(status))
{
log_err("%s:%d: Couldn't get Version string from ICU root bundle- %s", __FILE__, __LINE__, u_errorName(status));
return;
}
icuString = ures_getString(tmp, &len, &status);
if(U_FAILURE(status))
{
log_err("%s:%d: Couldn't get string from Version string from ICU root bundle- %s", __FILE__, __LINE__, u_errorName(status));
return;
}
/* log_info("icuString=%p - %s\n", icuString, austrdup(icuString)); */
tmp2 = ures_getByKey(app, "Version", tmp2, &status);
if(U_FAILURE(status))
{
log_err("%s:%d: Couldn't get Version string from App root bundle- %s", __FILE__, __LINE__, u_errorName(status));
return;
}
tmp2 = ures_getByKey(app, "Version", tmp2, &status);
if(U_FAILURE(status))
{
log_err("%s:%d: Couldn't get Version string from App root bundle- %s", __FILE__, __LINE__, u_errorName(status));
return;
}
appString = ures_getString(tmp2, &len, &status);
if(U_FAILURE(status))
{
log_err("%s:%d: Couldn't get string from Version string from App root bundle- %s", __FILE__, __LINE__, u_errorName(status));
return;
}
appString = ures_getString(tmp2, &len, &status);
if(U_FAILURE(status))
{
log_err("%s:%d: Couldn't get string from Version string from App root bundle- %s", __FILE__, __LINE__, u_errorName(status));
return;
}
/* log_info("appString=%p - %s\n", appString, austrdup(appString)); */
/* log_info("appString=%p - %s\n", appString, austrdup(appString)); */
if(!u_strcmp(icuString, appString))
{
log_err("%s:%d: Error! Expected ICU and App root version strings to be DIFFERENT but they are both %s and %s\n", __FILE__, __LINE__, austrdup(icuString),
austrdup(appString));
}
else
{
log_verbose("%s:%d: appstr=%s, icustr=%s\n", __FILE__,
__LINE__, u_austrcpy(testMsgBuf, appString), u_austrcpy(testMsgBuf, icuString));
}
if(!u_strcmp(icuString, appString))
{
log_err("%s:%d: Error! Expected ICU and App root version strings to be DIFFERENT but they are both %s and %s\n", __FILE__, __LINE__, austrdup(icuString),
austrdup(appString));
}
else
{
log_verbose("%s:%d: appstr=%s, icustr=%s\n", __FILE__,
__LINE__, u_austrcpy(testMsgBuf, appString), u_austrcpy(testMsgBuf, icuString));
}
ures_close(tmp);
ures_close(tmp2);
ures_close(icu);
ures_close(app);
ures_close(tmp);
ures_close(tmp2);
ures_close(icu);
ures_close(app);
}
static void TestICUDataName()
@ -1540,7 +1573,7 @@ TestSwapData() {
UDataSwapper *ds;
UDataMemory *pData;
uint8_t *buffer;
const char *pkg, *nm;
const char *pkg, *nm, *testPath;
UErrorCode errorCode;
int32_t i;
@ -1550,6 +1583,11 @@ TestSwapData() {
return;
}
testPath=loadTestData(&errorCode);
if(U_FAILURE(errorCode)) {
log_err("Could not load testdata.dat, status = %s\n", u_errorName(errorCode));
}
/* Test that printError works as expected. */
errorCode=U_USELESS_COLLATOR_ERROR;
ds=udata_openSwapper(U_IS_BIG_ENDIAN, U_ASCII_FAMILY,
@ -1607,7 +1645,7 @@ TestSwapData() {
/* build the name for logging */
errorCode=U_ZERO_ERROR;
if(swapCases[i].name[0]=='*') {
pkg=loadTestData(&errorCode);
pkg=testPath;
nm=swapCases[i].name+1;
uprv_strcpy(name, "testdata");
} else if (uprv_strcmp(swapCases[i].type, "brk")==0

View File

@ -1,6 +1,6 @@
/********************************************************************
* COPYRIGHT:
* Copyright (c) 1997-2005, International Business Machines Corporation and
* Copyright (c) 1997-2006, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************/
@ -197,6 +197,14 @@ void ResourceBundleTest::runIndexedTest( int32_t index, UBool exec, const char*
void
ResourceBundleTest::TestResourceBundles()
{
UErrorCode status = U_ZERO_ERROR;
loadTestData(status);
if(U_FAILURE(status))
{
errln("Could not load testdata.dat %s " + UnicodeString(u_errorName(status)));
return;
}
testTag("only_in_Root", TRUE, FALSE, FALSE);
testTag("only_in_te", FALSE, TRUE, FALSE);
testTag("only_in_te_IN", FALSE, FALSE, TRUE);

View File

@ -1,6 +1,6 @@
/********************************************************************
* COPYRIGHT:
* Copyright (c) 1997-2005, International Business Machines Corporation and
* Copyright (c) 1997-2006, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************/
@ -197,6 +197,14 @@ void NewResourceBundleTest::runIndexedTest( int32_t index, UBool exec, const cha
void
NewResourceBundleTest::TestResourceBundles()
{
UErrorCode status = U_ZERO_ERROR;
loadTestData(status);
if(U_FAILURE(status))
{
errln("Could not load testdata.dat %s " + UnicodeString(u_errorName(status)));
return;
}
testTag("only_in_Root", TRUE, FALSE, FALSE);
testTag("only_in_te", FALSE, TRUE, FALSE);
testTag("only_in_te_IN", FALSE, FALSE, TRUE);