diff options
| author | Baptiste Lepilleur <gaiacrtn@free.fr> | 2004-06-25 09:41:28 +0000 |
|---|---|---|
| committer | Baptiste Lepilleur <gaiacrtn@free.fr> | 2004-06-25 09:41:28 +0000 |
| commit | 212df8f138166ed053d63d6d54e1a1290e395ae5 (patch) | |
| tree | cadc9e6eaca1d184b7a69a8b389214d966c4ffb6 /src/cppunit | |
| parent | d9353259d7f48a5497e72a257f2a549ba719bc0c (diff) | |
| download | cppunit-212df8f138166ed053d63d6d54e1a1290e395ae5.tar.gz | |
Include/cppunit/Portability.
include/cppunit/Portability.h: moved OStringStream alias definition to
Portability/Stream.h. User need to define EVC4 to indicate that
config-evc4.h should be used. (how to we detect this automatically ?).
Notes that this means it might be needed to add #include <string> to some
headers since its no longer included by Portability.h.
* include/cppunit/Portability/Stream.h: define alias OStringStream, stdCOut(),
and OFileStream. If CPPUNIT_NO_STREAM is defined (evc4 config), then provides
our own implementation (based on sprintf and fwrite).
* include/cppunit/config/config-evc4.h: config file for embedded visual c++ 4.
Still need to detect for this platform in Portability.h (currently relying on
EVC4 being defined...)
* *.[cpp/h]: most source files have been impacted with the following change:
#include <iostream> -> #include <cppunit/Portability/Stream.h>
std::ostream -> CPPUNIT_NS::OStream
std::ofstream -> CPPUNIT_NS::OFileStream
std::cout -> CPPUNIT_NS::stdCOut()
std::endl -> "\n"
Also, code using std::cin as been defined out if CPPUNIT_NO_STREAM was defined.
The exact list of impact files can be obtain in CVS using tags:
TG_CPPUNIT_NO_STREAM_BEFORE & TG_CPPUNIT_NO_STREAM_AFTER.
Diffstat (limited to 'src/cppunit')
| -rw-r--r-- | src/cppunit/BriefTestProgressListener.cpp | 12 | ||||
| -rw-r--r-- | src/cppunit/CompilerOutputter.cpp | 20 | ||||
| -rw-r--r-- | src/cppunit/StringTools.cpp | 1 | ||||
| -rw-r--r-- | src/cppunit/TextOutputter.cpp | 25 | ||||
| -rw-r--r-- | src/cppunit/TextTestProgressListener.cpp | 10 | ||||
| -rw-r--r-- | src/cppunit/TextTestResult.cpp | 12 | ||||
| -rw-r--r-- | src/cppunit/TextTestRunner.cpp | 11 | ||||
| -rw-r--r-- | src/cppunit/XmlOutputter.cpp | 2 | ||||
| -rw-r--r-- | src/cppunit/cppunit.dsp | 8 |
9 files changed, 55 insertions, 46 deletions
diff --git a/src/cppunit/BriefTestProgressListener.cpp b/src/cppunit/BriefTestProgressListener.cpp index 953f659..639d622 100644 --- a/src/cppunit/BriefTestProgressListener.cpp +++ b/src/cppunit/BriefTestProgressListener.cpp @@ -1,7 +1,7 @@ #include <cppunit/BriefTestProgressListener.h> #include <cppunit/Test.h> #include <cppunit/TestFailure.h> -#include <iostream> +#include <cppunit/Portability/Stream.h> CPPUNIT_NS_BEGIN @@ -21,8 +21,8 @@ BriefTestProgressListener::~BriefTestProgressListener() void BriefTestProgressListener::startTest( Test *test ) { - std::cerr << test->getName(); - std::cerr.flush(); + stdCOut() << test->getName(); + stdCOut().flush(); m_lastTestFailed = false; } @@ -31,7 +31,7 @@ BriefTestProgressListener::startTest( Test *test ) void BriefTestProgressListener::addFailure( const TestFailure &failure ) { - std::cerr << " : " << (failure.isError() ? "error" : "assertion"); + stdCOut() << " : " << (failure.isError() ? "error" : "assertion"); m_lastTestFailed = true; } @@ -40,8 +40,8 @@ void BriefTestProgressListener::endTest( Test *test ) { if ( !m_lastTestFailed ) - std::cerr << " : OK"; - std::cerr << std::endl; + stdCOut() << " : OK"; + stdCOut() << "\n"; } diff --git a/src/cppunit/CompilerOutputter.cpp b/src/cppunit/CompilerOutputter.cpp index 790481a..ab0f4bb 100644 --- a/src/cppunit/CompilerOutputter.cpp +++ b/src/cppunit/CompilerOutputter.cpp @@ -11,7 +11,7 @@ CPPUNIT_NS_BEGIN CompilerOutputter::CompilerOutputter( TestResultCollector *result, - std::ostream &stream, + OStream &stream, const std::string &locationFormat ) : m_result( result ) , m_stream( stream ) @@ -35,7 +35,7 @@ CompilerOutputter::setLocationFormat( const std::string &locationFormat ) CompilerOutputter * CompilerOutputter::defaultOutputter( TestResultCollector *result, - std::ostream &stream ) + OStream &stream ) { return new CompilerOutputter( result, stream ); } @@ -54,8 +54,7 @@ CompilerOutputter::write() void CompilerOutputter::printSuccess() { - m_stream << "OK (" << m_result->runTests() << ")" - << std::endl; + m_stream << "OK (" << m_result->runTests() << ")\n"; } @@ -161,35 +160,34 @@ CompilerOutputter::printFailureType( TestFailure *failure ) void CompilerOutputter::printFailedTestName( TestFailure *failure ) { - m_stream << std::endl; - m_stream << "Test name: " << failure->failedTestName(); + m_stream << "\nTest name: " << failure->failedTestName(); } void CompilerOutputter::printFailureMessage( TestFailure *failure ) { - m_stream << std::endl; + m_stream << "\n"; Exception *thrownException = failure->thrownException(); - m_stream << thrownException->message().shortDescription() << std::endl; + m_stream << thrownException->message().shortDescription() << "\n"; std::string message = thrownException->message().details(); if ( m_wrapColumn > 0 ) message = StringTools::wrap( message, m_wrapColumn ); - m_stream << message << std::endl; + m_stream << message << "\n"; } void CompilerOutputter::printStatistics() { - m_stream << "Failures !!!" << std::endl; + m_stream << "Failures !!!\n"; m_stream << "Run: " << m_result->runTests() << " " << "Failure total: " << m_result->testFailuresTotal() << " " << "Failures: " << m_result->testFailures() << " " << "Errors: " << m_result->testErrors() - << std::endl; + << "\n"; } diff --git a/src/cppunit/StringTools.cpp b/src/cppunit/StringTools.cpp index 2f77d24..130543c 100644 --- a/src/cppunit/StringTools.cpp +++ b/src/cppunit/StringTools.cpp @@ -1,4 +1,5 @@ #include <cppunit/tools/StringTools.h> +#include <cppunit/Portability/Stream.h> #include <algorithm> diff --git a/src/cppunit/TextOutputter.cpp b/src/cppunit/TextOutputter.cpp index 6dd54e5..f74214f 100644 --- a/src/cppunit/TextOutputter.cpp +++ b/src/cppunit/TextOutputter.cpp @@ -9,7 +9,7 @@ CPPUNIT_NS_BEGIN TextOutputter::TextOutputter( TestResultCollector *result, - std::ostream &stream ) + OStream &stream ) : m_result( result ) , m_stream( stream ) { @@ -25,9 +25,9 @@ void TextOutputter::write() { printHeader(); - m_stream << std::endl; + m_stream << "\n"; printFailures(); - m_stream << std::endl; + m_stream << "\n"; } @@ -38,7 +38,7 @@ TextOutputter::printFailures() int failureNumber = 1; while ( itFailure != m_result->failures().end() ) { - m_stream << std::endl; + m_stream << "\n"; printFailure( *itFailure++, failureNumber++ ); } } @@ -55,9 +55,9 @@ TextOutputter::printFailure( TestFailure *failure, printFailureType( failure ); m_stream << ' '; printFailureLocation( failure->sourceLine() ); - m_stream << std::endl; + m_stream << "\n"; printFailureDetail( failure->thrownException() ); - m_stream << std::endl; + m_stream << "\n"; } @@ -98,7 +98,7 @@ TextOutputter::printFailureLocation( SourceLine sourceLine ) void TextOutputter::printFailureDetail( Exception *thrownException ) { - m_stream << thrownException->message().shortDescription() << std::endl; + m_stream << thrownException->message().shortDescription() << "\n"; m_stream << thrownException->message().details(); } @@ -107,11 +107,10 @@ void TextOutputter::printHeader() { if ( m_result->wasSuccessful() ) - m_stream << std::endl << "OK (" << m_result->runTests () << " tests)" - << std::endl; + m_stream << "\nOK (" << m_result->runTests () << " tests)\n" ; else { - m_stream << std::endl; + m_stream << "\n"; printFailureWarning(); printStatistics(); } @@ -121,19 +120,19 @@ TextOutputter::printHeader() void TextOutputter::printFailureWarning() { - m_stream << "!!!FAILURES!!!" << std::endl; + m_stream << "!!!FAILURES!!!\n"; } void TextOutputter::printStatistics() { - m_stream << "Test Results:" << std::endl; + m_stream << "Test Results:\n"; m_stream << "Run: " << m_result->runTests() << " Failures: " << m_result->testFailures() << " Errors: " << m_result->testErrors() - << std::endl; + << "\n"; } diff --git a/src/cppunit/TextTestProgressListener.cpp b/src/cppunit/TextTestProgressListener.cpp index cb0a833..55aca05 100644 --- a/src/cppunit/TextTestProgressListener.cpp +++ b/src/cppunit/TextTestProgressListener.cpp @@ -1,6 +1,6 @@ #include <cppunit/TestFailure.h> #include <cppunit/TextTestProgressListener.h> -#include <iostream> +#include <cppunit/Portability/Stream.h> CPPUNIT_NS_BEGIN @@ -19,14 +19,14 @@ TextTestProgressListener::~TextTestProgressListener() void TextTestProgressListener::startTest( Test *test ) { - std::cerr << "."; + stdCOut() << "."; } void TextTestProgressListener::addFailure( const TestFailure &failure ) { - std::cerr << ( failure.isError() ? "E" : "F" ); + stdCOut() << ( failure.isError() ? "E" : "F" ); } @@ -34,8 +34,8 @@ void TextTestProgressListener::endTestRun( Test *test, TestResult *eventManager ) { - std::cerr << std::endl; - std::cerr.flush(); + stdCOut() << "\n"; + stdCOut().flush(); } diff --git a/src/cppunit/TextTestResult.cpp b/src/cppunit/TextTestResult.cpp index c155745..b498af8 100644 --- a/src/cppunit/TextTestResult.cpp +++ b/src/cppunit/TextTestResult.cpp @@ -3,7 +3,7 @@ #include <cppunit/TestFailure.h> #include <cppunit/TextTestResult.h> #include <cppunit/TextOutputter.h> -#include <iostream> +#include <cppunit/Portability/Stream.h> CPPUNIT_NS_BEGIN @@ -19,7 +19,7 @@ void TextTestResult::addFailure( const TestFailure &failure ) { TestResultCollector::addFailure( failure ); - std::cerr << ( failure.isError() ? "E" : "F" ); + stdCOut() << ( failure.isError() ? "E" : "F" ); } @@ -27,20 +27,20 @@ void TextTestResult::startTest( Test *test ) { TestResultCollector::startTest (test); - std::cerr << "."; + stdCOut() << "."; } void -TextTestResult::print( std::ostream& stream ) +TextTestResult::print( OStream &stream ) { TextOutputter outputter( this, stream ); outputter.write(); } -std::ostream & -operator <<( std::ostream &stream, +OStream & +operator <<( OStream &stream, TextTestResult &result ) { result.print (stream); return stream; diff --git a/src/cppunit/TextTestRunner.cpp b/src/cppunit/TextTestRunner.cpp index 5ca182b..e8087bf 100644 --- a/src/cppunit/TextTestRunner.cpp +++ b/src/cppunit/TextTestRunner.cpp @@ -6,7 +6,7 @@ #include <cppunit/TextTestProgressListener.h> #include <cppunit/TestResult.h> #include <cppunit/ui/text/TextTestRunner.h> -#include <iostream> +#include <cppunit/Portability/Stream.h> #include <stdexcept> @@ -22,7 +22,7 @@ TextTestRunner::TextTestRunner( Outputter *outputter ) , m_eventManager( new TestResult() ) { if ( !m_outputter ) - m_outputter = new TextOutputter( m_result, std::cout ); + m_outputter = new TextOutputter( m_result, stdCOut() ); m_eventManager->addListener( m_result ); } @@ -75,18 +75,21 @@ TextTestRunner::run( std::string testName, void TextTestRunner::wait( bool doWait ) { +#if !defined( CPPUNIT_NO_STREAM ) if ( doWait ) { - std::cout << "<RETURN> to continue" << std::endl; + stdCOut() << "<RETURN> to continue\n"; + stdCOut().flush(); std::cin.get (); } +#endif } void TextTestRunner::printResult( bool doPrintResult ) { - std::cout << std::endl; + stdCOut() << "\n"; if ( doPrintResult ) m_outputter->write(); } diff --git a/src/cppunit/XmlOutputter.cpp b/src/cppunit/XmlOutputter.cpp index 8453424..cc9f175 100644 --- a/src/cppunit/XmlOutputter.cpp +++ b/src/cppunit/XmlOutputter.cpp @@ -14,7 +14,7 @@ CPPUNIT_NS_BEGIN XmlOutputter::XmlOutputter( TestResultCollector *result, - std::ostream &stream, + OStream &stream, std::string encoding ) : m_result( result ) , m_stream( stream ) diff --git a/src/cppunit/cppunit.dsp b/src/cppunit/cppunit.dsp index 7ac7e1c..de14e05 100644 --- a/src/cppunit/cppunit.dsp +++ b/src/cppunit/cppunit.dsp @@ -211,6 +211,10 @@ SOURCE="..\..\include\cppunit\config\config-bcb5.h" # End Source File # Begin Source File +SOURCE="..\..\include\cppunit\config\config-evc4.h" +# End Source File +# Begin Source File + SOURCE="..\..\include\cppunit\config\config-mac.h" # End Source File # Begin Source File @@ -249,6 +253,10 @@ SOURCE=..\..\include\cppunit\Portability.h SOURCE=..\..\include\cppunit\config\SelectDllLoader.h # End Source File +# Begin Source File + +SOURCE=..\..\include\cppunit\portability\Stream.h +# End Source File # End Group # Begin Group "output" |
