ICU-2840 tests shouldn't crash if there is no data

X-SVN-Rev: 12305
This commit is contained in:
Vladimir Weinstein 2003-06-04 23:56:49 +00:00
parent b37a895921
commit ec21353ba5
4 changed files with 23 additions and 9 deletions

View File

@ -1224,8 +1224,10 @@ LocaleTest::Test4143951()
{
UErrorCode status = U_ZERO_ERROR;
Calendar *cal = Calendar::createInstance(Locale("ru", "", ""), status);
if (cal->getFirstDayOfWeek(status) != UCAL_MONDAY) {
errln("Fail: First day of week in Russia should be Monday");
if(U_SUCCESS(status)) {
if (cal->getFirstDayOfWeek(status) != UCAL_MONDAY) {
errln("Fail: First day of week in Russia should be Monday");
}
}
delete cal;
}

View File

@ -414,6 +414,7 @@ NewResourceBundleTest::TestOtherAPI(){
ResourceBundle defaultresource(err);
if(U_FAILURE(err)){
errln("Construction of default resourcebundle failed");
return;
}
if(strcmp(defaultresource.getLocale().getName(), Locale::getDefault().getName()) != 0){
errln("Construction of default resourcebundle didn't take the defaultlocale\n");

View File

@ -669,6 +669,7 @@ public:
virtual void run()
{
UMTX myMutex = 0;
// Keep this data here to avoid static initialization.
FormatThreadTestData kNumberFormatTestData[] =
{
@ -699,7 +700,7 @@ public:
if(U_FAILURE(status))
{
Mutex m;
Mutex m(&myMutex);
error("Error on NumberFormat::createInstance()");
return;
}
@ -709,7 +710,7 @@ public:
if(U_FAILURE(status))
{
{
Mutex m;
Mutex m(&myMutex);
error("Error on NumberFormat::createPercentInstance()");
}
delete formatter;
@ -726,7 +727,7 @@ public:
if(0 != output.compare(kNumberFormatTestData[whichLine].string))
{
Mutex m;
Mutex m(&myMutex);
error("format().. expected " + kNumberFormatTestData[whichLine].string + " got " + output);
continue; // will break
}
@ -739,7 +740,7 @@ public:
if(0 != output.compare(kPercentFormatTestData[whichLine].string))
{
Mutex m;
Mutex m(&myMutex);
error("percent format().. \n" + showDifference(kPercentFormatTestData[whichLine].string,output));
continue;
}
@ -790,14 +791,14 @@ public:
{
UnicodeString tmp;
errorToString(status,tmp);
Mutex m;
Mutex m(&myMutex);
error("Failure on message format, pattern=" + patternToCheck +", error = " + tmp);
continue;
}
if(result != expected)
{
Mutex m;
Mutex m(&myMutex);
error("PatternFormat: \n" + showDifference(expected,result));
continue;
}
@ -805,7 +806,7 @@ public:
delete formatter;
delete percentFormatter;
Mutex m;
Mutex m(&myMutex);
done();
}

View File

@ -176,6 +176,7 @@ void UnicodeTest::TestAdditionalProperties() {
int32_t rangeCount, range;
uint32_t i;
UChar32 start, end;
int32_t noErrors = 0;
// test all TRUE properties
for(i=0; i<LENGTHOF(derivedCorePropsNames); ++i) {
@ -186,11 +187,16 @@ void UnicodeTest::TestAdditionalProperties() {
for(; start<=end; ++start) {
if(!u_hasBinaryProperty(start, derivedCorePropsIndex[i])) {
errln("UnicodeTest error: u_hasBinaryProperty(U+%04lx, %s)==FALSE is wrong\n", start, derivedCorePropsNames[i]);
if(noErrors++ > 100) {
errln("Too many errors, moving to the next test");
break;
}
}
}
}
}
noErrors = 0;
// invert all properties
for(i=0; i<LENGTHOF(derivedCorePropsNames); ++i) {
derivedCoreProps[i].complement();
@ -205,6 +211,10 @@ void UnicodeTest::TestAdditionalProperties() {
for(; start<=end; ++start) {
if(u_hasBinaryProperty(start, derivedCorePropsIndex[i])) {
errln("UnicodeTest error: u_hasBinaryProperty(U+%04lx, %s)==TRUE is wrong\n", start, derivedCorePropsNames[i]);
if(noErrors++ > 100) {
errln("Too many errors, moving to the next test");
break;
}
}
}
}