ICU-4354 Add dataerr(), dataerrln() to intltest.

X-SVN-Rev: 17462
This commit is contained in:
Eric Mader 2005-04-05 20:12:22 +00:00
parent 88f310afe6
commit e904300468
3 changed files with 92 additions and 6 deletions

View file

@ -487,8 +487,10 @@ IntlTest::IntlTest()
path = NULL;
LL_linestart = TRUE;
errorCount = 0;
dataErrorCount = 0;
verbose = FALSE;
no_err_msg = FALSE;
warn_on_missing_data = FALSE;
quick = FALSE;
leaks = FALSE;
testoutfp = stdout;
@ -526,6 +528,13 @@ UBool IntlTest::setVerbose( UBool verboseVal )
return rval;
}
UBool IntlTest::setWarnOnMissingData( UBool warn_on_missing_dataVal )
{
UBool rval = this->warn_on_missing_data;
this->warn_on_missing_data = warn_on_missing_dataVal;
return rval;
}
UBool IntlTest::setNoErrMsg( UBool no_err_msgVal )
{
UBool rval = this->no_err_msg;
@ -552,6 +561,11 @@ int32_t IntlTest::getErrors( void )
return errorCount;
}
int32_t IntlTest::getDataErrors( void )
{
return dataErrorCount;
}
UBool IntlTest::runTest( char* name, char* par )
{
UBool rval;
@ -712,7 +726,15 @@ int32_t IntlTest::IncErrorCount( void )
return errorCount;
}
void IntlTest::err() {
int32_t IntlTest::IncDataErrorCount( void )
{
dataErrorCount++;
if (caller) caller->IncDataErrorCount();
return dataErrorCount;
}
void IntlTest::err()
{
IncErrorCount();
}
@ -728,6 +750,28 @@ void IntlTest::errln( const UnicodeString &message )
if (!no_err_msg) LL_message( message, TRUE );
}
void IntlTest::dataerr( const UnicodeString &message )
{
IncDataErrorCount();
if (!warn_on_missing_data) {
IncErrorCount();
}
if (!no_err_msg) LL_message( message, FALSE );
}
void IntlTest::dataerrln( const UnicodeString &message )
{
IncDataErrorCount();
if (!warn_on_missing_data) {
IncErrorCount();
}
if (!no_err_msg) LL_message( message, TRUE );
}
/* convenience functions that include sprintf formatting */
void IntlTest::log(const char *fmt, ...)
{
@ -804,6 +848,17 @@ void IntlTest::errln(const char *fmt, ...)
errln(UnicodeString(buffer, ""));
}
void IntlTest::dataerrln(const char *fmt, ...)
{
char buffer[4000];
va_list ap;
va_start(ap, fmt);
vsprintf(buffer, fmt, ap);
va_end(ap);
dataerrln(UnicodeString(buffer, ""));
}
void IntlTest::printErrors()
{
IntlTest::LL_message(errorList, TRUE);
@ -981,16 +1036,18 @@ main(int argc, char* argv[])
major.setNoErrMsg( no_err_msg );
major.setQuick( quick );
major.setLeaks( leaks );
major.setWarnOnMissingData( warnOnMissingData );
fprintf(stdout, "-----------------------------------------------\n");
fprintf(stdout, " IntlTest (C++) Test Suite for \n");
fprintf(stdout, " International Components for Unicode %s\n", U_ICU_VERSION);
fprintf(stdout, "-----------------------------------------------\n");
fprintf(stdout, " Options: \n");
fprintf(stdout, " all (a) : %s\n", (all? "On" : "Off"));
fprintf(stdout, " Verbose (v) : %s\n", (verbose? "On" : "Off"));
fprintf(stdout, " No error messages (n) : %s\n", (no_err_msg? "On" : "Off"));
fprintf(stdout, " Exhaustive (e) : %s\n", (!quick? "On" : "Off"));
fprintf(stdout, " Leaks (l) : %s\n", (leaks? "On" : "Off"));
fprintf(stdout, " all (a) : %s\n", (all? "On" : "Off"));
fprintf(stdout, " Verbose (v) : %s\n", (verbose? "On" : "Off"));
fprintf(stdout, " No error messages (n) : %s\n", (no_err_msg? "On" : "Off"));
fprintf(stdout, " Exhaustive (e) : %s\n", (!quick? "On" : "Off"));
fprintf(stdout, " Leaks (l) : %s\n", (leaks? "On" : "Off"));
fprintf(stdout, " Warn on missing data (w) : %s\n", (warnOnMissingData? "On" : "Off"));
fprintf(stdout, "-----------------------------------------------\n");
/* Check whether ICU will initialize without forcing the build data directory into
@ -1129,10 +1186,21 @@ main(int argc, char* argv[])
u_cleanup();
fprintf(stdout, "OK: All tests passed without error.\n");
if (major.getDataErrors() != 0) {
fprintf(stdout, "\t*WARNING* some data-loading errors were ignored by the -w option.\n");
}
}else{
fprintf(stdout, "Errors in total: %ld.\n", (long)major.getErrors());
major.printErrors();
if (major.getDataErrors() != 0) {
fprintf(stdout, "\t*Note* some errors are data-loading related. If the data used is not the \n"
"\tstock ICU data (i.e some have been added or removed), consider using\n"
"\tthe '-w' option to turn these errors into warnings.\n");
}
/* Call afterwards to display errors. */
u_cleanup();
}

View file

@ -78,8 +78,10 @@ public:
virtual UBool setNoErrMsg( UBool no_err_msg = TRUE );
virtual UBool setQuick( UBool quick = TRUE );
virtual UBool setLeaks( UBool leaks = TRUE );
virtual UBool setWarnOnMissingData( UBool warn_on_missing_data = TRUE );
virtual int32_t getErrors( void );
virtual int32_t getDataErrors (void );
virtual void setCaller( IntlTest* callingTest ); // for internal use only
virtual void setPath( char* path ); // for internal use only
@ -102,6 +104,10 @@ public:
virtual void errln( const UnicodeString &message );
virtual void dataerr( const UnicodeString &message );
virtual void dataerrln( const UnicodeString &message );
// convenience functions: sprintf() + errln() etc.
void log(const char *fmt, ...);
void logln(const char *fmt, ...);
@ -109,6 +115,8 @@ public:
void infoln(const char *fmt, ...);
void err(const char *fmt, ...);
void errln(const char *fmt, ...);
void dataerr(const char *fmt, ...);
void dataerrln(const char *fmt, ...);
// Print ALL named errors encountered so far
void printErrors();
@ -166,6 +174,8 @@ protected:
virtual int32_t IncErrorCount( void );
virtual int32_t IncDataErrorCount( void );
virtual UBool callTest( IntlTest& testToBeCalled, char* par );
@ -173,12 +183,14 @@ protected:
UBool no_err_msg;
UBool quick;
UBool leaks;
UBool warn_on_missing_data;
private:
UBool LL_linestart;
int32_t LL_indentlevel;
int32_t errorCount;
int32_t dataErrorCount;
IntlTest* caller;
char* path; // specifies subtests

View file

@ -1193,6 +1193,12 @@ LocaleTest::TestEuroSupport()
UnicodeString temp;
NumberFormat *nf = NumberFormat::createCurrencyInstance(loc, status);
UnicodeString pos;
if (U_FAILURE(status)) {
dataerrln("Error calling NumberFormat::createCurrencyInstance(%s)", *locales);
continue;
}
nf->format(271828.182845, pos);
UnicodeString neg;
nf->format(-271828.182845, neg);