ICU-9802 Fix failures in running cintltst and intltest without data

X-SVN-Rev: 33089
This commit is contained in:
Michael Ow 2013-01-29 01:51:53 +00:00
parent 44dcd1d90a
commit 2724d7c5cc
6 changed files with 67 additions and 58 deletions

View File

@ -909,6 +909,10 @@ static void TestCalendarDateParse() {
U_STRING_INIT(text, "75", 2);
simpleDateFormat = udat_open(UDAT_FULL, UDAT_FULL, "en-GB", 0, 0, 0, 0, &ec);
if (U_FAILURE(ec)) {
log_data_err("udat_open(UDAT_FULL, UDAT_FULL, \"en-GB\", 0, 0, 0, 0, &ec) failed: %s - (Are you missing data?)\n", u_errorName(ec));
return;
}
udat_applyPattern(simpleDateFormat, 0, pattern, u_strlen(pattern));
udat_setLenient(simpleDateFormat, 0);

View File

@ -2522,7 +2522,7 @@ static void TestEnglishExemplarCharacters(void) {
};
ULocaleData *uld = ulocdata_open("en", &status);
if (U_FAILURE(status)) {
log_err("ulocdata_open() failed\n");
log_data_err("ulocdata_open() failed : %s - (Are you missing data?)\n", u_errorName(status));
return;
}

View File

@ -1,6 +1,6 @@
/*
*******************************************************************************
* Copyright (C) 1997-2012, International Business Machines Corporation and *
* Copyright (C) 1997-2013, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*
@ -246,7 +246,8 @@ void CompactDecimalFormatTest::TestFieldPosition() {
UErrorCode status = U_ZERO_ERROR;
LocalPointer<CompactDecimalFormat> cdf(createCDFInstance("sw", UNUM_SHORT, status));
if (U_FAILURE(status)) {
errln("Unable to create format object - %s", u_errorName(status));
dataerrln("Unable to create format object - %s", u_errorName(status));
return;
}
FieldPosition fp(UNUM_INTEGER_FIELD);
UnicodeString result;
@ -282,7 +283,7 @@ void CompactDecimalFormatTest::TestSignificantDigits() {
UErrorCode status = U_ZERO_ERROR;
LocalPointer<CompactDecimalFormat> cdf(CompactDecimalFormat::createInstance("en", UNUM_SHORT, status));
if (U_FAILURE(status)) {
errln("Unable to create format object - %s", u_errorName(status));
dataerrln("Unable to create format object - %s", u_errorName(status));
return;
}
UnicodeString actual;
@ -298,7 +299,7 @@ void CompactDecimalFormatTest::CheckLocale(const Locale& locale, UNumberCompactS
UErrorCode status = U_ZERO_ERROR;
LocalPointer<CompactDecimalFormat> cdf(createCDFInstance(locale, style, status));
if (U_FAILURE(status)) {
errln("Unable to create format object - %s", u_errorName(status));
dataerrln("Unable to create format object - %s", u_errorName(status));
return;
}
char description[256];

View File

@ -1,7 +1,7 @@
/*
*******************************************************************************
*
* Copyright (C) 2012, International Business Machines
* Copyright (C) 2012-2013, International Business Machines
* Corporation and others. All Rights Reserved.
*
*******************************************************************************
@ -39,7 +39,7 @@ void ListFormatterTest::CheckFourCases(const char* locale_string, UnicodeString
UErrorCode errorCode = U_ZERO_ERROR;
LocalPointer<ListFormatter> formatter(ListFormatter::createInstance(Locale(locale_string), errorCode));
if (U_FAILURE(errorCode)) {
errln("Allocation problem\n");
dataerrln("ListFormatter::createInstance(Locale(\"%s\"), errorCode) failed in CheckFourCases: %s", locale_string, u_errorName(errorCode));
return;
}
UnicodeString input1[] = {one};
@ -60,7 +60,7 @@ UBool ListFormatterTest::RecordFourCases(const Locale& locale, UnicodeString one
UErrorCode errorCode = U_ZERO_ERROR;
LocalPointer<ListFormatter> formatter(ListFormatter::createInstance(locale, errorCode));
if (U_FAILURE(errorCode)) {
errln("Allocation problem in RecordFourCases\n");
dataerrln("ListFormatter::createInstance(\"%s\", errorCode) failed in RecordFourCases: %s", locale.getName(), u_errorName(errorCode));
return FALSE;
}
UnicodeString input1[] = {one};

View File

@ -388,7 +388,7 @@ void RegionTest::TestKnownRegions() {
}
}
} else {
errln("Known region %s was not recognized.",rd.code);
dataerrln("Known region %s was not recognized.",rd.code);
}
}
}
@ -440,10 +440,10 @@ void RegionTest::TestGetInstanceString() {
type = URGN_UNKNOWN;
}
if ( uprv_strcmp(id,data.expectedID)) {
errln("Unexpected region ID for Region::getInstance(\"%s\"); Expected: %s Got: %s",data.inputID,data.expectedID,id);
dataerrln("Unexpected region ID for Region::getInstance(\"%s\"); Expected: %s Got: %s",data.inputID,data.expectedID,id);
}
if ( type != data.expectedType) {
errln("Unexpected region type for Region::getInstance(\"%s\"); Expected: %d Got: %d",data.inputID,data.expectedType,type);
dataerrln("Unexpected region type for Region::getInstance(\"%s\"); Expected: %d Got: %d",data.inputID,data.expectedType,type);
}
}
}
@ -484,10 +484,10 @@ void RegionTest::TestGetInstanceInt() {
type = URGN_UNKNOWN;
}
if ( uprv_strcmp(data.expectedID,id)) {
errln("Unexpected region ID for Region.getInstance(%d)); Expected: %s Got: %s",data.inputID,data.expectedID,id);
dataerrln("Unexpected region ID for Region.getInstance(%d)); Expected: %s Got: %s",data.inputID,data.expectedID,id);
}
if ( data.expectedType != type) {
errln("Unexpected region type for Region.getInstance(%d)); Expected: %d Got: %d",data.inputID,data.expectedType,type);
dataerrln("Unexpected region type for Region.getInstance(%d)); Expected: %d Got: %d",data.inputID,data.expectedType,type);
}
}
}
@ -514,7 +514,7 @@ void RegionTest::TestGetContainedRegions() {
}
delete containedRegions;
} else {
errln("Known region %s was not recognized.",rd.code);
dataerrln("Known region %s was not recognized.",rd.code);
}
}
}
@ -541,7 +541,7 @@ void RegionTest::TestGetContainedRegionsWithType() {
}
delete containedRegions;
} else {
errln("Known region %s was not recognized.",rd.code);
dataerrln("Known region %s was not recognized.",rd.code);
}
}
}
@ -565,7 +565,7 @@ void RegionTest::TestGetContainingRegion() {
}
}
} else {
errln("Known region %s was not recognized.",rd.code);
dataerrln("Known region %s was not recognized.",rd.code);
}
}
}
@ -590,7 +590,7 @@ void RegionTest::TestGetContainingRegionWithType() {
}
}
} else {
errln("Known region %s was not recognized.",rd.code);
dataerrln("Known region %s was not recognized.",rd.code);
}
}
}
@ -627,7 +627,7 @@ void RegionTest::TestGetPreferredValues() {
}
delete preferredValues;
} else {
errln("Known region %s was not recognized.",data[0]);
dataerrln("Known region %s was not recognized.",data[0]);
}
}
}
@ -647,47 +647,51 @@ void RegionTest::TestContains() {
c = c->getContainingRegion();
}
} else {
errln("Known region %s was not recognized.",rd.code);
dataerrln("Known region %s was not recognized.",rd.code);
}
}
}
void RegionTest::TestAvailableTerritories() {
// Test to make sure that the set of territories contained in World and the set of all available
// territories are one and the same.
UErrorCode status = U_ZERO_ERROR;
StringEnumeration *availableTerritories = Region::getAvailable(URGN_TERRITORY);
const Region *world = Region::getInstance("001",status);
StringEnumeration *containedInWorld = world->getContainedRegions(URGN_TERRITORY);
if ( !availableTerritories || !containedInWorld || *availableTerritories != *containedInWorld ) {
char availableTerritoriesString[1024] = "";
char containedInWorldString[1024] = "";
if ( availableTerritories ) {
for (int32_t i = 0 ; i < availableTerritories->count(status) ; i++ ) {
if ( i > 0 ) {
uprv_strcat(availableTerritoriesString," ");
}
uprv_strcat(availableTerritoriesString,availableTerritories->next(NULL,status));
}
} else {
uprv_strcpy(availableTerritoriesString,"NULL");
}
if ( containedInWorld ) {
for (int32_t i = 0 ; i < containedInWorld->count(status) ; i++ ) {
if ( i > 0 ) {
uprv_strcat(containedInWorldString," ");
}
uprv_strcat(containedInWorldString,containedInWorld->next(NULL,status));
}
} else {
uprv_strcpy(containedInWorldString,"NULL");
}
errln("Available territories and all territories contained in world should be the same set.\nAvailable = %s\nContained in World = %s",
availableTerritoriesString,containedInWorldString);
}
delete availableTerritories;
delete containedInWorld;
// Test to make sure that the set of territories contained in World and the set of all available
// territories are one and the same.
UErrorCode status = U_ZERO_ERROR;
StringEnumeration *availableTerritories = Region::getAvailable(URGN_TERRITORY);
const Region *world = Region::getInstance("001",status);
if (U_FAILURE(status)) {
dataerrln("Region::getInstance(\"001\",status) failed: %s", u_errorName(status));
return;
}
StringEnumeration *containedInWorld = world->getContainedRegions(URGN_TERRITORY);
if ( !availableTerritories || !containedInWorld || *availableTerritories != *containedInWorld ) {
char availableTerritoriesString[1024] = "";
char containedInWorldString[1024] = "";
if ( availableTerritories ) {
for (int32_t i = 0 ; i < availableTerritories->count(status) ; i++ ) {
if ( i > 0 ) {
uprv_strcat(availableTerritoriesString," ");
}
uprv_strcat(availableTerritoriesString,availableTerritories->next(NULL,status));
}
} else {
uprv_strcpy(availableTerritoriesString,"NULL");
}
if ( containedInWorld ) {
for (int32_t i = 0 ; i < containedInWorld->count(status) ; i++ ) {
if ( i > 0 ) {
uprv_strcat(containedInWorldString," ");
}
uprv_strcat(containedInWorldString,containedInWorld->next(NULL,status));
}
} else {
uprv_strcpy(containedInWorldString,"NULL");
}
errln("Available territories and all territories contained in world should be the same set.\nAvailable = %s\nContained in World = %s",
availableTerritoriesString,containedInWorldString);
}
delete availableTerritories;
delete containedInWorld;
}
#endif /* #if !UCONFIG_NO_FORMATTING */
//eof

View File

@ -1,6 +1,6 @@
/*
**********************************************************************
* Copyright (C) 2005-2012, International Business Machines
* Copyright (C) 2005-2013, International Business Machines
* Corporation and others. All Rights Reserved.
**********************************************************************
*/
@ -34,7 +34,7 @@ char testId[100];
errln("Failure in file %s, line %d, test ID = \"%s\"", __FILE__, __LINE__, testId);}}
#define TEST_ASSERT_M(x, m) {if (!(x)) { \
errln("Failure in file %s, line %d. \"%s\"", __FILE__, __LINE__, m);return;}}
dataerrln("Failure in file %s, line %d. \"%s\"", __FILE__, __LINE__, m);return;}}
#define TEST_ASSERT_SUCCESS(errcode) {if (U_FAILURE(errcode)) { \
dataerrln("Failure in file %s, line %d, test ID \"%s\", status = \"%s\"", \
@ -763,7 +763,7 @@ void SSearchTest::sharpSTest()
if (bFound) {
logln("Test %d: found long pattern at [%d, %d].", t, start, end);
} else {
errln("Test %d: did not find long pattern.", t);
dataerrln("Test %d: did not find long pattern.", t);
}
usearch_setText(ussShort.getAlias(), target.getBuffer(), target.length(), &status);
@ -772,7 +772,7 @@ void SSearchTest::sharpSTest()
if (bFound) {
logln("Test %d: found long pattern at [%d, %d].", t, start, end);
} else {
errln("Test %d: did not find long pattern.", t);
dataerrln("Test %d: did not find long pattern.", t);
}
}
@ -803,7 +803,7 @@ void SSearchTest::goodSuffixTest()
if (bFound) {
logln("Found pattern at [%d, %d].", start, end);
} else {
errln("Did not find pattern.");
dataerrln("Did not find pattern.");
}
ucol_close(coll);