Changes to make the CPPUnit build on PPC (with mwcc *shudder*).

Courtesy of Oliver Tappe.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@6616 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold
2004-02-17 19:57:58 +00:00
parent 69cb3c1013
commit aa94570a34
54 changed files with 390 additions and 367 deletions
+1 -1
View File
@@ -4,7 +4,7 @@
#include <stdio.h>
#include <stdarg.h>
BTestCase::BTestCase(std::string name)
BTestCase::BTestCase(string name)
: CppUnit::TestCase(name)
, fValidCWD(false)
, fSubTestNum(0)
+8 -8
View File
@@ -1,3 +1,4 @@
#include <iostream>
#include <map>
#include <set>
#include <string>
@@ -20,13 +21,12 @@
#include <TestShell.h>
#include <TestListener.h>
#include <ElfSymbolPatcher.h>
BTestShell *BTestShell::fGlobalShell = NULL;
const char BTestShell::indent[] = " ";
BTestShell::BTestShell(const std::string &description, SyncObject *syncObject)
BTestShell::BTestShell(const string &description, SyncObject *syncObject)
: fVerbosityLevel(v2)
, fTestResults(syncObject)
, fDescription(description)
@@ -72,7 +72,7 @@ BTestShell::AddSuite(BTestSuite *suite) {
}
void
BTestShell::AddTest(const std::string &name, CppUnit::Test *test) {
BTestShell::AddTest(const string &name, CppUnit::Test *test) {
if (test != NULL)
fTests[name] = test;
else
@@ -153,8 +153,8 @@ BTestShell::Run(int argc, char *argv[]) {
suite.addTest( i->second );
} else {
std::set<std::string>::const_iterator i;
std::set<std::string> suitesToRemove;
set<string>::const_iterator i;
set<string> suitesToRemove;
// Add all the tests from any specified suites to the list of
// tests to run (since we use a set, this eliminates the concern
@@ -312,7 +312,7 @@ BTestShell::ProcessArguments(int argc, char *argv[]) {
// Handle each command line argument (skipping the first
// which is just the app name)
for (int i = 1; i < argc; i++) {
std::string str(argv[i]);
string str(argv[i]);
if (!ProcessArgument(str, argc, argv))
return false;
@@ -322,7 +322,7 @@ BTestShell::ProcessArguments(int argc, char *argv[]) {
}
bool
BTestShell::ProcessArgument(std::string arg, int argc, char *argv[]) {
BTestShell::ProcessArgument(string arg, int argc, char *argv[]) {
if (arg == "--help") {
PrintDescription(argc, argv);
PrintHelp();
@@ -419,7 +419,7 @@ BTestShell::LoadDynamicSuites() {
cout << "------------------------------------------------------------------------------" << endl;
}
std::set<std::string>::iterator i;
set<string>::iterator i;
for (i = fLibDirs.begin(); i != fLibDirs.end(); i++) {
BDirectory libDir((*i).c_str());
if (Verbosity() >= v3)
+8 -8
View File
@@ -3,7 +3,7 @@
#include <cppunit/TestResult.h>
// Default constructor
BTestSuite::BTestSuite( std::string name )
BTestSuite::BTestSuite( string name )
: fName(name)
{
}
@@ -17,7 +17,7 @@ BTestSuite::~BTestSuite() {
// Deletes all tests in the suite.
void
BTestSuite::deleteContents() {
for ( std::map<std::string, CppUnit::Test*>::iterator it = fTests.begin();
for ( map<string, CppUnit::Test*>::iterator it = fTests.begin();
it != fTests.end();
++it)
delete it->second;
@@ -28,7 +28,7 @@ BTestSuite::deleteContents() {
/// Runs the tests and collects their result in a TestResult.
void
BTestSuite::run( CppUnit::TestResult *result ) {
for ( std::map<std::string, CppUnit::Test*>::iterator it = fTests.begin();
for ( map<string, CppUnit::Test*>::iterator it = fTests.begin();
it != fTests.end();
++it )
{
@@ -46,7 +46,7 @@ int
BTestSuite::countTestCases() const {
int count = 0;
for ( std::map<std::string, CppUnit::Test *>::const_iterator it = fTests.begin();
for ( map<string, CppUnit::Test *>::const_iterator it = fTests.begin();
it != fTests.end();
++it )
count += it->second->countTestCases();
@@ -57,26 +57,26 @@ BTestSuite::countTestCases() const {
// Adds a test to the suite.
void
BTestSuite::addTest(std::string name, CppUnit::Test *test) {
BTestSuite::addTest(string name, CppUnit::Test *test) {
fTests[name] = test;
}
// Returns a string representation of the test suite.
std::string
string
BTestSuite::toString() const {
return "suite " + getName();
}
// Returns the name of the test suite.
std::string
string
BTestSuite::getName() const {
return fName;
}
const std::map<std::string, CppUnit::Test*> &
const map<string, CppUnit::Test*> &
BTestSuite::getTests() const {
return fTests;
}
+4 -3
View File
@@ -3,12 +3,13 @@
#include <TestUtils.h>
#include <TestShell.h>
#include <stdio.h>
#include <iostream>
status_t DecodeResult(status_t result) {
if (!BTestShell::GlobalBeVerbose())
return result;
std::string str;
string str;
switch (result) {
case B_OK:
@@ -177,10 +178,10 @@ status_t DecodeResult(status_t result) {
return result;
}
std::string IntToStr(int i) {
string IntToStr(int i) {
char num[32];
sprintf(num, "%d", i);
return std::string(num);
return string(num);
}
void ExecCommand(const char *command) {
+8 -8
View File
@@ -3,7 +3,7 @@
#include <Autolock.h>
#include <stdio.h>
BThreadedTestCase::BThreadedTestCase(std::string name, std::string progressSeparator)
BThreadedTestCase::BThreadedTestCase(string name, string progressSeparator)
: BTestCase(name)
, fProgressSeparator(progressSeparator)
, fUpdateLock(new BLocker())
@@ -15,7 +15,7 @@ BThreadedTestCase::~BThreadedTestCase() {
delete fUpdateLock;
// Clean up
for (std::map<thread_id, ThreadSubTestInfo*>::iterator i = fNumberMap.begin();
for (map<thread_id, ThreadSubTestInfo*>::iterator i = fNumberMap.begin();
i != fNumberMap.end();
i++)
{
@@ -31,13 +31,13 @@ BThreadedTestCase::NextSubTest() {
{
// Acquire the update lock
BAutolock lock(fUpdateLock);
std::map<thread_id, ThreadSubTestInfo*>::iterator i = fNumberMap.find(id);
map<thread_id, ThreadSubTestInfo*>::iterator i = fNumberMap.find(id);
if (i != fNumberMap.end() && i->second) {
// Handle multi-threaded case
ThreadSubTestInfo *info = i->second;
char num[32];
sprintf(num, "%ld", info->subTestNum++);
std::string str = std::string("[") + info->name + fProgressSeparator + num + "]";
string str = string("[") + info->name + fProgressSeparator + num + "]";
fUpdateList.push_back(str);
return;
}
@@ -72,16 +72,16 @@ BThreadedTestCase::Outputf(const char *str, ...) {
{
// Acquire the update lock and post our update
BAutolock lock(fUpdateLock);
fUpdateList.push_back(std::string(msg));
fUpdateList.push_back(string(msg));
}
}
}
}
void
BThreadedTestCase::InitThreadInfo(thread_id id, std::string threadName) {
BThreadedTestCase::InitThreadInfo(thread_id id, string threadName) {
BAutolock lock(fUpdateLock); // Lock the number map
std::map<thread_id, ThreadSubTestInfo*>::iterator i = fNumberMap.find(id);
map<thread_id, ThreadSubTestInfo*>::iterator i = fNumberMap.find(id);
if (i != fNumberMap.end() && i->second) {
i->second->name = threadName;
i->second->subTestNum = 0;
@@ -108,7 +108,7 @@ BThreadedTestCase::UnregisterForUse() {
fInUse = false;
}
std::vector<std::string>&
vector<string>&
BThreadedTestCase::AcquireUpdateList() {
fUpdateLock->Lock();
return fUpdateList;
+8 -8
View File
@@ -11,7 +11,7 @@ namespace Asserter
void
fail( std::string message,
fail( string message,
SourceLine sourceLine )
{
throw Exception( message, sourceLine );
@@ -20,7 +20,7 @@ fail( std::string message,
void
failIf( bool shouldFail,
std::string message,
string message,
SourceLine location )
{
if ( shouldFail )
@@ -29,10 +29,10 @@ failIf( bool shouldFail,
void
failNotEqual( std::string expected,
std::string actual,
failNotEqual( string expected,
string actual,
SourceLine sourceLine,
std::string additionalMessage )
string additionalMessage )
{
throw NotEqualException( expected,
actual,
@@ -43,10 +43,10 @@ failNotEqual( std::string expected,
void
failNotEqualIf( bool shouldFail,
std::string expected,
std::string actual,
string expected,
string actual,
SourceLine sourceLine,
std::string additionalMessage )
string additionalMessage )
{
if ( shouldFail )
failNotEqual( expected, actual, sourceLine, additionalMessage );
+21 -21
View File
@@ -10,7 +10,7 @@ namespace CppUnit
{
CompilerOutputter::CompilerOutputter( TestResultCollector *result,
std::ostream &stream ) :
ostream &stream ) :
m_result( result ),
m_stream( stream )
{
@@ -24,7 +24,7 @@ CompilerOutputter::~CompilerOutputter()
CompilerOutputter *
CompilerOutputter::defaultOutputter( TestResultCollector *result,
std::ostream &stream )
ostream &stream )
{
return new CompilerOutputter( result, stream );
// For automatic adpatation...
@@ -46,7 +46,7 @@ void
CompilerOutputter::printSucess()
{
m_stream << "OK (" << m_result->runTests() << ")"
<< std::endl;
<< endl;
}
@@ -99,7 +99,7 @@ CompilerOutputter::printFailureType( TestFailure *failure )
void
CompilerOutputter::printFailedTestName( TestFailure *failure )
{
m_stream << std::endl;
m_stream << endl;
m_stream << "Test name: " << failure->failedTestName();
}
@@ -107,13 +107,13 @@ CompilerOutputter::printFailedTestName( TestFailure *failure )
void
CompilerOutputter::printFailureMessage( TestFailure *failure )
{
m_stream << std::endl;
m_stream << endl;
Exception *thrownException = failure->thrownException();
if ( thrownException->isInstanceOf( NotEqualException::type() ) )
printNotEqualMessage( thrownException );
else
printDefaultMessage( thrownException );
m_stream << std::endl;
m_stream << endl;
}
@@ -122,13 +122,13 @@ CompilerOutputter::printNotEqualMessage( Exception *thrownException )
{
NotEqualException *e = (NotEqualException *)thrownException;
m_stream << wrap( "- Expected : " + e->expectedValue() );
m_stream << std::endl;
m_stream << endl;
m_stream << wrap( "- Actual : " + e->actualValue() );
m_stream << std::endl;
m_stream << endl;
if ( !e->additionalMessage().empty() )
{
m_stream << wrap( e->additionalMessage() );
m_stream << std::endl;
m_stream << endl;
}
}
@@ -136,36 +136,36 @@ CompilerOutputter::printNotEqualMessage( Exception *thrownException )
void
CompilerOutputter::printDefaultMessage( Exception *thrownException )
{
std::string wrappedMessage = wrap( thrownException->what() );
m_stream << wrappedMessage << std::endl;
string wrappedMessage = wrap( thrownException->what() );
m_stream << wrappedMessage << endl;
}
void
CompilerOutputter::printStatistics()
{
m_stream << "Failures !!!" << std::endl;
m_stream << "Failures !!!" << endl;
m_stream << "Run: " << m_result->runTests() << " "
<< "Failure total: " << m_result->testFailuresTotal() << " "
<< "Failures: " << m_result->testFailures() << " "
<< "Errors: " << m_result->testErrors()
<< std::endl;
<< endl;
}
std::string
CompilerOutputter::wrap( std::string message )
string
CompilerOutputter::wrap( string message )
{
Lines lines = splitMessageIntoLines( message );
std::string wrapped;
string wrapped;
for ( Lines::iterator it = lines.begin(); it != lines.end(); ++it )
{
std::string line( *it );
string line( *it );
const int maxLineLength = 80;
int index =0;
while ( index < (int)line.length() )
{
std::string line( line.substr( index, maxLineLength ) );
string line( line.substr( index, maxLineLength ) );
wrapped += line;
index += maxLineLength;
if ( index < (int)line.length() )
@@ -178,14 +178,14 @@ CompilerOutputter::wrap( std::string message )
CompilerOutputter::Lines
CompilerOutputter::splitMessageIntoLines( std::string message )
CompilerOutputter::splitMessageIntoLines( string message )
{
Lines lines;
std::string::iterator itStart = message.begin();
string::iterator itStart = message.begin();
while ( true )
{
std::string::iterator itEol = std::find( itStart,
string::iterator itEol = find( itStart,
message.end(),
'\n' );
lines.push_back( message.substr( itStart - message.begin(),
+7 -7
View File
@@ -8,7 +8,7 @@ namespace CppUnit {
/*!
* \deprecated Use SourceLine::isValid() instead.
*/
const std::string Exception::UNKNOWNFILENAME = "<unknown>";
const string Exception::UNKNOWNFILENAME = "<unknown>";
/*!
* \deprecated Use SourceLine::isValid() instead.
@@ -19,7 +19,7 @@ const long Exception::UNKNOWNLINENUMBER = -1;
/// Construct the exception
Exception::Exception( const Exception &other ) :
std::exception( other )
exception( other )
{
m_message = other.m_message;
m_sourceLine = other.m_sourceLine;
@@ -29,7 +29,7 @@ Exception::Exception( const Exception &other ) :
/*!
* \deprecated Use other constructor instead.
*/
Exception::Exception( std::string message,
Exception::Exception( string message,
SourceLine sourceLine ) :
m_message( message ),
m_sourceLine( sourceLine )
@@ -41,9 +41,9 @@ Exception::Exception( std::string message,
/*!
* \deprecated Use other constructor instead.
*/
Exception::Exception( std::string message,
Exception::Exception( string message,
long lineNumber,
std::string fileName ) :
string fileName ) :
m_message( message ),
m_sourceLine( fileName, lineNumber )
{
@@ -63,7 +63,7 @@ Exception::operator =( const Exception& other )
{
// Don't call superclass operator =(). VC++ STL implementation
// has a bug. It calls the destructor and copy constructor of
// std::exception() which reset the virtual table to std::exception.
// exception() which reset the virtual table to exception.
// SuperClass::operator =(other);
if ( &other != this )
@@ -102,7 +102,7 @@ Exception::lineNumber() const
/// The file in which the error occurred
std::string
string
Exception::fileName() const
{
return m_sourceLine.isValid() ? m_sourceLine.fileName() :
@@ -3,10 +3,10 @@
namespace CppUnit {
NotEqualException::NotEqualException( std::string expected,
std::string actual,
NotEqualException::NotEqualException( string expected,
string actual,
SourceLine sourceLine ,
std::string additionalMessage ) :
string additionalMessage ) :
Exception( "Expected: " + expected +
", but was: " + actual +
"." + additionalMessage ,
@@ -22,10 +22,10 @@ NotEqualException::NotEqualException( std::string expected,
/*!
* \deprecated Use other constructor instead.
*/
NotEqualException::NotEqualException( std::string expected,
std::string actual,
NotEqualException::NotEqualException( string expected,
string actual,
long lineNumber,
std::string fileName ) :
string fileName ) :
Exception( "Expected: " + expected + ", but was: " + actual,
lineNumber,
fileName ),
@@ -87,21 +87,21 @@ NotEqualException::type()
}
std::string
string
NotEqualException::expectedValue() const
{
return m_expected;
}
std::string
string
NotEqualException::actualValue() const
{
return m_actual;
}
std::string
string
NotEqualException::additionalMessage() const
{
return m_additionalMessage;
+1 -1
View File
@@ -14,7 +14,7 @@ RepeatedTest::countTestCases() const
// Returns the name of the test instance.
std::string
string
RepeatedTest::toString() const
{
return TestDecorator::toString () + " (repeated)";
+2 -2
View File
@@ -10,7 +10,7 @@ SourceLine::SourceLine() :
}
SourceLine::SourceLine( const std::string &fileName,
SourceLine::SourceLine( const string &fileName,
int lineNumber ) :
m_fileName( fileName ),
m_lineNumber( lineNumber )
@@ -37,7 +37,7 @@ SourceLine::lineNumber() const
}
std::string
string
SourceLine::fileName() const
{
return m_fileName;
+6 -6
View File
@@ -15,9 +15,9 @@ namespace CppUnit {
/// Check for a failed general assertion
void
TestAssert::assertImplementation( bool condition,
std::string conditionExpression,
string conditionExpression,
long lineNumber,
std::string fileName )
string fileName )
{
Asserter::failIf( condition,
conditionExpression,
@@ -27,10 +27,10 @@ TestAssert::assertImplementation( bool condition,
/// Reports failed equality
void
TestAssert::assertNotEqualImplementation( std::string expected,
std::string actual,
TestAssert::assertNotEqualImplementation( string expected,
string actual,
long lineNumber,
std::string fileName )
string fileName )
{
Asserter::failNotEqual( expected,
actual,
@@ -44,7 +44,7 @@ TestAssert::assertEquals( double expected,
double actual,
double delta,
long lineNumber,
std::string fileName )
string fileName )
{
if (fabs (expected - actual) > delta)
assertNotEqualImplementation( assertion_traits<double>::toString(expected),
+6 -6
View File
@@ -33,7 +33,7 @@ TestCase::run( TestResult *result )
Exception *copy = e.clone();
result->addFailure( this, copy );
}
catch ( std::exception &e ) {
catch ( exception &e ) {
result->addError( this, new Exception( e.what() ) );
}
catch (...) {
@@ -77,7 +77,7 @@ TestCase::runTest()
/** Constructs a test case.
* \param name the name of the TestCase.
**/
TestCase::TestCase( std::string name )
TestCase::TestCase( string name )
: m_name(name)
{
}
@@ -108,7 +108,7 @@ TestCase::countTestCases() const
/// Returns the name of the test case
std::string
string
TestCase::getName() const
{
return m_name;
@@ -116,13 +116,13 @@ TestCase::getName() const
/// Returns the name of the test case instance
std::string
string
TestCase::toString() const
{
std::string className;
string className;
#if CPPUNIT_USE_TYPEINFO_NAME
const std::type_info& thisClass = typeid( *this );
const type_info& thisClass = typeid( *this );
className = thisClass.name();
#else
className = "TestCase";
@@ -1,6 +1,7 @@
#include <cppunit/extensions/TestFactoryRegistry.h>
#include <cppunit/TestSuite.h>
#include <set>
#include <string>
#if CPPUNIT_USE_TYPEINFO_NAME
@@ -26,17 +27,17 @@ public:
static NamedRegistries &getInstance();
TestFactoryRegistry &getRegistry( std::string name );
TestFactoryRegistry &getRegistry( string name );
void wasDestroyed( TestFactory *factory );
bool needDestroy( TestFactory *factory );
private:
typedef std::map<std::string, TestFactoryRegistry *> Registries;
typedef map<string, TestFactoryRegistry *> Registries;
Registries m_registries;
typedef std::set<TestFactory *> Factories;
typedef set<TestFactory *> Factories;
Factories m_factoriesToDestroy;
Factories m_destroyedFactories;
};
@@ -63,13 +64,24 @@ NamedRegistries::getInstance()
TestFactoryRegistry &
NamedRegistries::getRegistry( std::string name )
NamedRegistries::getRegistry( string name )
{
Registries::const_iterator foundIt = m_registries.find( name );
if ( foundIt == m_registries.end() )
{
TestFactoryRegistry *factory = new TestFactoryRegistry( name );
#if defined(__POWERPC__) && defined(__BEOS__)
m_registries.insert(
pair<
const basic_string< char, char_traits< char>, allocator<char> >,
CppUnit::TestFactoryRegistry*
>(
name, factory
)
);
#else
m_registries.insert( std::make_pair( name, factory ) );
#endif
m_factoriesToDestroy.insert( factory );
return *factory;
}
@@ -93,7 +105,7 @@ NamedRegistries::needDestroy( TestFactory *factory )
TestFactoryRegistry::TestFactoryRegistry( std::string name ) :
TestFactoryRegistry::TestFactoryRegistry( string name ) :
m_name( name )
{
}
@@ -125,14 +137,14 @@ TestFactoryRegistry::getRegistry()
TestFactoryRegistry &
TestFactoryRegistry::getRegistry( const std::string &name )
TestFactoryRegistry::getRegistry( const string &name )
{
return NamedRegistries::getInstance().getRegistry( name );
}
void
TestFactoryRegistry::registerFactory( const std::string &name,
TestFactoryRegistry::registerFactory( const string &name,
TestFactory *factory )
{
m_factories[name] = factory;
+2 -2
View File
@@ -53,7 +53,7 @@ TestFailure::isError() const
/// Gets the name of the failed test.
std::string
string
TestFailure::failedTestName() const
{
return m_failedTest->getName();
@@ -61,7 +61,7 @@ TestFailure::failedTestName() const
/// Returns a short description of the failure.
std::string
string
TestFailure::toString() const
{
return m_failedTest->toString() + ": " + m_thrownException->what();
+1 -1
View File
@@ -120,7 +120,7 @@ void
TestResult::removeListener ( TestListener *listener )
{
ExclusiveZone zone( m_syncObject );
m_listeners.erase( std::remove( m_listeners.begin(),
m_listeners.erase( remove( m_listeners.begin(),
m_listeners.end(),
listener ),
m_listeners.end());
+9 -9
View File
@@ -20,7 +20,7 @@ TestRunner::TestRunner( Outputter *outputter )
, m_outputter( outputter )
{
if ( !m_outputter )
m_outputter = new TextOutputter( m_result, std::cout );
m_outputter = new TextOutputter( m_result, cout );
m_eventManager->addListener( m_result );
}
@@ -61,7 +61,7 @@ TestRunner::addTest( Test *test )
* failed or was not found.
*/
bool
TestRunner::run( std::string testName,
TestRunner::run( string testName,
bool doWait,
bool doPrintResult,
bool doPrintProgress )
@@ -74,7 +74,7 @@ TestRunner::run( std::string testName,
bool
TestRunner::runTestByName( std::string testName,
TestRunner::runTestByName( string testName,
bool doPrintProgress )
{
if ( testName.empty() )
@@ -84,7 +84,7 @@ TestRunner::runTestByName( std::string testName,
if ( test != NULL )
return runTest( test, doPrintProgress );
std::cout << "Test " << testName << " not found." << std::endl;
cout << "Test " << testName << " not found." << endl;
return false;
}
@@ -94,8 +94,8 @@ TestRunner::wait( bool doWait )
{
if ( doWait )
{
std::cout << "<RETURN> to continue" << std::endl;
std::cin.get ();
cout << "<RETURN> to continue" << endl;
cin.get ();
}
}
@@ -103,16 +103,16 @@ TestRunner::wait( bool doWait )
void
TestRunner::printResult( bool doPrintResult )
{
std::cout << std::endl;
cout << endl;
if ( doPrintResult )
m_outputter->write();
}
Test *
TestRunner::findTestByName( std::string name ) const
TestRunner::findTestByName( string name ) const
{
for ( std::vector<Test *>::const_iterator it = m_suite->getTests().begin();
for ( vector<Test *>::const_iterator it = m_suite->getTests().begin();
it != m_suite->getTests().end();
++it )
{
+7 -7
View File
@@ -4,7 +4,7 @@
namespace CppUnit {
/// Default constructor
TestSuite::TestSuite( std::string name )
TestSuite::TestSuite( string name )
: m_name( name )
{
}
@@ -21,7 +21,7 @@ TestSuite::~TestSuite()
void
TestSuite::deleteContents()
{
for ( std::vector<Test *>::iterator it = m_tests.begin();
for ( vector<Test *>::iterator it = m_tests.begin();
it != m_tests.end();
++it)
delete *it;
@@ -33,7 +33,7 @@ TestSuite::deleteContents()
void
TestSuite::run( TestResult *result )
{
for ( std::vector<Test *>::iterator it = m_tests.begin();
for ( vector<Test *>::iterator it = m_tests.begin();
it != m_tests.end();
++it )
{
@@ -52,7 +52,7 @@ TestSuite::countTestCases() const
{
int count = 0;
for ( std::vector<Test *>::const_iterator it = m_tests.begin();
for ( vector<Test *>::const_iterator it = m_tests.begin();
it != m_tests.end();
++it )
count += (*it)->countTestCases();
@@ -70,7 +70,7 @@ TestSuite::addTest( Test *test )
/// Returns a string representation of the test suite.
std::string
string
TestSuite::toString() const
{
return "suite " + getName();
@@ -78,14 +78,14 @@ TestSuite::toString() const
/// Returns the name of the test suite.
std::string
string
TestSuite::getName() const
{
return m_name;
}
const std::vector<Test *> &
const vector<Test *> &
TestSuite::getTests() const
{
return m_tests;
+15 -15
View File
@@ -10,7 +10,7 @@ namespace CppUnit
TextOutputter::TextOutputter( TestResultCollector *result,
std::ostream &stream )
ostream &stream )
: m_result( result )
, m_stream( stream )
{
@@ -26,9 +26,9 @@ void
TextOutputter::write()
{
printHeader();
m_stream << std::endl;
m_stream << endl;
printFailures();
m_stream << std::endl;
m_stream << endl;
}
@@ -39,7 +39,7 @@ TextOutputter::printFailures()
int failureNumber = 1;
while ( itFailure != m_result->failures().end() )
{
m_stream << std::endl;
m_stream << endl;
printFailure( *itFailure++, failureNumber++ );
}
}
@@ -56,9 +56,9 @@ TextOutputter::printFailure( TestFailure *failure,
printFailureType( failure );
m_stream << ' ';
printFailureLocation( failure->sourceLine() );
m_stream << std::endl;
m_stream << endl;
printFailureDetail( failure->thrownException() );
m_stream << std::endl;
m_stream << endl;
}
@@ -102,12 +102,12 @@ TextOutputter::printFailureDetail( Exception *thrownException )
if ( thrownException->isInstanceOf( NotEqualException::type() ) )
{
NotEqualException *e = (NotEqualException*)thrownException;
m_stream << "expected: " << e->expectedValue() << std::endl
m_stream << "expected: " << e->expectedValue() << endl
<< "but was: " << e->actualValue();
if ( !e->additionalMessage().empty() )
{
m_stream << std::endl;
m_stream << "additional message:" << std::endl
m_stream << endl;
m_stream << "additional message:" << endl
<< e->additionalMessage();
}
}
@@ -122,11 +122,11 @@ void
TextOutputter::printHeader()
{
if ( m_result->wasSuccessful() )
m_stream << std::endl << "OK (" << m_result->runTests () << " tests)"
<< std::endl;
m_stream << endl << "OK (" << m_result->runTests () << " tests)"
<< endl;
else
{
m_stream << std::endl;
m_stream << endl;
printFailureWarning();
printStatistics();
}
@@ -136,19 +136,19 @@ TextOutputter::printHeader()
void
TextOutputter::printFailureWarning()
{
m_stream << "!!!FAILURES!!!" << std::endl;
m_stream << "!!!FAILURES!!!" << endl;
}
void
TextOutputter::printStatistics()
{
m_stream << "Test Results:" << std::endl;
m_stream << "Test Results:" << endl;
m_stream << "Run: " << m_result->runTests()
<< " Failures: " << m_result->testFailures()
<< " Errors: " << m_result->testErrors()
<< std::endl;
<< endl;
}
@@ -20,24 +20,24 @@ TextTestProgressListener::~TextTestProgressListener()
void
TextTestProgressListener::startTest( Test *test )
{
std::cerr << ".";
std::cerr.flush();
cerr << ".";
cerr.flush();
}
void
TextTestProgressListener::addFailure( const TestFailure &failure )
{
std::cerr << ( failure.isError() ? "E" : "F" );
std::cerr.flush();
cerr << ( failure.isError() ? "E" : "F" );
cerr.flush();
}
void
TextTestProgressListener::done()
{
std::cerr << std::endl;
std::cerr.flush();
cerr << endl;
cerr.flush();
}
} // namespace CppUnit
+28 -28
View File
@@ -26,7 +26,7 @@ void
TextTestResult::addFailure( const TestFailure &failure )
{
TestResultCollector::addFailure( failure );
std::cerr << ( failure.isError() ? "E" : "F" );
cerr << ( failure.isError() ? "E" : "F" );
}
@@ -34,18 +34,18 @@ void
TextTestResult::startTest( Test *test )
{
TestResultCollector::startTest (test);
std::cerr << ".";
cerr << ".";
}
void
TextTestResult::printFailures( std::ostream &stream )
TextTestResult::printFailures( ostream &stream )
{
TestFailures::const_iterator itFailure = failures().begin();
int failureNumber = 1;
while ( itFailure != failures().end() )
{
stream << std::endl;
stream << endl;
printFailure( *itFailure++, failureNumber++, stream );
}
}
@@ -54,7 +54,7 @@ TextTestResult::printFailures( std::ostream &stream )
void
TextTestResult::printFailure( TestFailure *failure,
int failureNumber,
std::ostream &stream )
ostream &stream )
{
printFailureListMark( failureNumber, stream );
stream << ' ';
@@ -63,15 +63,15 @@ TextTestResult::printFailure( TestFailure *failure,
printFailureType( failure, stream );
stream << ' ';
printFailureLocation( failure->sourceLine(), stream );
stream << std::endl;
stream << endl;
printFailureDetail( failure->thrownException(), stream );
stream << std::endl;
stream << endl;
}
void
TextTestResult::printFailureListMark( int failureNumber,
std::ostream &stream )
ostream &stream )
{
stream << failureNumber << ")";
}
@@ -79,7 +79,7 @@ TextTestResult::printFailureListMark( int failureNumber,
void
TextTestResult::printFailureTestName( TestFailure *failure,
std::ostream &stream )
ostream &stream )
{
stream << "test: " << failure->failedTest()->getName();
}
@@ -87,7 +87,7 @@ TextTestResult::printFailureTestName( TestFailure *failure,
void
TextTestResult::printFailureType( TestFailure *failure,
std::ostream &stream )
ostream &stream )
{
stream << "("
<< (failure->isError() ? "E" : "F")
@@ -97,7 +97,7 @@ TextTestResult::printFailureType( TestFailure *failure,
void
TextTestResult::printFailureLocation( SourceLine sourceLine,
std::ostream &stream )
ostream &stream )
{
if ( !sourceLine.isValid() )
return;
@@ -109,17 +109,17 @@ TextTestResult::printFailureLocation( SourceLine sourceLine,
void
TextTestResult::printFailureDetail( Exception *thrownException,
std::ostream &stream )
ostream &stream )
{
if ( thrownException->isInstanceOf( NotEqualException::type() ) )
{
NotEqualException *e = (NotEqualException*)thrownException;
stream << "expected: " << e->expectedValue() << std::endl
stream << "expected: " << e->expectedValue() << endl
<< "but was: " << e->actualValue();
if ( !e->additionalMessage().empty() )
{
stream << std::endl;
stream << "additional message:" << std::endl
stream << endl;
stream << "additional message:" << endl
<< e->additionalMessage();
}
}
@@ -131,23 +131,23 @@ TextTestResult::printFailureDetail( Exception *thrownException,
void
TextTestResult::print( std::ostream& stream )
TextTestResult::print( ostream& stream )
{
printHeader( stream );
stream << std::endl;
stream << endl;
printFailures( stream );
}
void
TextTestResult::printHeader( std::ostream &stream )
TextTestResult::printHeader( ostream &stream )
{
if (wasSuccessful ())
stream << std::endl << "OK (" << runTests () << " tests)"
<< std::endl;
stream << endl << "OK (" << runTests () << " tests)"
<< endl;
else
{
stream << std::endl;
stream << endl;
printFailureWarning( stream );
printStatistics( stream );
}
@@ -155,26 +155,26 @@ TextTestResult::printHeader( std::ostream &stream )
void
TextTestResult::printFailureWarning( std::ostream &stream )
TextTestResult::printFailureWarning( ostream &stream )
{
stream << "!!!FAILURES!!!" << std::endl;
stream << "!!!FAILURES!!!" << endl;
}
void
TextTestResult::printStatistics( std::ostream &stream )
TextTestResult::printStatistics( ostream &stream )
{
stream << "Test Results:" << std::endl;
stream << "Test Results:" << endl;
stream << "Run: " << runTests()
<< " Failures: " << testFailures()
<< " Errors: " << testErrors()
<< std::endl;
<< endl;
}
std::ostream &
operator <<( std::ostream &stream,
ostream &
operator <<( ostream &stream,
TextTestResult &result )
{
result.print (stream); return stream;
+4 -4
View File
@@ -8,11 +8,11 @@
namespace CppUnit {
std::string
TypeInfoHelper::getClassName( const std::type_info &info )
string
TypeInfoHelper::getClassName( const type_info &info )
{
static std::string classPrefix( "class " );
std::string name( info.name() );
static const string classPrefix( "class " );
string name( info.name() );
bool has_class_prefix = 0 ==
#if CPPUNIT_FUNC_STRING_COMPARE_STRING_FIRST
+23 -18
View File
@@ -14,15 +14,15 @@ namespace CppUnit
// //////////////////////////////////////////////////////////////////
XmlOutputter::Node::Node( std::string elementName,
std::string content ) :
XmlOutputter::Node::Node( string elementName,
string content ) :
m_name( elementName ),
m_content( content )
{
}
XmlOutputter::Node::Node( std::string elementName,
XmlOutputter::Node::Node( string elementName,
int numericContent ) :
m_name( elementName )
{
@@ -39,15 +39,15 @@ XmlOutputter::Node::~Node()
void
XmlOutputter::Node::addAttribute( std::string attributeName,
std::string value )
XmlOutputter::Node::addAttribute( string attributeName,
string value )
{
m_attributes.push_back( Attribute( attributeName, value ) );
}
void
XmlOutputter::Node::addAttribute( std::string attributeName,
XmlOutputter::Node::addAttribute( string attributeName,
int numericValue )
{
addAttribute( attributeName, asString( numericValue ) );
@@ -61,10 +61,10 @@ XmlOutputter::Node::addNode( Node *node )
}
std::string
string
XmlOutputter::Node::toString() const
{
std::string element = "<";
string element = "<";
element += m_name;
element += " ";
element += attributesAsString();
@@ -87,10 +87,10 @@ XmlOutputter::Node::toString() const
}
std::string
string
XmlOutputter::Node::attributesAsString() const
{
std::string attributes;
string attributes;
Attributes::const_iterator itAttribute = m_attributes.begin();
while ( itAttribute != m_attributes.end() )
{
@@ -104,10 +104,10 @@ XmlOutputter::Node::attributesAsString() const
}
std::string
XmlOutputter::Node::escape( std::string value ) const
string
XmlOutputter::Node::escape( string value ) const
{
std::string escaped;
string escaped;
for ( int index =0; index < (int)value.length(); ++index )
{
char c = value[index ];
@@ -137,7 +137,7 @@ XmlOutputter::Node::escape( std::string value ) const
}
// should be somewhere else... Future CppUnit::String ?
std::string
string
XmlOutputter::Node::asString( int value )
{
OStringStream stream;
@@ -152,8 +152,8 @@ XmlOutputter::Node::asString( int value )
// //////////////////////////////////////////////////////////////////
XmlOutputter::XmlOutputter( TestResultCollector *result,
std::ostream &stream,
std::string encoding ) :
ostream &stream,
string encoding ) :
m_result( result ),
m_stream( stream ),
m_encoding( encoding )
@@ -179,7 +179,7 @@ XmlOutputter::writeProlog()
{
m_stream << "<?xml version=\"1.0\" "
"encoding='" << m_encoding << "' standalone='yes' ?>"
<< std::endl;
<< endl;
}
@@ -216,7 +216,12 @@ XmlOutputter::fillFailedTestsMap( FailedTests &failedTests )
while ( itFailure != failures.end() )
{
TestFailure *failure = *itFailure++;
failedTests.insert( std::make_pair(failure->failedTest(), failure ) );
failedTests.insert(
pair< CppUnit::Test* const, CppUnit::TestFailure*
>(
failure->failedTest(), failure
)
);
}
}