ICU-368 do not use C++ streams at all for tests so that they can

run in the lame WebObjects 4 environment.

X-SVN-Rev: 1251
This commit is contained in:
Yves Arrouye 2000-04-25 21:32:10 +00:00
parent f59e194eab
commit 5630fb77db
10 changed files with 142 additions and 143 deletions

View file

@ -9,12 +9,12 @@
* Modification History:
*
* Date Name Description
* 08/21/98 stephen Creation.
* 08/21/98 stephen Creation.
*******************************************************************************
*/
#include <iostream.h> // cout, cerr
#include <float.h> // DBL_MAX
#include <stdio.h>
#include <float.h> // DBL_MAX
#include "ieeetest.h"
#include "unicode/utypes.h"
@ -32,23 +32,23 @@ main(int argc,
if(argv[i][0] == '-') {
switch(argv[i][1]) {
case 'v':
flags += IEEETest::kVerboseMode;
break;
flags += IEEETest::kVerboseMode;
break;
case '?':
case 'h':
case 'H':
usage(argv[0]);
return 0;
break;
usage(argv[0]);
return 0;
break;
default:
break;
break;
}
}
}
IEEETest test(flags);
IEEETest test(flags);
return test.run();
}
@ -58,10 +58,9 @@ main(int argc,
void
usage(const char *execName)
{
cout << endl;
cout << "usage: " << execName << " [flags]" << endl << endl;
cout << "Flags:" << endl;
cout << " -v Verbose mode" << endl;
fprintf(stdout, "usage: %s [flags]\n\n"
"Flags:\n"
"-v Verbose mode\n", execName);
}
//==============================
@ -94,7 +93,7 @@ IEEETest::run(void)
errCount += runTest("+Infinity behavior", &IEEETest::testPositiveInfinity);
errCount += runTest("-Infinity behavior", &IEEETest::testNegativeInfinity);
errCount += runTest("Zero behavior", &IEEETest::testZero);
decreaseTestLevel();
if(errCount == 0)
log("IEEETest Passed");
@ -105,7 +104,7 @@ IEEETest::run(void)
logln();
if(errCount == 0 && ! (mFlags & kVerboseMode))
cout << endl << "All tests passed without error." << endl;
fprintf(stdout, "\nAll tests passed without error.\n");
return errCount;
}
@ -113,7 +112,7 @@ IEEETest::run(void)
//==============================
int
IEEETest::runTest(const char *testName,
int (IEEETest::*testFunc)(void))
int (IEEETest::*testFunc)(void))
{
logln().log("Running test ").log(testName).logln();
increaseTestLevel();
@ -161,13 +160,13 @@ IEEETest::testNaN(void)
//==============================
int
int
IEEETest::testPositiveInfinity(void)
{
int errCount = 0;
double pinf = uprv_getInfinity();
double ninf = -uprv_getInfinity();
double ten = 10.0;
double pinf = uprv_getInfinity();
double ninf = -uprv_getInfinity();
double ten = 10.0;
if(uprv_isInfinite(pinf) != TRUE) {
err("FAIL: isInfinite(+Infinity) returned FALSE, should be TRUE.").errln();
@ -209,13 +208,13 @@ IEEETest::testPositiveInfinity(void)
//==============================
int
int
IEEETest::testNegativeInfinity(void)
{
int errCount = 0;
double pinf = uprv_getInfinity();
double ninf = -uprv_getInfinity();
double ten = 10.0;
double pinf = uprv_getInfinity();
double ninf = -uprv_getInfinity();
double ten = 10.0;
if(uprv_isInfinite(ninf) != TRUE) {
err("FAIL: isInfinite(-Infinity) returned FALSE, should be TRUE.").errln();
@ -261,13 +260,13 @@ IEEETest::testNegativeInfinity(void)
// -0.0 == 0.0 == TRUE
// -0.0 < 0.0 == FALSE
// generating -0.0 must be done at runtime. compiler apparently ignores sign?
int
int
IEEETest::testZero(void)
{
int errCount = 0;
double ten = 10.0;
double pzero = 0.0;
double nzero = 0.0;
double ten = 10.0;
double pzero = 0.0;
double nzero = 0.0;
nzero *= -1;
@ -324,11 +323,11 @@ IEEETest::testZero(void)
int
IEEETest::testIsNaN(void)
{
int numErrors = 0;
double pinf = uprv_getInfinity();
double ninf = -uprv_getInfinity();
double nan = uprv_getNaN();
double ten = 10.0;
int numErrors = 0;
double pinf = uprv_getInfinity();
double ninf = -uprv_getInfinity();
double nan = uprv_getNaN();
double ten = 10.0;
if(uprv_isNaN(nan) == FALSE) {
err("FAIL: isNaN() returned FALSE for NaN.").errln();
@ -358,11 +357,11 @@ IEEETest::testIsNaN(void)
int
IEEETest::NaNGT(void)
{
double pinf = uprv_getInfinity();
double ninf = -uprv_getInfinity();
double nan = uprv_getNaN();
double ten = 10.0;
int numErrors = 0;
double pinf = uprv_getInfinity();
double ninf = -uprv_getInfinity();
double nan = uprv_getNaN();
double ten = 10.0;
int numErrors = 0;
if(nan > nan != FALSE) {
log("WARNING: NaN > NaN returned TRUE, should be FALSE").logln();
@ -385,14 +384,14 @@ IEEETest::NaNGT(void)
//==============================
int
int
IEEETest::NaNLT(void)
{
double pinf = uprv_getInfinity();
double ninf = -uprv_getInfinity();
double nan = uprv_getNaN();
double ten = 10.0;
int numErrors = 0;
double pinf = uprv_getInfinity();
double ninf = -uprv_getInfinity();
double nan = uprv_getNaN();
double ten = 10.0;
int numErrors = 0;
if(nan < nan != FALSE) {
log("WARNING: NaN < NaN returned TRUE, should be FALSE").logln();
@ -415,14 +414,14 @@ IEEETest::NaNLT(void)
//==============================
int
int
IEEETest::NaNGTE(void)
{
double pinf = uprv_getInfinity();
double ninf = -uprv_getInfinity();
double nan = uprv_getNaN();
double ten = 10.0;
int numErrors = 0;
double pinf = uprv_getInfinity();
double ninf = -uprv_getInfinity();
double nan = uprv_getNaN();
double ten = 10.0;
int numErrors = 0;
if(nan >= nan != FALSE) {
log("WARNING: NaN >= NaN returned TRUE, should be FALSE").logln();
@ -445,14 +444,14 @@ IEEETest::NaNGTE(void)
//==============================
int
int
IEEETest::NaNLTE(void)
{
double pinf = uprv_getInfinity();
double ninf = -uprv_getInfinity();
double nan = uprv_getNaN();
double ten = 10.0;
int numErrors = 0;
double pinf = uprv_getInfinity();
double ninf = -uprv_getInfinity();
double nan = uprv_getNaN();
double ten = 10.0;
int numErrors = 0;
if(nan <= nan != FALSE) {
log("WARNING: NaN <= NaN returned TRUE, should be FALSE").logln();
@ -475,14 +474,14 @@ IEEETest::NaNLTE(void)
//==============================
int
int
IEEETest::NaNE(void)
{
double pinf = uprv_getInfinity();
double ninf = -uprv_getInfinity();
double nan = uprv_getNaN();
double ten = 10.0;
int numErrors = 0;
double pinf = uprv_getInfinity();
double ninf = -uprv_getInfinity();
double nan = uprv_getNaN();
double ten = 10.0;
int numErrors = 0;
if(nan == nan != FALSE) {
log("WARNING: NaN == NaN returned TRUE, should be FALSE").logln();
@ -505,14 +504,14 @@ IEEETest::NaNE(void)
//==============================
int
int
IEEETest::NaNNE(void)
{
double pinf = uprv_getInfinity();
double ninf = -uprv_getInfinity();
double nan = uprv_getNaN();
double ten = 10.0;
int numErrors = 0;
double pinf = uprv_getInfinity();
double ninf = -uprv_getInfinity();
double nan = uprv_getNaN();
double ten = 10.0;
int numErrors = 0;
if(nan != nan != TRUE) {
log("WARNING: NaN != NaN returned FALSE, should be TRUE").logln();
@ -541,10 +540,10 @@ IEEETest::log(char c)
if(mFlags & kVerboseMode) {
if(mNeedLogIndent) {
for(int j = 0; j < 2 * getTestLevel(); ++j)
cout << ' ';
fputc(' ', stdout);
mNeedLogIndent = FALSE;
}
cout << c;
fputc(c, stdout);
}
return *this;
}
@ -557,10 +556,10 @@ IEEETest::log(const char *s)
if(mFlags & kVerboseMode) {
if(mNeedLogIndent) {
for(int j = 0; j < 2 * getTestLevel(); ++j)
cout << ' ';
fputc(' ', stdout);
mNeedLogIndent = FALSE;
}
cout << s;
fprintf(stdout, "%s", s);
}
return *this;
}
@ -573,10 +572,10 @@ IEEETest::log(int i)
if(mFlags & kVerboseMode) {
if(mNeedLogIndent) {
for(int j = 0; j < 2 * getTestLevel(); ++j)
cout << ' ';
fputc(' ', stdout);
mNeedLogIndent = FALSE;
}
cout << i;
fprintf(stdout, "%d", i);
}
return *this;
}
@ -589,10 +588,10 @@ IEEETest::log(long l)
if(mFlags & kVerboseMode) {
if(mNeedLogIndent) {
for(int j = 0; j < 2 * getTestLevel(); ++j)
cout << ' ';
fputc(' ', stdout);
mNeedLogIndent = FALSE;
}
cout << l;
fprintf(stdout, "%ld", l);
}
return *this;
}
@ -605,10 +604,10 @@ IEEETest::log(double d)
if(mFlags & kVerboseMode) {
if(mNeedLogIndent) {
for(int j = 0; j < 2 * getTestLevel(); ++j)
cout << ' ';
fputc(' ', stdout);
mNeedLogIndent = FALSE;
}
cout << d;
fprintf(stdout, "%g", d);
}
return *this;
}
@ -619,7 +618,7 @@ IEEETest&
IEEETest::logln(void)
{
if(mFlags & kVerboseMode)
cout << endl;
fputc('\n', stdout);
mNeedLogIndent = TRUE;
return *this;
}
@ -631,10 +630,10 @@ IEEETest::err(char c)
{
if(mNeedErrIndent) {
for(int j = 0; j < 2 * getTestLevel(); ++j)
cerr << ' ';
fputc(' ', stderr);
mNeedErrIndent = FALSE;
}
cerr << c;
fputc(c, stderr);
return *this;
}
@ -645,10 +644,10 @@ IEEETest::err(const char *s)
{
if(mNeedErrIndent) {
for(int j = 0; j < 2 * getTestLevel(); ++j)
cerr << ' ';
fputc(' ', stderr);
mNeedErrIndent = FALSE;
}
cerr << s;
fprintf(stderr, "%s", s);
return *this;
}
@ -659,10 +658,10 @@ IEEETest::err(int i)
{
if(mNeedErrIndent) {
for(int j = 0; j < 2 * getTestLevel(); ++j)
cerr << ' ';
fputc(' ', stderr);
mNeedErrIndent = FALSE;
}
cerr << i;
fprintf(stderr, "%d", i);
return *this;
}
@ -673,10 +672,10 @@ IEEETest::err(long l)
{
if(mNeedErrIndent) {
for(int j = 0; j < 2 * getTestLevel(); ++j)
cerr << ' ';
fputc(' ', stderr);
mNeedErrIndent = FALSE;
}
cerr << l;
fprintf(stderr, "%ld", l);
return *this;
}
@ -687,10 +686,10 @@ IEEETest::err(double d)
{
if(mNeedErrIndent) {
for(int j = 0; j < 2 * getTestLevel(); ++j)
cerr << ' ';
fputc(' ', stderr);
mNeedErrIndent = FALSE;
}
cerr << d;
fprintf(stderr, "%g", d);
return *this;
}
@ -699,7 +698,7 @@ IEEETest::err(double d)
IEEETest&
IEEETest::errln(void)
{
cerr << endl;
fputc('\n', stderr);
mNeedErrIndent = TRUE;
return *this;
}

View file

@ -26,7 +26,6 @@
// testing.
// 02/10/98 damiba Added test for compare(UnicodeString&, UnicodeString&, int32_t)
//===============================================================================
#include <iostream.h>
#ifndef COLL_H
#include "unicode/coll.h"

View file

@ -12,7 +12,6 @@
#include "unicode/unistr.h"
#include "unicode/convert.h"
#include "unicode/ucnv_err.h"
#include <iostream.h>
#include "cppcnvt.h"
#include "cstring.h"

View file

@ -15,7 +15,6 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <iostream.h>
#include <assert.h>
#include "unicode/utypes.h"
@ -526,9 +525,6 @@ IntlTest& operator<<(IntlTest& test, const int32_t num)
return test;
}
//inline _CRTIMP ostream& __cdecl endl(ostream& _outs) { return _outs << '\n' << flush; }
//inline ostream& ostream::operator<<(ostream& (__cdecl * _f)(ostream&)) { (*_f)(*this); return *this; }
IntlTest& endl( IntlTest& test )
{
test.logln();
@ -552,7 +548,7 @@ IntlTest::IntlTest()
no_err_msg = FALSE;
quick = FALSE;
leaks = FALSE;
testout = &cout;
testoutfp = stdout;
LL_indentlevel = indentLevel_offset;
}
@ -563,7 +559,7 @@ void IntlTest::setCaller( IntlTest* callingTest )
verbose = caller->verbose;
no_err_msg = caller->no_err_msg;
quick = caller->quick;
testout = caller->testout;
testoutfp = caller->testoutfp;
LL_indentlevel = caller->LL_indentlevel + indentLevel_offset;
}
}
@ -776,7 +772,7 @@ void IntlTest::LL_message( UnicodeString message, bool_t newline )
// stream out the indentation string first if necessary
if(LL_linestart) {
length = indent.extract(0, indent.length(), buffer);
testout->write(buffer, length);
fwrite(buffer, sizeof(*buffer), length, testoutfp);
}
// replace each LineFeed by the indentation string
@ -784,9 +780,8 @@ void IntlTest::LL_message( UnicodeString message, bool_t newline )
// stream out the message
length = message.extract(0, message.length(), buffer);
testout->write(buffer, length);
testout->flush();
fwrite(buffer, sizeof(*buffer), length, testoutfp);
fflush(testoutfp);
// keep the terminating newline as a state for the next call,
// for use with the then active indentation
@ -876,7 +871,8 @@ main(int argc, char* argv[])
if (!all && !name) syntax = TRUE;
if (syntax) {
cout << "### Syntax:\n"
fprintf(stdout,
"### Syntax:\n"
"### IntlTest [-option1 -option2 ...] [testname1 testname2 ...] \n"
"### where options are: verbose (v), all (a), noerrormsg (n), \n"
"### exhaustive (e) and leaks (l). \n"
@ -891,7 +887,7 @@ main(int argc, char* argv[])
"### To run just the Locale test type: intltest utility/LocaleTest \n"
"### \n"
"### A parameter can be specified for a test by appending '@' and the value \n"
"### to the testname. \n\n";
"### to the testname. \n\n");
return 1;
}
@ -901,17 +897,17 @@ main(int argc, char* argv[])
major.setNoErrMsg( no_err_msg );
major.setQuick( quick );
major.setLeaks( leaks );
cout << "-----------------------------------------------" << endl;
cout << " IntlTest Test Suite for " << endl;
cout << " International Classes for Unicode " << endl;
cout << "-----------------------------------------------" << endl;
cout << " Options: " << endl;
cout << " all (a) : " << (all? "On" : "Off") << endl;
cout << " Verbose (v) : " << (verbose? "On" : "Off") << endl;
cout << " No error messages (n) : " << (no_err_msg? "On" : "Off") << endl;
cout << " Exhaustive (e) : " << (!quick? "On" : "Off") << endl;
cout << " Leaks (l) : " << (leaks? "On" : "Off") << endl;
cout << "-----------------------------------------------" << endl << endl;
fprintf(stdout, "-----------------------------------------------\n");
fprintf(stdout, " IntlTest Test Suite for \n");
fprintf(stdout, " International Classes for Unicode \n");
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, "-----------------------------------------------\n");
// initial check for the default converter
UErrorCode errorCode = U_ZERO_ERROR;
@ -920,9 +916,10 @@ main(int argc, char* argv[])
// ok
ucnv_close(cnv);
} else {
cout << "*** Failure! The default converter cannot be opened." << endl <<
"*** Check the ICU_DATA environment variable and " << endl <<
"*** check that the data files are present." << endl;
fprintf(stdout,
"*** Failure! The default converter cannot be opened.\n"
"*** Check the ICU_DATA environment variable and\n"
"*** check that the data files are present.\n");
return 1;
}
@ -932,9 +929,10 @@ main(int argc, char* argv[])
// ok
ucnv_close(cnv);
} else {
cout << "*** Failure! The converter for iso-8859-7 cannot be opened." << endl <<
"*** Check the ICU_DATA environment variable and " << endl <<
"*** check that the data files are present." << endl;
fprintf(stdout,
"*** Failure! The converter for iso-8859-7 cannot be opened.\n"
"*** Check the ICU_DATA environment variable and \n"
"*** check that the data files are present.\n");
return 1;
}
@ -943,9 +941,10 @@ main(int argc, char* argv[])
// ok
ures_close(rb);
} else {
cout << "*** Failure! The \"en\" locale resource bundle cannot be opened." << endl <<
"*** Check the ICU_DATA environment variable and " << endl <<
"*** check that the data files are present." << endl;
fprintf(stdout,
"*** Failure! The \"en\" locale resource bundle cannot be opened.\n"
"*** Check the ICU_DATA environment variable and \n"
"*** check that the data files are present.\n");
return 1;
}
@ -958,7 +957,7 @@ main(int argc, char* argv[])
for (int i = 1; i < argc; ++i) {
if (argv[i][0] != '-') {
char* name = argv[i];
cout << "\n=== Handling test: " << name << ": ===\n";
fprintf(stdout, "\n=== Handling test: %s: ===\n", name);
char* parameter = strchr( name, '@' );
if (parameter) {
*parameter = 0;
@ -970,23 +969,23 @@ main(int argc, char* argv[])
major.run_phase2( name, parameter );
}
if (!res || (execCount <= 0)) {
cout << "\n---ERROR: Test doesn't exist: " << name << " !\n";
fprintf(stdout, "\n---ERROR: Test doesn't exist: %s!\n", name);
all_tests_exist = FALSE;
}
}
}
}
cout << "\n--------------------------------------\n";
fprintf(stdout, "\n--------------------------------------\n");
if (major.getErrors() == 0) {
cout << "OK: All tests passed without error.\n";
fprintf(stdout, "OK: All tests passed without error.\n");
}else{
cout << "Errors in total: " << major.getErrors() << ".\n";
fprintf(stdout, "Errors in total: %ld.\n", major.getErrors());
}
cout << "--------------------------------------\n";
fprintf(stdout, "--------------------------------------\n");
if (execCount <= 0) {
cout << "***** Not all called tests actually exist! *****\n";
fprintf(stdout, "***** Not all called tests actually exist! *****\n");
}
return major.getErrors();
@ -1031,3 +1030,13 @@ UnicodeString CharsToUnicodeString(const char* chars)
}
return result;
}
/*
* Hey, Emacs, please set the following:
*
* Local Variables:
* indent-tabs-mode: nil
* End:
*
*/

View file

@ -11,14 +11,14 @@
#ifndef _INTLTEST
#define _INTLTEST
#include <stdio.h>
#include "unicode/utypes.h"
#include "unicode/unistr.h"
#include "unicode/coll.h"
#include "unicode/sortkey.h"
#include "unicode/fmtable.h" // liu
#include <iostream.h>
#ifdef OS390
// avoid collision with math.h/log()
// this must be after including utypes.h so that OS390 is actually defined
@ -88,7 +88,7 @@ public:
virtual void usage( void ) ;
ostream* testout;
FILE *testoutfp;
protected:
virtual void runIndexedTest( int32_t index, bool_t exec, char* &name, char* par = NULL ); // overide !

View file

@ -16,9 +16,6 @@
// Date Name Description
//
//===============================================================================
#ifndef _IOSTREAM
#include <iostream.h>
#endif
#define generate_source 1
#if generate_source

View file

@ -177,7 +177,6 @@ void ParsePositionTest::TestFieldPosition_example()
tempLen : (tempLen - pos.getEndIndex());
for (int j=0; j<tempOffset; j++)
temp += UnicodeString("="/*'='*/); // initialize
//cout << temp << fmtText << endl;
logln("FP " + temp + res);
}

View file

@ -101,7 +101,6 @@ void test_FieldPosition_example( void )
UTextOffset tempOffset = (tempLen <= (tempLen - pos.getEndIndex())) ?
tempLen : (tempLen - pos.getEndIndex());
temp[tempOffset] = '\0';
//cout << temp << fmtText << endl;
it_out << "FP " << temp << res << endl;
}
delete fmt;

View file

@ -201,7 +201,6 @@ ostream& operator<<(ostream& stream, const Formattable& obj);
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <iostream.h>
IntlTest&
operator<<( IntlTest& stream,

View file

@ -10,7 +10,6 @@
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <iostream.h>
UnicodeTest::UnicodeTest()
{