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:
@@ -8,7 +8,7 @@
|
|||||||
//! Base class for single threaded unit tests
|
//! Base class for single threaded unit tests
|
||||||
class BTestCase : public CppUnit::TestCase {
|
class BTestCase : public CppUnit::TestCase {
|
||||||
public:
|
public:
|
||||||
BTestCase(std::string Name = "");
|
BTestCase(string Name = "");
|
||||||
|
|
||||||
//! Displays the next sub test progress indicator (i.e. [0][1][2][3]...).
|
//! Displays the next sub test progress indicator (i.e. [0][1][2][3]...).
|
||||||
virtual void NextSubTest();
|
virtual void NextSubTest();
|
||||||
|
|||||||
@@ -48,13 +48,13 @@ typedef CppUnit::SynchronizedObject::SynchronizationObject SyncObject;
|
|||||||
*/
|
*/
|
||||||
class BTestShell {
|
class BTestShell {
|
||||||
public:
|
public:
|
||||||
BTestShell(const std::string &description = "", SyncObject *syncObject = 0);
|
BTestShell(const string &description = "", SyncObject *syncObject = 0);
|
||||||
virtual ~BTestShell();
|
virtual ~BTestShell();
|
||||||
|
|
||||||
// This function is used to add the tests for a given kit (as contained
|
// This function is used to add the tests for a given kit (as contained
|
||||||
// in a BTestSuite object) to the list of available tests. The shell assumes
|
// in a BTestSuite object) to the list of available tests. The shell assumes
|
||||||
// ownership of the BTestSuite object. Each test in the kit is added to
|
// ownership of the BTestSuite object. Each test in the kit is added to
|
||||||
// the list of tests via a call to AddTest(std::string
|
// the list of tests via a call to AddTest(string
|
||||||
status_t AddSuite(BTestSuite *kit);
|
status_t AddSuite(BTestSuite *kit);
|
||||||
|
|
||||||
// This function is used to add test suites to the list of available
|
// This function is used to add test suites to the list of available
|
||||||
@@ -64,7 +64,7 @@ public:
|
|||||||
// when the program is run with "--list" as an argument. Usually the
|
// when the program is run with "--list" as an argument. Usually the
|
||||||
// given suite would be a test suite for an entire class, but that's
|
// given suite would be a test suite for an entire class, but that's
|
||||||
// not a requirement.
|
// not a requirement.
|
||||||
void AddTest(const std::string &name, CppUnit::Test* test);
|
void AddTest(const string &name, CppUnit::Test* test);
|
||||||
|
|
||||||
// This function loads all the test addons it finds in the given
|
// This function loads all the test addons it finds in the given
|
||||||
// directory, returning the number of tests actually loaded.
|
// directory, returning the number of tests actually loaded.
|
||||||
@@ -104,18 +104,18 @@ public:
|
|||||||
bool WasDebuggerCalled();
|
bool WasDebuggerCalled();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
typedef std::map<std::string, CppUnit::Test*> TestMap;
|
typedef map<string, CppUnit::Test*> TestMap;
|
||||||
typedef std::map<std::string, BTestSuite*> SuiteMap;
|
typedef map<string, BTestSuite*> SuiteMap;
|
||||||
|
|
||||||
VerbosityLevel fVerbosityLevel;
|
VerbosityLevel fVerbosityLevel;
|
||||||
std::set<std::string> fTestsToRun;
|
set<string> fTestsToRun;
|
||||||
std::set<std::string> fSuitesToRun;
|
set<string> fSuitesToRun;
|
||||||
TestMap fTests;
|
TestMap fTests;
|
||||||
SuiteMap fSuites;
|
SuiteMap fSuites;
|
||||||
std::set<std::string> fLibDirs;
|
set<string> fLibDirs;
|
||||||
CppUnit::TestResult fTestResults;
|
CppUnit::TestResult fTestResults;
|
||||||
CppUnit::TestResultCollector fResultsCollector;
|
CppUnit::TestResultCollector fResultsCollector;
|
||||||
std::string fDescription;
|
string fDescription;
|
||||||
static BTestShell* fGlobalShell;
|
static BTestShell* fGlobalShell;
|
||||||
static const char indent[];
|
static const char indent[];
|
||||||
bool fListTestsAndExit;
|
bool fListTestsAndExit;
|
||||||
@@ -149,7 +149,7 @@ protected:
|
|||||||
bool ProcessArguments(int argc, char *argv[]);
|
bool ProcessArguments(int argc, char *argv[]);
|
||||||
|
|
||||||
//! Processes a single argument, given by the \c arg parameter.
|
//! Processes a single argument, given by the \c arg parameter.
|
||||||
virtual bool ProcessArgument(std::string arg, int argc, char *argv[]);
|
virtual bool ProcessArgument(string arg, int argc, char *argv[]);
|
||||||
|
|
||||||
//! Makes any necessary pre-test preparations
|
//! Makes any necessary pre-test preparations
|
||||||
void InitOutput();
|
void InitOutput();
|
||||||
|
|||||||
@@ -10,22 +10,22 @@ class CppUnit::TestResult;
|
|||||||
//! Groups together a set of tests for a given kit.
|
//! Groups together a set of tests for a given kit.
|
||||||
class BTestSuite : public CppUnit::Test {
|
class BTestSuite : public CppUnit::Test {
|
||||||
public:
|
public:
|
||||||
BTestSuite( std::string name = "" );
|
BTestSuite( string name = "" );
|
||||||
virtual ~BTestSuite();
|
virtual ~BTestSuite();
|
||||||
|
|
||||||
virtual void run( CppUnit::TestResult *result );
|
virtual void run( CppUnit::TestResult *result );
|
||||||
virtual int countTestCases() const;
|
virtual int countTestCases() const;
|
||||||
virtual std::string getName() const;
|
virtual string getName() const;
|
||||||
virtual std::string toString() const;
|
virtual string toString() const;
|
||||||
|
|
||||||
virtual void addTest(std::string name, CppUnit::Test *test);
|
virtual void addTest(string name, CppUnit::Test *test);
|
||||||
virtual void deleteContents();
|
virtual void deleteContents();
|
||||||
|
|
||||||
const std::map<std::string, CppUnit::Test*> &getTests() const;
|
const map<string, CppUnit::Test*> &getTests() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::map<std::string, CppUnit::Test*> fTests;
|
map<string, CppUnit::Test*> fTests;
|
||||||
const std::string fName;
|
const string fName;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BTestSuite(const BTestSuite &other);
|
BTestSuite(const BTestSuite &other);
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ Equals(const A &a, const B &b, const C &c)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Returns a string version of the given integer
|
// Returns a string version of the given integer
|
||||||
std::string IntToStr(int i);
|
string IntToStr(int i);
|
||||||
|
|
||||||
// Calls system() with the concatenated string of command and parameter.
|
// Calls system() with the concatenated string of command and parameter.
|
||||||
void ExecCommand(const char *command, const char *parameter);
|
void ExecCommand(const char *command, const char *parameter);
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
//! Base class for single threaded unit tests
|
//! Base class for single threaded unit tests
|
||||||
class BThreadedTestCase : public BTestCase {
|
class BThreadedTestCase : public BTestCase {
|
||||||
public:
|
public:
|
||||||
BThreadedTestCase(std::string Name = "", std::string progressSeparator = ".");
|
BThreadedTestCase(string Name = "", string progressSeparator = ".");
|
||||||
virtual ~BThreadedTestCase();
|
virtual ~BThreadedTestCase();
|
||||||
|
|
||||||
/*! \brief Displays the next sub test progress indicator for the
|
/*! \brief Displays the next sub test progress indicator for the
|
||||||
@@ -33,24 +33,24 @@ public:
|
|||||||
|
|
||||||
//! Restores the current working directory to last directory saved by a call to SaveCWD().
|
//! Restores the current working directory to last directory saved by a call to SaveCWD().
|
||||||
void RestoreCWD(const char *alternate = NULL);
|
void RestoreCWD(const char *alternate = NULL);
|
||||||
void InitThreadInfo(thread_id id, std::string threadName);
|
void InitThreadInfo(thread_id id, string threadName);
|
||||||
bool RegisterForUse();
|
bool RegisterForUse();
|
||||||
void UnregisterForUse();
|
void UnregisterForUse();
|
||||||
|
|
||||||
std::vector<std::string>& AcquireUpdateList();
|
vector<string>& AcquireUpdateList();
|
||||||
void ReleaseUpdateList();
|
void ReleaseUpdateList();
|
||||||
protected:
|
protected:
|
||||||
bool fInUse;
|
bool fInUse;
|
||||||
|
|
||||||
// friend class ThreadManager<BThreadedTestCase>;
|
// friend class ThreadManager<BThreadedTestCase>;
|
||||||
std::string fProgressSeparator;
|
string fProgressSeparator;
|
||||||
|
|
||||||
struct ThreadSubTestInfo {
|
struct ThreadSubTestInfo {
|
||||||
std::string name;
|
string name;
|
||||||
int32 subTestNum;
|
int32 subTestNum;
|
||||||
};
|
};
|
||||||
std::map<thread_id, ThreadSubTestInfo*> fNumberMap;
|
map<thread_id, ThreadSubTestInfo*> fNumberMap;
|
||||||
std::vector<std::string> fUpdateList;
|
vector<string> fUpdateList;
|
||||||
BLocker *fUpdateLock;
|
BLocker *fUpdateLock;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -18,12 +18,12 @@ namespace CppUnit
|
|||||||
* #include <cppunit/TestAssert.h>
|
* #include <cppunit/TestAssert.h>
|
||||||
*
|
*
|
||||||
* void
|
* void
|
||||||
* checkXmlEqual( std::string expectedXml,
|
* checkXmlEqual( string expectedXml,
|
||||||
* std::string actualXml,
|
* string actualXml,
|
||||||
* CppUnit::SourceLine sourceLine )
|
* CppUnit::SourceLine sourceLine )
|
||||||
* {
|
* {
|
||||||
* std::string expected = XmlUniformiser( expectedXml ).stripped();
|
* string expected = XmlUniformiser( expectedXml ).stripped();
|
||||||
* std::string actual = XmlUniformiser( actualXml ).stripped();
|
* string actual = XmlUniformiser( actualXml ).stripped();
|
||||||
*
|
*
|
||||||
* if ( expected == actual )
|
* if ( expected == actual )
|
||||||
* return;
|
* return;
|
||||||
@@ -44,7 +44,7 @@ namespace Asserter
|
|||||||
|
|
||||||
/*! Throws a Exception with the specified message and location.
|
/*! Throws a Exception with the specified message and location.
|
||||||
*/
|
*/
|
||||||
void CPPUNIT_API fail( std::string message,
|
void CPPUNIT_API fail( string message,
|
||||||
SourceLine sourceLine = SourceLine() );
|
SourceLine sourceLine = SourceLine() );
|
||||||
|
|
||||||
/*! Throws a Exception with the specified message and location.
|
/*! Throws a Exception with the specified message and location.
|
||||||
@@ -54,7 +54,7 @@ namespace Asserter
|
|||||||
* \param sourceLine Location of the assertion.
|
* \param sourceLine Location of the assertion.
|
||||||
*/
|
*/
|
||||||
void CPPUNIT_API failIf( bool shouldFail,
|
void CPPUNIT_API failIf( bool shouldFail,
|
||||||
std::string message,
|
string message,
|
||||||
SourceLine sourceLine = SourceLine() );
|
SourceLine sourceLine = SourceLine() );
|
||||||
|
|
||||||
/*! Throws a NotEqualException with the specified message and location.
|
/*! Throws a NotEqualException with the specified message and location.
|
||||||
@@ -64,10 +64,10 @@ namespace Asserter
|
|||||||
* where the "difference" is located.
|
* where the "difference" is located.
|
||||||
* \param sourceLine Location of the assertion.
|
* \param sourceLine Location of the assertion.
|
||||||
*/
|
*/
|
||||||
void CPPUNIT_API failNotEqual( std::string expected,
|
void CPPUNIT_API failNotEqual( string expected,
|
||||||
std::string actual,
|
string actual,
|
||||||
SourceLine sourceLine = SourceLine(),
|
SourceLine sourceLine = SourceLine(),
|
||||||
std::string additionalMessage ="" );
|
string additionalMessage ="" );
|
||||||
|
|
||||||
/*! Throws a NotEqualException with the specified message and location.
|
/*! Throws a NotEqualException with the specified message and location.
|
||||||
* \param shouldFail if \c true then the exception is thrown. Otherwise
|
* \param shouldFail if \c true then the exception is thrown. Otherwise
|
||||||
@@ -79,10 +79,10 @@ namespace Asserter
|
|||||||
* \param sourceLine Location of the assertion.
|
* \param sourceLine Location of the assertion.
|
||||||
*/
|
*/
|
||||||
void CPPUNIT_API failNotEqualIf( bool shouldFail,
|
void CPPUNIT_API failNotEqualIf( bool shouldFail,
|
||||||
std::string expected,
|
string expected,
|
||||||
std::string actual,
|
string actual,
|
||||||
SourceLine sourceLine = SourceLine(),
|
SourceLine sourceLine = SourceLine(),
|
||||||
std::string additionalMessage ="" );
|
string additionalMessage ="" );
|
||||||
|
|
||||||
} // namespace Asserter
|
} // namespace Asserter
|
||||||
} // namespace CppUnit
|
} // namespace CppUnit
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ class TestResultCollector;
|
|||||||
* // if command line contains "-selftest" then this is the post build check
|
* // if command line contains "-selftest" then this is the post build check
|
||||||
* // => the output must be in the compiler error format.
|
* // => the output must be in the compiler error format.
|
||||||
* bool selfTest = (argc > 1) &&
|
* bool selfTest = (argc > 1) &&
|
||||||
* (std::string("-selftest") == argv[1]);
|
* (string("-selftest") == argv[1]);
|
||||||
*
|
*
|
||||||
* CppUnit::TextUi::TestRunner runner;
|
* CppUnit::TextUi::TestRunner runner;
|
||||||
* runner.addTest( CppUnitTest::suite() ); // Add the top suite to the test runner
|
* runner.addTest( CppUnitTest::suite() ); // Add the top suite to the test runner
|
||||||
@@ -44,7 +44,7 @@ class TestResultCollector;
|
|||||||
* // The test runner owns the new outputter.
|
* // The test runner owns the new outputter.
|
||||||
* runner.setOutputter( CppUnit::CompilerOutputter::defaultOutputter(
|
* runner.setOutputter( CppUnit::CompilerOutputter::defaultOutputter(
|
||||||
* &runner.result(),
|
* &runner.result(),
|
||||||
* std::cerr ) );
|
* cerr ) );
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
* // Run the test and don't wait a key if post build check.
|
* // Run the test and don't wait a key if post build check.
|
||||||
@@ -61,7 +61,7 @@ public:
|
|||||||
/*! Constructs a CompilerOutputter object.
|
/*! Constructs a CompilerOutputter object.
|
||||||
*/
|
*/
|
||||||
CompilerOutputter( TestResultCollector *result,
|
CompilerOutputter( TestResultCollector *result,
|
||||||
std::ostream &stream );
|
ostream &stream );
|
||||||
|
|
||||||
/// Destructor.
|
/// Destructor.
|
||||||
virtual ~CompilerOutputter();
|
virtual ~CompilerOutputter();
|
||||||
@@ -69,7 +69,7 @@ public:
|
|||||||
/*! Creates an instance of an outputter that matches your current compiler.
|
/*! Creates an instance of an outputter that matches your current compiler.
|
||||||
*/
|
*/
|
||||||
static CompilerOutputter *defaultOutputter( TestResultCollector *result,
|
static CompilerOutputter *defaultOutputter( TestResultCollector *result,
|
||||||
std::ostream &stream );
|
ostream &stream );
|
||||||
|
|
||||||
void write();
|
void write();
|
||||||
|
|
||||||
@@ -84,7 +84,7 @@ public:
|
|||||||
virtual void printFailureMessage( TestFailure *failure );
|
virtual void printFailureMessage( TestFailure *failure );
|
||||||
virtual void printNotEqualMessage( Exception *thrownException );
|
virtual void printNotEqualMessage( Exception *thrownException );
|
||||||
virtual void printDefaultMessage( Exception *thrownException );
|
virtual void printDefaultMessage( Exception *thrownException );
|
||||||
virtual std::string wrap( std::string message );
|
virtual string wrap( string message );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// Prevents the use of the copy constructor.
|
/// Prevents the use of the copy constructor.
|
||||||
@@ -93,12 +93,12 @@ private:
|
|||||||
/// Prevents the use of the copy operator.
|
/// Prevents the use of the copy operator.
|
||||||
void operator =( const CompilerOutputter © );
|
void operator =( const CompilerOutputter © );
|
||||||
|
|
||||||
typedef std::vector<std::string> Lines;
|
typedef vector<string> Lines;
|
||||||
static Lines splitMessageIntoLines( std::string message );
|
static Lines splitMessageIntoLines( string message );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TestResultCollector *m_result;
|
TestResultCollector *m_result;
|
||||||
std::ostream &m_stream;
|
ostream &m_stream;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -14,31 +14,31 @@ namespace CppUnit {
|
|||||||
* Exception is an exception that serves
|
* Exception is an exception that serves
|
||||||
* descriptive strings through its what() method
|
* descriptive strings through its what() method
|
||||||
*/
|
*/
|
||||||
class CPPUNIT_API Exception : public std::exception
|
class CPPUNIT_API Exception : public exception
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
class Type
|
class Type
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Type( std::string type ) : m_type ( type ) {}
|
Type( string type ) : m_type ( type ) {}
|
||||||
|
|
||||||
bool operator ==( const Type &other ) const
|
bool operator ==( const Type &other ) const
|
||||||
{
|
{
|
||||||
return m_type == other.m_type;
|
return m_type == other.m_type;
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
const std::string m_type;
|
const string m_type;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
Exception( std::string message = "",
|
Exception( string message = "",
|
||||||
SourceLine sourceLine = SourceLine() );
|
SourceLine sourceLine = SourceLine() );
|
||||||
|
|
||||||
#ifdef CPPUNIT_ENABLE_SOURCELINE_DEPRECATED
|
#ifdef CPPUNIT_ENABLE_SOURCELINE_DEPRECATED
|
||||||
Exception( std::string message,
|
Exception( string message,
|
||||||
long lineNumber,
|
long lineNumber,
|
||||||
std::string fileName );
|
string fileName );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Exception (const Exception& other);
|
Exception (const Exception& other);
|
||||||
@@ -53,9 +53,9 @@ public:
|
|||||||
|
|
||||||
#ifdef CPPUNIT_ENABLE_SOURCELINE_DEPRECATED
|
#ifdef CPPUNIT_ENABLE_SOURCELINE_DEPRECATED
|
||||||
long lineNumber() const;
|
long lineNumber() const;
|
||||||
std::string fileName() const;
|
string fileName() const;
|
||||||
|
|
||||||
static const std::string UNKNOWNFILENAME;
|
static const string UNKNOWNFILENAME;
|
||||||
static const long UNKNOWNLINENUMBER;
|
static const long UNKNOWNLINENUMBER;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -68,9 +68,9 @@ public:
|
|||||||
private:
|
private:
|
||||||
// VC++ does not recognize call to parent class when prefixed
|
// VC++ does not recognize call to parent class when prefixed
|
||||||
// with a namespace. This is a workaround.
|
// with a namespace. This is a workaround.
|
||||||
typedef std::exception SuperClass;
|
typedef exception SuperClass;
|
||||||
|
|
||||||
std::string m_message;
|
string m_message;
|
||||||
SourceLine m_sourceLine;
|
SourceLine m_sourceLine;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -19,16 +19,16 @@ public:
|
|||||||
* \param additionalMessage Additionnal information provided to further qualify
|
* \param additionalMessage Additionnal information provided to further qualify
|
||||||
* the inequality.
|
* the inequality.
|
||||||
*/
|
*/
|
||||||
NotEqualException( std::string expected,
|
NotEqualException( string expected,
|
||||||
std::string actual,
|
string actual,
|
||||||
SourceLine sourceLine = SourceLine(),
|
SourceLine sourceLine = SourceLine(),
|
||||||
std::string additionalMessage = "" );
|
string additionalMessage = "" );
|
||||||
|
|
||||||
#ifdef CPPUNIT_ENABLE_SOURCELINE_DEPRECATED
|
#ifdef CPPUNIT_ENABLE_SOURCELINE_DEPRECATED
|
||||||
NotEqualException( std::string expected,
|
NotEqualException( string expected,
|
||||||
std::string actual,
|
string actual,
|
||||||
long lineNumber,
|
long lineNumber,
|
||||||
std::string fileName );
|
string fileName );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
NotEqualException( const NotEqualException &other );
|
NotEqualException( const NotEqualException &other );
|
||||||
@@ -36,11 +36,11 @@ public:
|
|||||||
|
|
||||||
virtual ~NotEqualException() throw();
|
virtual ~NotEqualException() throw();
|
||||||
|
|
||||||
std::string expectedValue() const;
|
string expectedValue() const;
|
||||||
|
|
||||||
std::string actualValue() const;
|
string actualValue() const;
|
||||||
|
|
||||||
std::string additionalMessage() const;
|
string additionalMessage() const;
|
||||||
|
|
||||||
/*! Copy operator.
|
/*! Copy operator.
|
||||||
* @param other Object to copy.
|
* @param other Object to copy.
|
||||||
@@ -55,9 +55,9 @@ public:
|
|||||||
static Type type();
|
static Type type();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string m_expected;
|
string m_expected;
|
||||||
std::string m_actual;
|
string m_actual;
|
||||||
std::string m_additionalMessage;
|
string m_additionalMessage;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace CppUnit
|
} // namespace CppUnit
|
||||||
|
|||||||
@@ -16,6 +16,11 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(__POWERPC__) && defined(__BEOS__)
|
||||||
|
#define CPPUNIT_HAVE_SSTREAM 1
|
||||||
|
#undef CPPUNIT_FUNC_STRING_COMPARE_STRING_FIRST
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Define to 1 if you wish to have the old-style macros
|
/* Define to 1 if you wish to have the old-style macros
|
||||||
assert(), assertEqual(), assertDoublesEqual(), and assertLongsEqual() */
|
assert(), assertEqual(), assertDoublesEqual(), and assertLongsEqual() */
|
||||||
#ifndef CPPUNIT_ENABLE_NAKED_ASSERT
|
#ifndef CPPUNIT_ENABLE_NAKED_ASSERT
|
||||||
@@ -45,13 +50,13 @@
|
|||||||
/* perform portability hacks */
|
/* perform portability hacks */
|
||||||
|
|
||||||
|
|
||||||
/* Define CPPUNIT_SSTREAM as a stream with a "std::string str()"
|
/* Define CPPUNIT_SSTREAM as a stream with a "string str()"
|
||||||
* method.
|
* method.
|
||||||
*/
|
*/
|
||||||
#if CPPUNIT_HAVE_SSTREAM
|
#if CPPUNIT_HAVE_SSTREAM
|
||||||
# include <sstream>
|
# include <sstream>
|
||||||
namespace CppUnit {
|
namespace CppUnit {
|
||||||
class OStringStream : public std::ostringstream
|
class OStringStream : public ostringstream
|
||||||
{
|
{
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -65,14 +70,14 @@
|
|||||||
# endif
|
# endif
|
||||||
|
|
||||||
namespace CppUnit {
|
namespace CppUnit {
|
||||||
class OStringStream : public std::ostrstream
|
class OStringStream : public ostrstream
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
std::string str()
|
string str()
|
||||||
{
|
{
|
||||||
(*this) << '\0';
|
(*this) << '\0';
|
||||||
std::string msg(std::ostrstream::str());
|
string msg(ostrstream::str());
|
||||||
std::ostrstream::freeze(false);
|
ostrstream::freeze(false);
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ class CPPUNIT_API SourceLine
|
|||||||
public:
|
public:
|
||||||
SourceLine();
|
SourceLine();
|
||||||
|
|
||||||
SourceLine( const std::string &fileName,
|
SourceLine( const string &fileName,
|
||||||
int lineNumber );
|
int lineNumber );
|
||||||
|
|
||||||
/// Destructor.
|
/// Destructor.
|
||||||
@@ -42,13 +42,13 @@ public:
|
|||||||
|
|
||||||
int lineNumber() const;
|
int lineNumber() const;
|
||||||
|
|
||||||
std::string fileName() const;
|
string fileName() const;
|
||||||
|
|
||||||
bool operator ==( const SourceLine &other ) const;
|
bool operator ==( const SourceLine &other ) const;
|
||||||
bool operator !=( const SourceLine &other ) const;
|
bool operator !=( const SourceLine &other ) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string m_fileName;
|
string m_fileName;
|
||||||
int m_lineNumber;
|
int m_lineNumber;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ public:
|
|||||||
* Each test has a name. This name may be used to find the
|
* Each test has a name. This name may be used to find the
|
||||||
* test in a suite or registry of tests.
|
* test in a suite or registry of tests.
|
||||||
*/
|
*/
|
||||||
virtual std::string getName () const = 0;
|
virtual string getName () const = 0;
|
||||||
|
|
||||||
/*! \brief Description of the test, for diagnostic output.
|
/*! \brief Description of the test, for diagnostic output.
|
||||||
*
|
*
|
||||||
@@ -51,7 +51,7 @@ public:
|
|||||||
* suite named <tt>complex_add</tt> may be described as
|
* suite named <tt>complex_add</tt> may be described as
|
||||||
* <tt>suite complex_add</tt>.
|
* <tt>suite complex_add</tt>.
|
||||||
*/
|
*/
|
||||||
virtual std::string toString () const = 0;
|
virtual string toString () const = 0;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -14,16 +14,16 @@ namespace CppUnit {
|
|||||||
*
|
*
|
||||||
* \code
|
* \code
|
||||||
* template<>
|
* template<>
|
||||||
* struct assertion_traits<std::string> // specialization for the std::string type
|
* struct assertion_traits<string> // specialization for the string type
|
||||||
* {
|
* {
|
||||||
* static bool equal( const std::string& x, const std::string& y )
|
* static bool equal( const string& x, const string& y )
|
||||||
* {
|
* {
|
||||||
* return x == y;
|
* return x == y;
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
* static std::string toString( const std::string& x )
|
* static string toString( const string& x )
|
||||||
* {
|
* {
|
||||||
* std::string text = '"' + x + '"'; // adds quote around the string to see whitespace
|
* string text = '"' + x + '"'; // adds quote around the string to see whitespace
|
||||||
* OStringStream ost;
|
* OStringStream ost;
|
||||||
* ost << text;
|
* ost << text;
|
||||||
* return ost.str();
|
* return ost.str();
|
||||||
@@ -39,7 +39,7 @@ namespace CppUnit {
|
|||||||
return x == y;
|
return x == y;
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string toString( const T& x )
|
static string toString( const T& x )
|
||||||
{
|
{
|
||||||
OStringStream ost;
|
OStringStream ost;
|
||||||
ost << x;
|
ost << x;
|
||||||
@@ -52,21 +52,21 @@ namespace CppUnit {
|
|||||||
{
|
{
|
||||||
#ifdef CPPUNIT_ENABLE_SOURCELINE_DEPRECATED
|
#ifdef CPPUNIT_ENABLE_SOURCELINE_DEPRECATED
|
||||||
void CPPUNIT_API assertImplementation( bool condition,
|
void CPPUNIT_API assertImplementation( bool condition,
|
||||||
std::string conditionExpression = "",
|
string conditionExpression = "",
|
||||||
long lineNumber,
|
long lineNumber,
|
||||||
std::string fileName );
|
string fileName );
|
||||||
|
|
||||||
void CPPUNIT_API assertNotEqualImplementation( std::string expected,
|
void CPPUNIT_API assertNotEqualImplementation( string expected,
|
||||||
std::string actual,
|
string actual,
|
||||||
long lineNumber,
|
long lineNumber,
|
||||||
std::string fileName );
|
string fileName );
|
||||||
|
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
void assertEquals( const T& expected,
|
void assertEquals( const T& expected,
|
||||||
const T& actual,
|
const T& actual,
|
||||||
long lineNumber,
|
long lineNumber,
|
||||||
std::string fileName )
|
string fileName )
|
||||||
{
|
{
|
||||||
if ( !assertion_traits<T>::equal(expected,actual) ) // lazy toString conversion...
|
if ( !assertion_traits<T>::equal(expected,actual) ) // lazy toString conversion...
|
||||||
{
|
{
|
||||||
@@ -81,7 +81,7 @@ namespace CppUnit {
|
|||||||
double actual,
|
double actual,
|
||||||
double delta,
|
double delta,
|
||||||
long lineNumber,
|
long lineNumber,
|
||||||
std::string fileName );
|
string fileName );
|
||||||
|
|
||||||
#else // using SourceLine
|
#else // using SourceLine
|
||||||
|
|
||||||
@@ -89,7 +89,7 @@ namespace CppUnit {
|
|||||||
void assertEquals( const T& expected,
|
void assertEquals( const T& expected,
|
||||||
const T& actual,
|
const T& actual,
|
||||||
SourceLine sourceLine,
|
SourceLine sourceLine,
|
||||||
const std::string &message ="" )
|
const string &message ="" )
|
||||||
{
|
{
|
||||||
if ( !assertion_traits<T>::equal(expected,actual) ) // lazy toString conversion...
|
if ( !assertion_traits<T>::equal(expected,actual) ) // lazy toString conversion...
|
||||||
{
|
{
|
||||||
@@ -166,7 +166,7 @@ namespace CppUnit {
|
|||||||
*
|
*
|
||||||
* Requirement for \a expected and \a actual parameters:
|
* Requirement for \a expected and \a actual parameters:
|
||||||
* - They are exactly of the same type
|
* - They are exactly of the same type
|
||||||
* - They are serializable into a std::strstream using operator <<.
|
* - They are serializable into a strstream using operator <<.
|
||||||
* - They can be compared using operator ==.
|
* - They can be compared using operator ==.
|
||||||
*
|
*
|
||||||
* The last two requirements (serialization and comparison) can be
|
* The last two requirements (serialization and comparison) can be
|
||||||
@@ -189,7 +189,7 @@ namespace CppUnit {
|
|||||||
*
|
*
|
||||||
* Requirement for \a expected and \a actual parameters:
|
* Requirement for \a expected and \a actual parameters:
|
||||||
* - They are exactly of the same type
|
* - They are exactly of the same type
|
||||||
* - They are serializable into a std::strstream using operator <<.
|
* - They are serializable into a strstream using operator <<.
|
||||||
* - They can be compared using operator ==.
|
* - They can be compared using operator ==.
|
||||||
*
|
*
|
||||||
* The last two requirements (serialization and comparison) can be
|
* The last two requirements (serialization and comparison) can be
|
||||||
|
|||||||
@@ -33,11 +33,11 @@ struct ExpectedExceptionTraits
|
|||||||
static void expectedException()
|
static void expectedException()
|
||||||
{
|
{
|
||||||
#if CPPUNIT_USE_TYPEINFO_NAME
|
#if CPPUNIT_USE_TYPEINFO_NAME
|
||||||
std::string message( "Expected exception of type " );
|
string message( "Expected exception of type " );
|
||||||
message += TypeInfoHelper::getClassName( typeid( ExceptionType ) );
|
message += TypeInfoHelper::getClassName( typeid( ExceptionType ) );
|
||||||
message += ", but got none";
|
message += ", but got none";
|
||||||
#else
|
#else
|
||||||
std::string message( "Expected exception but got none" );
|
string message( "Expected exception but got none" );
|
||||||
#endif
|
#endif
|
||||||
throw Exception( message );
|
throw Exception( message );
|
||||||
}
|
}
|
||||||
@@ -111,7 +111,7 @@ public:
|
|||||||
* \param name name of this TestCaller
|
* \param name name of this TestCaller
|
||||||
* \param test the method this TestCaller calls in runTest()
|
* \param test the method this TestCaller calls in runTest()
|
||||||
*/
|
*/
|
||||||
TestCaller( std::string name, TestMethod test ) :
|
TestCaller( string name, TestMethod test ) :
|
||||||
TestCase( name ),
|
TestCase( name ),
|
||||||
m_ownFixture( true ),
|
m_ownFixture( true ),
|
||||||
m_fixture( new Fixture() ),
|
m_fixture( new Fixture() ),
|
||||||
@@ -128,7 +128,7 @@ public:
|
|||||||
* \param test the method this TestCaller calls in runTest()
|
* \param test the method this TestCaller calls in runTest()
|
||||||
* \param fixture the Fixture to invoke the test method on.
|
* \param fixture the Fixture to invoke the test method on.
|
||||||
*/
|
*/
|
||||||
TestCaller(std::string name, TestMethod test, Fixture& fixture) :
|
TestCaller(string name, TestMethod test, Fixture& fixture) :
|
||||||
TestCase( name ),
|
TestCase( name ),
|
||||||
m_ownFixture( false ),
|
m_ownFixture( false ),
|
||||||
m_fixture( &fixture ),
|
m_fixture( &fixture ),
|
||||||
@@ -145,7 +145,7 @@ public:
|
|||||||
* \param test the method this TestCaller calls in runTest()
|
* \param test the method this TestCaller calls in runTest()
|
||||||
* \param fixture the Fixture to invoke the test method on.
|
* \param fixture the Fixture to invoke the test method on.
|
||||||
*/
|
*/
|
||||||
TestCaller(std::string name, TestMethod test, Fixture* fixture) :
|
TestCaller(string name, TestMethod test, Fixture* fixture) :
|
||||||
TestCase( name ),
|
TestCase( name ),
|
||||||
m_ownFixture( true ),
|
m_ownFixture( true ),
|
||||||
m_fixture( fixture ),
|
m_fixture( fixture ),
|
||||||
@@ -182,7 +182,7 @@ protected:
|
|||||||
m_fixture->tearDown ();
|
m_fixture->tearDown ();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string toString() const
|
string toString() const
|
||||||
{
|
{
|
||||||
return "TestCaller " + getName();
|
return "TestCaller " + getName();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,15 +28,15 @@ class CPPUNIT_API TestCase : public Test,
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
TestCase( std::string Name );
|
TestCase( string Name );
|
||||||
//! \internal
|
//! \internal
|
||||||
TestCase();
|
TestCase();
|
||||||
~TestCase();
|
~TestCase();
|
||||||
|
|
||||||
virtual void run(TestResult *result);
|
virtual void run(TestResult *result);
|
||||||
virtual int countTestCases() const;
|
virtual int countTestCases() const;
|
||||||
std::string getName() const;
|
string getName() const;
|
||||||
std::string toString() const;
|
string toString() const;
|
||||||
|
|
||||||
//! FIXME: what is this for?
|
//! FIXME: what is this for?
|
||||||
virtual TestResult *run();
|
virtual TestResult *run();
|
||||||
@@ -53,7 +53,7 @@ private:
|
|||||||
TestCase &operator=( const TestCase &other );
|
TestCase &operator=( const TestCase &other );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const std::string m_name;
|
const string m_name;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace CppUnit
|
} // namespace CppUnit
|
||||||
|
|||||||
@@ -37,9 +37,9 @@ public:
|
|||||||
|
|
||||||
virtual bool isError() const;
|
virtual bool isError() const;
|
||||||
|
|
||||||
virtual std::string failedTestName() const;
|
virtual string failedTestName() const;
|
||||||
|
|
||||||
virtual std::string toString() const;
|
virtual string toString() const;
|
||||||
|
|
||||||
virtual TestFailure *clone() const;
|
virtual TestFailure *clone() const;
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ class TestFailure;
|
|||||||
class TestListener;
|
class TestListener;
|
||||||
|
|
||||||
#if CPPUNIT_NEED_DLL_DECL
|
#if CPPUNIT_NEED_DLL_DECL
|
||||||
template class CPPUNIT_API std::deque<TestListener *>;
|
template class CPPUNIT_API deque<TestListener *>;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*! \brief Manages TestListener.
|
/*! \brief Manages TestListener.
|
||||||
@@ -65,7 +65,7 @@ protected:
|
|||||||
void addFailure( const TestFailure &failure );
|
void addFailure( const TestFailure &failure );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
typedef std::deque<TestListener *> TestListeners;
|
typedef deque<TestListener *> TestListeners;
|
||||||
TestListeners m_listeners;
|
TestListeners m_listeners;
|
||||||
bool m_stop;
|
bool m_stop;
|
||||||
|
|
||||||
|
|||||||
@@ -17,8 +17,8 @@ namespace CppUnit
|
|||||||
|
|
||||||
|
|
||||||
#if CPPUNIT_NEED_DLL_DECL
|
#if CPPUNIT_NEED_DLL_DECL
|
||||||
template class CPPUNIT_API std::deque<TestFailure *>;
|
template class CPPUNIT_API deque<TestFailure *>;
|
||||||
template class CPPUNIT_API std::deque<Test *>;
|
template class CPPUNIT_API deque<Test *>;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@@ -38,8 +38,8 @@ namespace CppUnit
|
|||||||
class CPPUNIT_API TestResultCollector : public TestSucessListener
|
class CPPUNIT_API TestResultCollector : public TestSucessListener
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef std::deque<TestFailure *> TestFailures;
|
typedef deque<TestFailure *> TestFailures;
|
||||||
typedef std::deque<Test *> Tests;
|
typedef deque<Test *> Tests;
|
||||||
|
|
||||||
|
|
||||||
/*! Constructs a TestResultCollector object.
|
/*! Constructs a TestResultCollector object.
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ namespace CppUnit {
|
|||||||
class TestResult;
|
class TestResult;
|
||||||
|
|
||||||
#if CPPUNIT_NEED_DLL_DECL
|
#if CPPUNIT_NEED_DLL_DECL
|
||||||
template class CPPUNIT_API std::vector<Test *>;
|
template class CPPUNIT_API vector<Test *>;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@@ -44,16 +44,16 @@ class TestResult;
|
|||||||
class CPPUNIT_API TestSuite : public Test
|
class CPPUNIT_API TestSuite : public Test
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TestSuite( std::string name = "" );
|
TestSuite( string name = "" );
|
||||||
~TestSuite();
|
~TestSuite();
|
||||||
|
|
||||||
void run( TestResult *result );
|
void run( TestResult *result );
|
||||||
int countTestCases() const;
|
int countTestCases() const;
|
||||||
std::string getName() const;
|
string getName() const;
|
||||||
std::string toString() const;
|
string toString() const;
|
||||||
|
|
||||||
void addTest( Test *test );
|
void addTest( Test *test );
|
||||||
const std::vector<Test *> &getTests() const;
|
const vector<Test *> &getTests() const;
|
||||||
|
|
||||||
virtual void deleteContents();
|
virtual void deleteContents();
|
||||||
|
|
||||||
@@ -62,8 +62,8 @@ private:
|
|||||||
TestSuite &operator =( const TestSuite &other );
|
TestSuite &operator =( const TestSuite &other );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<Test *> m_tests;
|
vector<Test *> m_tests;
|
||||||
const std::string m_name;
|
const string m_name;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ class CPPUNIT_API TextOutputter : public Outputter
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TextOutputter( TestResultCollector *result,
|
TextOutputter( TestResultCollector *result,
|
||||||
std::ostream &stream );
|
ostream &stream );
|
||||||
|
|
||||||
/// Destructor.
|
/// Destructor.
|
||||||
virtual ~TextOutputter();
|
virtual ~TextOutputter();
|
||||||
@@ -42,7 +42,7 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
TestResultCollector *m_result;
|
TestResultCollector *m_result;
|
||||||
std::ostream &m_stream;
|
ostream &m_stream;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// Prevents the use of the copy constructor.
|
/// Prevents the use of the copy constructor.
|
||||||
|
|||||||
@@ -25,29 +25,29 @@ public:
|
|||||||
virtual void addFailure( Test *test, Exception *e );
|
virtual void addFailure( Test *test, Exception *e );
|
||||||
virtual void addFailure( const TestFailure &failure );
|
virtual void addFailure( const TestFailure &failure );
|
||||||
virtual void startTest( Test *test );
|
virtual void startTest( Test *test );
|
||||||
virtual void print( std::ostream &stream );
|
virtual void print( ostream &stream );
|
||||||
virtual void printFailures( std::ostream &stream );
|
virtual void printFailures( ostream &stream );
|
||||||
virtual void printHeader( std::ostream &stream );
|
virtual void printHeader( ostream &stream );
|
||||||
|
|
||||||
virtual void printFailure( TestFailure *failure,
|
virtual void printFailure( TestFailure *failure,
|
||||||
int failureNumber,
|
int failureNumber,
|
||||||
std::ostream &stream );
|
ostream &stream );
|
||||||
virtual void printFailureListMark( int failureNumber,
|
virtual void printFailureListMark( int failureNumber,
|
||||||
std::ostream &stream );
|
ostream &stream );
|
||||||
virtual void printFailureTestName( TestFailure *failure,
|
virtual void printFailureTestName( TestFailure *failure,
|
||||||
std::ostream &stream );
|
ostream &stream );
|
||||||
virtual void printFailureType( TestFailure *failure,
|
virtual void printFailureType( TestFailure *failure,
|
||||||
std::ostream &stream );
|
ostream &stream );
|
||||||
virtual void printFailureLocation( SourceLine sourceLine,
|
virtual void printFailureLocation( SourceLine sourceLine,
|
||||||
std::ostream &stream );
|
ostream &stream );
|
||||||
virtual void printFailureDetail( Exception *thrownException,
|
virtual void printFailureDetail( Exception *thrownException,
|
||||||
std::ostream &stream );
|
ostream &stream );
|
||||||
virtual void printFailureWarning( std::ostream &stream );
|
virtual void printFailureWarning( ostream &stream );
|
||||||
virtual void printStatistics( std::ostream &stream );
|
virtual void printStatistics( ostream &stream );
|
||||||
};
|
};
|
||||||
|
|
||||||
/** insertion operator for easy output */
|
/** insertion operator for easy output */
|
||||||
std::ostream &operator <<( std::ostream &stream,
|
ostream &operator <<( ostream &stream,
|
||||||
TextTestResult &result );
|
TextTestResult &result );
|
||||||
|
|
||||||
} // namespace CppUnit
|
} // namespace CppUnit
|
||||||
|
|||||||
@@ -36,8 +36,8 @@ public:
|
|||||||
* \param encoding Encoding used in the XML file (default is Latin-1).
|
* \param encoding Encoding used in the XML file (default is Latin-1).
|
||||||
*/
|
*/
|
||||||
XmlOutputter( TestResultCollector *result,
|
XmlOutputter( TestResultCollector *result,
|
||||||
std::ostream &stream,
|
ostream &stream,
|
||||||
std::string encoding = "ISO-8859-1" );
|
string encoding = "ISO-8859-1" );
|
||||||
|
|
||||||
/// Destructor.
|
/// Destructor.
|
||||||
virtual ~XmlOutputter();
|
virtual ~XmlOutputter();
|
||||||
@@ -56,33 +56,33 @@ public:
|
|||||||
class CPPUNIT_API Node
|
class CPPUNIT_API Node
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Node( std::string elementName,
|
Node( string elementName,
|
||||||
std::string content ="" );
|
string content ="" );
|
||||||
Node( std::string elementName,
|
Node( string elementName,
|
||||||
int numericContent );
|
int numericContent );
|
||||||
virtual ~Node();
|
virtual ~Node();
|
||||||
|
|
||||||
void addAttribute( std::string attributeName,
|
void addAttribute( string attributeName,
|
||||||
std::string value );
|
string value );
|
||||||
void addAttribute( std::string attributeName,
|
void addAttribute( string attributeName,
|
||||||
int numericValue );
|
int numericValue );
|
||||||
void addNode( Node *node );
|
void addNode( Node *node );
|
||||||
|
|
||||||
std::string toString() const;
|
string toString() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef std::pair<std::string,std::string> Attribute;
|
typedef pair<string,string> Attribute;
|
||||||
|
|
||||||
std::string attributesAsString() const;
|
string attributesAsString() const;
|
||||||
std::string escape( std::string value ) const;
|
string escape( string value ) const;
|
||||||
static std::string asString( int value );
|
static string asString( int value );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string m_name;
|
string m_name;
|
||||||
std::string m_content;
|
string m_content;
|
||||||
typedef std::deque<Attribute> Attributes;
|
typedef deque<Attribute> Attributes;
|
||||||
Attributes m_attributes;
|
Attributes m_attributes;
|
||||||
typedef std::deque<Node *> Nodes;
|
typedef deque<Node *> Nodes;
|
||||||
Nodes m_nodes;
|
Nodes m_nodes;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -90,7 +90,7 @@ public:
|
|||||||
virtual void writeProlog();
|
virtual void writeProlog();
|
||||||
virtual void writeTestsResult();
|
virtual void writeTestsResult();
|
||||||
|
|
||||||
typedef std::map<Test *,TestFailure*> FailedTests;
|
typedef map<Test *,TestFailure*> FailedTests;
|
||||||
virtual Node *makeRootNode();
|
virtual Node *makeRootNode();
|
||||||
virtual void addFailedTests( FailedTests &failedTests,
|
virtual void addFailedTests( FailedTests &failedTests,
|
||||||
Node *rootNode );
|
Node *rootNode );
|
||||||
@@ -111,8 +111,8 @@ protected:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
TestResultCollector *m_result;
|
TestResultCollector *m_result;
|
||||||
std::ostream &m_stream;
|
ostream &m_stream;
|
||||||
std::string m_encoding;
|
string m_encoding;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// Prevents the use of the copy constructor.
|
/// Prevents the use of the copy constructor.
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
/* config/config.h. Generated automatically by configure. */
|
/* config/config.h. Generated automatically by configure. */
|
||||||
/* config/config.h.in. Generated automatically from configure.in by autoheader. */
|
/* config/config.h.in. Generated automatically from configure.in by autoheader. */
|
||||||
|
|
||||||
/* define if library uses std::string::compare(string,pos,n) */
|
/* define if library uses string::compare(string,pos,n) */
|
||||||
#ifndef CPPUNIT_FUNC_STRING_COMPARE_STRING_FIRST
|
#ifndef CPPUNIT_FUNC_STRING_COMPARE_STRING_FIRST
|
||||||
#define CPPUNIT_FUNC_STRING_COMPARE_STRING_FIRST 1
|
#define CPPUNIT_FUNC_STRING_COMPARE_STRING_FIRST 1
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ namespace CppUnit {
|
|||||||
/** Auto-register the suite factory in the specified registry.
|
/** Auto-register the suite factory in the specified registry.
|
||||||
* \param name Name of the registry.
|
* \param name Name of the registry.
|
||||||
*/
|
*/
|
||||||
AutoRegisterSuite( const std::string &name )
|
AutoRegisterSuite( const string &name )
|
||||||
{
|
{
|
||||||
TestFactory *factory = new TestSuiteFactory<TestCaseType>();
|
TestFactory *factory = new TestSuiteFactory<TestCaseType>();
|
||||||
TestFactoryRegistry::getRegistry( name ).registerFactory( factory );
|
TestFactoryRegistry::getRegistry( name ).registerFactory( factory );
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ namespace CppUnit
|
|||||||
#if CPPUNIT_USE_TYPEINFO_NAME
|
#if CPPUNIT_USE_TYPEINFO_NAME
|
||||||
# define __CPPUNIT_SUITE_CTOR_ARGS( ATestFixtureType )
|
# define __CPPUNIT_SUITE_CTOR_ARGS( ATestFixtureType )
|
||||||
#else
|
#else
|
||||||
# define __CPPUNIT_SUITE_CTOR_ARGS( ATestFixtureType ) (std::string(#ATestFixtureType))
|
# define __CPPUNIT_SUITE_CTOR_ARGS( ATestFixtureType ) (string(#ATestFixtureType))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@@ -196,13 +196,13 @@ namespace CppUnit
|
|||||||
* #include <vector>
|
* #include <vector>
|
||||||
* class MyTest : public CppUnit::TestFixture {
|
* class MyTest : public CppUnit::TestFixture {
|
||||||
* CPPUNIT_TEST_SUITE( MyTest );
|
* CPPUNIT_TEST_SUITE( MyTest );
|
||||||
* CPPUNIT_TEST_EXCEPTION( testVectorAtThrow, std::invalid_argument );
|
* CPPUNIT_TEST_EXCEPTION( testVectorAtThrow, invalid_argument );
|
||||||
* CPPUNIT_TEST_SUITE_END();
|
* CPPUNIT_TEST_SUITE_END();
|
||||||
* public:
|
* public:
|
||||||
* void testVectorAtThrow()
|
* void testVectorAtThrow()
|
||||||
* {
|
* {
|
||||||
* std::vector<int> v;
|
* vector<int> v;
|
||||||
* v.at( 1 ); // must throw exception std::invalid_argument
|
* v.at( 1 ); // must throw exception invalid_argument
|
||||||
* }
|
* }
|
||||||
* };
|
* };
|
||||||
* \endcode
|
* \endcode
|
||||||
@@ -303,7 +303,7 @@ namespace CppUnit
|
|||||||
* \code
|
* \code
|
||||||
* // MySuites.h
|
* // MySuites.h
|
||||||
* namespace MySuites {
|
* namespace MySuites {
|
||||||
* std::string math() {
|
* string math() {
|
||||||
* return "Math";
|
* return "Math";
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ public:
|
|||||||
|
|
||||||
void run( TestResult *result );
|
void run( TestResult *result );
|
||||||
int countTestCases() const;
|
int countTestCases() const;
|
||||||
std::string toString() const;
|
string toString() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
RepeatedTest( const RepeatedTest & );
|
RepeatedTest( const RepeatedTest & );
|
||||||
|
|||||||
@@ -25,8 +25,8 @@ public:
|
|||||||
|
|
||||||
void run (TestResult *result);
|
void run (TestResult *result);
|
||||||
int countTestCases () const;
|
int countTestCases () const;
|
||||||
std::string getName () const;
|
string getName () const;
|
||||||
std::string toString () const;
|
string toString () const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Test *m_test;
|
Test *m_test;
|
||||||
@@ -53,11 +53,11 @@ inline void TestDecorator::run (TestResult *result)
|
|||||||
{ m_test->run (result); }
|
{ m_test->run (result); }
|
||||||
|
|
||||||
|
|
||||||
inline std::string TestDecorator::toString () const
|
inline string TestDecorator::toString () const
|
||||||
{ return m_test->toString (); }
|
{ return m_test->toString (); }
|
||||||
|
|
||||||
|
|
||||||
inline std::string TestDecorator::getName () const
|
inline string TestDecorator::getName () const
|
||||||
{ return m_test->getName(); }
|
{ return m_test->getName(); }
|
||||||
|
|
||||||
} // namespace CppUnit
|
} // namespace CppUnit
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ namespace CppUnit {
|
|||||||
class TestSuite;
|
class TestSuite;
|
||||||
|
|
||||||
#if CPPUNIT_NEED_DLL_DECL
|
#if CPPUNIT_NEED_DLL_DECL
|
||||||
template class CPPUNIT_API std::map<std::string, TestFactory *>;
|
template class CPPUNIT_API map<string, TestFactory *>;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@@ -79,7 +79,7 @@ public:
|
|||||||
* \param name Name of the registry. It is the name of TestSuite returned by
|
* \param name Name of the registry. It is the name of TestSuite returned by
|
||||||
* makeTest().
|
* makeTest().
|
||||||
*/
|
*/
|
||||||
TestFactoryRegistry( std::string name = "All Tests" );
|
TestFactoryRegistry( string name = "All Tests" );
|
||||||
|
|
||||||
/// Destructor.
|
/// Destructor.
|
||||||
virtual ~TestFactoryRegistry();
|
virtual ~TestFactoryRegistry();
|
||||||
@@ -104,7 +104,7 @@ public:
|
|||||||
* \return Registry. If the registry does not exist, it is created with the
|
* \return Registry. If the registry does not exist, it is created with the
|
||||||
* specified name.
|
* specified name.
|
||||||
*/
|
*/
|
||||||
static TestFactoryRegistry &getRegistry( const std::string &name );
|
static TestFactoryRegistry &getRegistry( const string &name );
|
||||||
|
|
||||||
/** Adds the registered tests to the specified suite.
|
/** Adds the registered tests to the specified suite.
|
||||||
* \param suite Suite the tests are added to.
|
* \param suite Suite the tests are added to.
|
||||||
@@ -116,7 +116,7 @@ public:
|
|||||||
* \param factory Factory to register.
|
* \param factory Factory to register.
|
||||||
* \deprecated Use registerFactory( TestFactory *) instead.
|
* \deprecated Use registerFactory( TestFactory *) instead.
|
||||||
*/
|
*/
|
||||||
void registerFactory( const std::string &name,
|
void registerFactory( const string &name,
|
||||||
TestFactory *factory );
|
TestFactory *factory );
|
||||||
|
|
||||||
/** Adds the specified TestFactory to the registry.
|
/** Adds the specified TestFactory to the registry.
|
||||||
@@ -130,10 +130,10 @@ private:
|
|||||||
void operator =( const TestFactoryRegistry © );
|
void operator =( const TestFactoryRegistry © );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef std::map<std::string, TestFactory *> Factories;
|
typedef map<string, TestFactory *> Factories;
|
||||||
Factories m_factories;
|
Factories m_factories;
|
||||||
|
|
||||||
std::string m_name;
|
string m_name;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ namespace CppUnit {
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
TestSuiteBuilder(std::string name) : m_suite( new TestSuite(name) )
|
TestSuiteBuilder(string name) : m_suite( new TestSuite(name) )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,7 +57,7 @@ namespace CppUnit {
|
|||||||
m_suite->addTest( test );
|
m_suite->addTest( test );
|
||||||
}
|
}
|
||||||
|
|
||||||
void addTestCaller( std::string methodName,
|
void addTestCaller( string methodName,
|
||||||
TestMethod testMethod )
|
TestMethod testMethod )
|
||||||
{
|
{
|
||||||
Test *test =
|
Test *test =
|
||||||
@@ -66,7 +66,7 @@ namespace CppUnit {
|
|||||||
addTest( test );
|
addTest( test );
|
||||||
}
|
}
|
||||||
|
|
||||||
void addTestCaller( std::string methodName,
|
void addTestCaller( string methodName,
|
||||||
TestMethod testMethod,
|
TestMethod testMethod,
|
||||||
Fixture *fixture )
|
Fixture *fixture )
|
||||||
{
|
{
|
||||||
@@ -78,7 +78,7 @@ namespace CppUnit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename ExceptionType>
|
template<typename ExceptionType>
|
||||||
void addTestCallerForException( std::string methodName,
|
void addTestCallerForException( string methodName,
|
||||||
TestMethod testMethod,
|
TestMethod testMethod,
|
||||||
Fixture *fixture,
|
Fixture *fixture,
|
||||||
ExceptionType *dummyPointer )
|
ExceptionType *dummyPointer )
|
||||||
@@ -91,13 +91,13 @@ namespace CppUnit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::string makeTestName( const std::string &methodName )
|
string makeTestName( const string &methodName )
|
||||||
{
|
{
|
||||||
return m_suite->getName() + "." + methodName;
|
return m_suite->getName() + "." + methodName;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::auto_ptr<TestSuite> m_suite;
|
auto_ptr<TestSuite> m_suite;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace CppUnit
|
} // namespace CppUnit
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ namespace CppUnit {
|
|||||||
* the "class" prefix. If the name is not prefixed
|
* the "class" prefix. If the name is not prefixed
|
||||||
* by "class", it is returned as this.
|
* by "class", it is returned as this.
|
||||||
*/
|
*/
|
||||||
static std::string getClassName( const std::type_info &info );
|
static string getClassName( const type_info &info );
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace CppUnit
|
} // namespace CppUnit
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ namespace TextUi
|
|||||||
* runner.addTest( ExampleTestCase::suite() );
|
* runner.addTest( ExampleTestCase::suite() );
|
||||||
* runner.setOutputter( CppUnit::CompilerOutputter::defaultOutputter(
|
* runner.setOutputter( CppUnit::CompilerOutputter::defaultOutputter(
|
||||||
* &runner.result(),
|
* &runner.result(),
|
||||||
* std::cerr ) );
|
* cerr ) );
|
||||||
* MyCustomProgressTestListener progress;
|
* MyCustomProgressTestListener progress;
|
||||||
* runner.eventManager().addListener( &progress );
|
* runner.eventManager().addListener( &progress );
|
||||||
* runner.run( "", true ); // Run all tests and wait
|
* runner.run( "", true ); // Run all tests and wait
|
||||||
@@ -66,7 +66,7 @@ public:
|
|||||||
|
|
||||||
virtual ~TestRunner();
|
virtual ~TestRunner();
|
||||||
|
|
||||||
bool run( std::string testName ="",
|
bool run( string testName ="",
|
||||||
bool doWait = false,
|
bool doWait = false,
|
||||||
bool doPrintResult = true,
|
bool doPrintResult = true,
|
||||||
bool doPrintProgress = true );
|
bool doPrintProgress = true );
|
||||||
@@ -82,12 +82,12 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
virtual bool runTest( Test *test,
|
virtual bool runTest( Test *test,
|
||||||
bool doPrintProgress );
|
bool doPrintProgress );
|
||||||
virtual bool runTestByName( std::string testName,
|
virtual bool runTestByName( string testName,
|
||||||
bool printProgress );
|
bool printProgress );
|
||||||
virtual void wait( bool doWait );
|
virtual void wait( bool doWait );
|
||||||
virtual void printResult( bool doPrintResult );
|
virtual void printResult( bool doPrintResult );
|
||||||
|
|
||||||
virtual Test *findTestByName( std::string name ) const;
|
virtual Test *findTestByName( string name ) const;
|
||||||
|
|
||||||
TestSuite *m_suite;
|
TestSuite *m_suite;
|
||||||
TestResultCollector *m_result;
|
TestResultCollector *m_result;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
BTestCase::BTestCase(std::string name)
|
BTestCase::BTestCase(string name)
|
||||||
: CppUnit::TestCase(name)
|
: CppUnit::TestCase(name)
|
||||||
, fValidCWD(false)
|
, fValidCWD(false)
|
||||||
, fSubTestNum(0)
|
, fSubTestNum(0)
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#include <iostream>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <string>
|
#include <string>
|
||||||
@@ -20,13 +21,12 @@
|
|||||||
|
|
||||||
#include <TestShell.h>
|
#include <TestShell.h>
|
||||||
#include <TestListener.h>
|
#include <TestListener.h>
|
||||||
|
|
||||||
#include <ElfSymbolPatcher.h>
|
#include <ElfSymbolPatcher.h>
|
||||||
|
|
||||||
BTestShell *BTestShell::fGlobalShell = NULL;
|
BTestShell *BTestShell::fGlobalShell = NULL;
|
||||||
const char BTestShell::indent[] = " ";
|
const char BTestShell::indent[] = " ";
|
||||||
|
|
||||||
BTestShell::BTestShell(const std::string &description, SyncObject *syncObject)
|
BTestShell::BTestShell(const string &description, SyncObject *syncObject)
|
||||||
: fVerbosityLevel(v2)
|
: fVerbosityLevel(v2)
|
||||||
, fTestResults(syncObject)
|
, fTestResults(syncObject)
|
||||||
, fDescription(description)
|
, fDescription(description)
|
||||||
@@ -72,7 +72,7 @@ BTestShell::AddSuite(BTestSuite *suite) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
BTestShell::AddTest(const std::string &name, CppUnit::Test *test) {
|
BTestShell::AddTest(const string &name, CppUnit::Test *test) {
|
||||||
if (test != NULL)
|
if (test != NULL)
|
||||||
fTests[name] = test;
|
fTests[name] = test;
|
||||||
else
|
else
|
||||||
@@ -153,8 +153,8 @@ BTestShell::Run(int argc, char *argv[]) {
|
|||||||
suite.addTest( i->second );
|
suite.addTest( i->second );
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
std::set<std::string>::const_iterator i;
|
set<string>::const_iterator i;
|
||||||
std::set<std::string> suitesToRemove;
|
set<string> suitesToRemove;
|
||||||
|
|
||||||
// Add all the tests from any specified suites to the list of
|
// Add all the tests from any specified suites to the list of
|
||||||
// tests to run (since we use a set, this eliminates the concern
|
// 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
|
// Handle each command line argument (skipping the first
|
||||||
// which is just the app name)
|
// which is just the app name)
|
||||||
for (int i = 1; i < argc; i++) {
|
for (int i = 1; i < argc; i++) {
|
||||||
std::string str(argv[i]);
|
string str(argv[i]);
|
||||||
|
|
||||||
if (!ProcessArgument(str, argc, argv))
|
if (!ProcessArgument(str, argc, argv))
|
||||||
return false;
|
return false;
|
||||||
@@ -322,7 +322,7 @@ BTestShell::ProcessArguments(int argc, char *argv[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
BTestShell::ProcessArgument(std::string arg, int argc, char *argv[]) {
|
BTestShell::ProcessArgument(string arg, int argc, char *argv[]) {
|
||||||
if (arg == "--help") {
|
if (arg == "--help") {
|
||||||
PrintDescription(argc, argv);
|
PrintDescription(argc, argv);
|
||||||
PrintHelp();
|
PrintHelp();
|
||||||
@@ -419,7 +419,7 @@ BTestShell::LoadDynamicSuites() {
|
|||||||
cout << "------------------------------------------------------------------------------" << endl;
|
cout << "------------------------------------------------------------------------------" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::set<std::string>::iterator i;
|
set<string>::iterator i;
|
||||||
for (i = fLibDirs.begin(); i != fLibDirs.end(); i++) {
|
for (i = fLibDirs.begin(); i != fLibDirs.end(); i++) {
|
||||||
BDirectory libDir((*i).c_str());
|
BDirectory libDir((*i).c_str());
|
||||||
if (Verbosity() >= v3)
|
if (Verbosity() >= v3)
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
#include <cppunit/TestResult.h>
|
#include <cppunit/TestResult.h>
|
||||||
|
|
||||||
// Default constructor
|
// Default constructor
|
||||||
BTestSuite::BTestSuite( std::string name )
|
BTestSuite::BTestSuite( string name )
|
||||||
: fName(name)
|
: fName(name)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -17,7 +17,7 @@ BTestSuite::~BTestSuite() {
|
|||||||
// Deletes all tests in the suite.
|
// Deletes all tests in the suite.
|
||||||
void
|
void
|
||||||
BTestSuite::deleteContents() {
|
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 != fTests.end();
|
||||||
++it)
|
++it)
|
||||||
delete it->second;
|
delete it->second;
|
||||||
@@ -28,7 +28,7 @@ BTestSuite::deleteContents() {
|
|||||||
/// Runs the tests and collects their result in a TestResult.
|
/// Runs the tests and collects their result in a TestResult.
|
||||||
void
|
void
|
||||||
BTestSuite::run( CppUnit::TestResult *result ) {
|
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 != fTests.end();
|
||||||
++it )
|
++it )
|
||||||
{
|
{
|
||||||
@@ -46,7 +46,7 @@ int
|
|||||||
BTestSuite::countTestCases() const {
|
BTestSuite::countTestCases() const {
|
||||||
int count = 0;
|
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 != fTests.end();
|
||||||
++it )
|
++it )
|
||||||
count += it->second->countTestCases();
|
count += it->second->countTestCases();
|
||||||
@@ -57,26 +57,26 @@ BTestSuite::countTestCases() const {
|
|||||||
|
|
||||||
// Adds a test to the suite.
|
// Adds a test to the suite.
|
||||||
void
|
void
|
||||||
BTestSuite::addTest(std::string name, CppUnit::Test *test) {
|
BTestSuite::addTest(string name, CppUnit::Test *test) {
|
||||||
fTests[name] = test;
|
fTests[name] = test;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Returns a string representation of the test suite.
|
// Returns a string representation of the test suite.
|
||||||
std::string
|
string
|
||||||
BTestSuite::toString() const {
|
BTestSuite::toString() const {
|
||||||
return "suite " + getName();
|
return "suite " + getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Returns the name of the test suite.
|
// Returns the name of the test suite.
|
||||||
std::string
|
string
|
||||||
BTestSuite::getName() const {
|
BTestSuite::getName() const {
|
||||||
return fName;
|
return fName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const std::map<std::string, CppUnit::Test*> &
|
const map<string, CppUnit::Test*> &
|
||||||
BTestSuite::getTests() const {
|
BTestSuite::getTests() const {
|
||||||
return fTests;
|
return fTests;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,12 +3,13 @@
|
|||||||
#include <TestUtils.h>
|
#include <TestUtils.h>
|
||||||
#include <TestShell.h>
|
#include <TestShell.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
status_t DecodeResult(status_t result) {
|
status_t DecodeResult(status_t result) {
|
||||||
if (!BTestShell::GlobalBeVerbose())
|
if (!BTestShell::GlobalBeVerbose())
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
std::string str;
|
string str;
|
||||||
switch (result) {
|
switch (result) {
|
||||||
|
|
||||||
case B_OK:
|
case B_OK:
|
||||||
@@ -177,10 +178,10 @@ status_t DecodeResult(status_t result) {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string IntToStr(int i) {
|
string IntToStr(int i) {
|
||||||
char num[32];
|
char num[32];
|
||||||
sprintf(num, "%d", i);
|
sprintf(num, "%d", i);
|
||||||
return std::string(num);
|
return string(num);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExecCommand(const char *command) {
|
void ExecCommand(const char *command) {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
#include <Autolock.h>
|
#include <Autolock.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
BThreadedTestCase::BThreadedTestCase(std::string name, std::string progressSeparator)
|
BThreadedTestCase::BThreadedTestCase(string name, string progressSeparator)
|
||||||
: BTestCase(name)
|
: BTestCase(name)
|
||||||
, fProgressSeparator(progressSeparator)
|
, fProgressSeparator(progressSeparator)
|
||||||
, fUpdateLock(new BLocker())
|
, fUpdateLock(new BLocker())
|
||||||
@@ -15,7 +15,7 @@ BThreadedTestCase::~BThreadedTestCase() {
|
|||||||
delete fUpdateLock;
|
delete fUpdateLock;
|
||||||
|
|
||||||
// Clean up
|
// 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 != fNumberMap.end();
|
||||||
i++)
|
i++)
|
||||||
{
|
{
|
||||||
@@ -31,13 +31,13 @@ BThreadedTestCase::NextSubTest() {
|
|||||||
{
|
{
|
||||||
// Acquire the update lock
|
// Acquire the update lock
|
||||||
BAutolock lock(fUpdateLock);
|
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) {
|
if (i != fNumberMap.end() && i->second) {
|
||||||
// Handle multi-threaded case
|
// Handle multi-threaded case
|
||||||
ThreadSubTestInfo *info = i->second;
|
ThreadSubTestInfo *info = i->second;
|
||||||
char num[32];
|
char num[32];
|
||||||
sprintf(num, "%ld", info->subTestNum++);
|
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);
|
fUpdateList.push_back(str);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -72,16 +72,16 @@ BThreadedTestCase::Outputf(const char *str, ...) {
|
|||||||
{
|
{
|
||||||
// Acquire the update lock and post our update
|
// Acquire the update lock and post our update
|
||||||
BAutolock lock(fUpdateLock);
|
BAutolock lock(fUpdateLock);
|
||||||
fUpdateList.push_back(std::string(msg));
|
fUpdateList.push_back(string(msg));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
BThreadedTestCase::InitThreadInfo(thread_id id, std::string threadName) {
|
BThreadedTestCase::InitThreadInfo(thread_id id, string threadName) {
|
||||||
BAutolock lock(fUpdateLock); // Lock the number map
|
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) {
|
if (i != fNumberMap.end() && i->second) {
|
||||||
i->second->name = threadName;
|
i->second->name = threadName;
|
||||||
i->second->subTestNum = 0;
|
i->second->subTestNum = 0;
|
||||||
@@ -108,7 +108,7 @@ BThreadedTestCase::UnregisterForUse() {
|
|||||||
fInUse = false;
|
fInUse = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string>&
|
vector<string>&
|
||||||
BThreadedTestCase::AcquireUpdateList() {
|
BThreadedTestCase::AcquireUpdateList() {
|
||||||
fUpdateLock->Lock();
|
fUpdateLock->Lock();
|
||||||
return fUpdateList;
|
return fUpdateList;
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ namespace Asserter
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
fail( std::string message,
|
fail( string message,
|
||||||
SourceLine sourceLine )
|
SourceLine sourceLine )
|
||||||
{
|
{
|
||||||
throw Exception( message, sourceLine );
|
throw Exception( message, sourceLine );
|
||||||
@@ -20,7 +20,7 @@ fail( std::string message,
|
|||||||
|
|
||||||
void
|
void
|
||||||
failIf( bool shouldFail,
|
failIf( bool shouldFail,
|
||||||
std::string message,
|
string message,
|
||||||
SourceLine location )
|
SourceLine location )
|
||||||
{
|
{
|
||||||
if ( shouldFail )
|
if ( shouldFail )
|
||||||
@@ -29,10 +29,10 @@ failIf( bool shouldFail,
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
failNotEqual( std::string expected,
|
failNotEqual( string expected,
|
||||||
std::string actual,
|
string actual,
|
||||||
SourceLine sourceLine,
|
SourceLine sourceLine,
|
||||||
std::string additionalMessage )
|
string additionalMessage )
|
||||||
{
|
{
|
||||||
throw NotEqualException( expected,
|
throw NotEqualException( expected,
|
||||||
actual,
|
actual,
|
||||||
@@ -43,10 +43,10 @@ failNotEqual( std::string expected,
|
|||||||
|
|
||||||
void
|
void
|
||||||
failNotEqualIf( bool shouldFail,
|
failNotEqualIf( bool shouldFail,
|
||||||
std::string expected,
|
string expected,
|
||||||
std::string actual,
|
string actual,
|
||||||
SourceLine sourceLine,
|
SourceLine sourceLine,
|
||||||
std::string additionalMessage )
|
string additionalMessage )
|
||||||
{
|
{
|
||||||
if ( shouldFail )
|
if ( shouldFail )
|
||||||
failNotEqual( expected, actual, sourceLine, additionalMessage );
|
failNotEqual( expected, actual, sourceLine, additionalMessage );
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ namespace CppUnit
|
|||||||
{
|
{
|
||||||
|
|
||||||
CompilerOutputter::CompilerOutputter( TestResultCollector *result,
|
CompilerOutputter::CompilerOutputter( TestResultCollector *result,
|
||||||
std::ostream &stream ) :
|
ostream &stream ) :
|
||||||
m_result( result ),
|
m_result( result ),
|
||||||
m_stream( stream )
|
m_stream( stream )
|
||||||
{
|
{
|
||||||
@@ -24,7 +24,7 @@ CompilerOutputter::~CompilerOutputter()
|
|||||||
|
|
||||||
CompilerOutputter *
|
CompilerOutputter *
|
||||||
CompilerOutputter::defaultOutputter( TestResultCollector *result,
|
CompilerOutputter::defaultOutputter( TestResultCollector *result,
|
||||||
std::ostream &stream )
|
ostream &stream )
|
||||||
{
|
{
|
||||||
return new CompilerOutputter( result, stream );
|
return new CompilerOutputter( result, stream );
|
||||||
// For automatic adpatation...
|
// For automatic adpatation...
|
||||||
@@ -46,7 +46,7 @@ void
|
|||||||
CompilerOutputter::printSucess()
|
CompilerOutputter::printSucess()
|
||||||
{
|
{
|
||||||
m_stream << "OK (" << m_result->runTests() << ")"
|
m_stream << "OK (" << m_result->runTests() << ")"
|
||||||
<< std::endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -99,7 +99,7 @@ CompilerOutputter::printFailureType( TestFailure *failure )
|
|||||||
void
|
void
|
||||||
CompilerOutputter::printFailedTestName( TestFailure *failure )
|
CompilerOutputter::printFailedTestName( TestFailure *failure )
|
||||||
{
|
{
|
||||||
m_stream << std::endl;
|
m_stream << endl;
|
||||||
m_stream << "Test name: " << failure->failedTestName();
|
m_stream << "Test name: " << failure->failedTestName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,13 +107,13 @@ CompilerOutputter::printFailedTestName( TestFailure *failure )
|
|||||||
void
|
void
|
||||||
CompilerOutputter::printFailureMessage( TestFailure *failure )
|
CompilerOutputter::printFailureMessage( TestFailure *failure )
|
||||||
{
|
{
|
||||||
m_stream << std::endl;
|
m_stream << endl;
|
||||||
Exception *thrownException = failure->thrownException();
|
Exception *thrownException = failure->thrownException();
|
||||||
if ( thrownException->isInstanceOf( NotEqualException::type() ) )
|
if ( thrownException->isInstanceOf( NotEqualException::type() ) )
|
||||||
printNotEqualMessage( thrownException );
|
printNotEqualMessage( thrownException );
|
||||||
else
|
else
|
||||||
printDefaultMessage( thrownException );
|
printDefaultMessage( thrownException );
|
||||||
m_stream << std::endl;
|
m_stream << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -122,13 +122,13 @@ CompilerOutputter::printNotEqualMessage( Exception *thrownException )
|
|||||||
{
|
{
|
||||||
NotEqualException *e = (NotEqualException *)thrownException;
|
NotEqualException *e = (NotEqualException *)thrownException;
|
||||||
m_stream << wrap( "- Expected : " + e->expectedValue() );
|
m_stream << wrap( "- Expected : " + e->expectedValue() );
|
||||||
m_stream << std::endl;
|
m_stream << endl;
|
||||||
m_stream << wrap( "- Actual : " + e->actualValue() );
|
m_stream << wrap( "- Actual : " + e->actualValue() );
|
||||||
m_stream << std::endl;
|
m_stream << endl;
|
||||||
if ( !e->additionalMessage().empty() )
|
if ( !e->additionalMessage().empty() )
|
||||||
{
|
{
|
||||||
m_stream << wrap( e->additionalMessage() );
|
m_stream << wrap( e->additionalMessage() );
|
||||||
m_stream << std::endl;
|
m_stream << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -136,36 +136,36 @@ CompilerOutputter::printNotEqualMessage( Exception *thrownException )
|
|||||||
void
|
void
|
||||||
CompilerOutputter::printDefaultMessage( Exception *thrownException )
|
CompilerOutputter::printDefaultMessage( Exception *thrownException )
|
||||||
{
|
{
|
||||||
std::string wrappedMessage = wrap( thrownException->what() );
|
string wrappedMessage = wrap( thrownException->what() );
|
||||||
m_stream << wrappedMessage << std::endl;
|
m_stream << wrappedMessage << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
CompilerOutputter::printStatistics()
|
CompilerOutputter::printStatistics()
|
||||||
{
|
{
|
||||||
m_stream << "Failures !!!" << std::endl;
|
m_stream << "Failures !!!" << endl;
|
||||||
m_stream << "Run: " << m_result->runTests() << " "
|
m_stream << "Run: " << m_result->runTests() << " "
|
||||||
<< "Failure total: " << m_result->testFailuresTotal() << " "
|
<< "Failure total: " << m_result->testFailuresTotal() << " "
|
||||||
<< "Failures: " << m_result->testFailures() << " "
|
<< "Failures: " << m_result->testFailures() << " "
|
||||||
<< "Errors: " << m_result->testErrors()
|
<< "Errors: " << m_result->testErrors()
|
||||||
<< std::endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::string
|
string
|
||||||
CompilerOutputter::wrap( std::string message )
|
CompilerOutputter::wrap( string message )
|
||||||
{
|
{
|
||||||
Lines lines = splitMessageIntoLines( message );
|
Lines lines = splitMessageIntoLines( message );
|
||||||
std::string wrapped;
|
string wrapped;
|
||||||
for ( Lines::iterator it = lines.begin(); it != lines.end(); ++it )
|
for ( Lines::iterator it = lines.begin(); it != lines.end(); ++it )
|
||||||
{
|
{
|
||||||
std::string line( *it );
|
string line( *it );
|
||||||
const int maxLineLength = 80;
|
const int maxLineLength = 80;
|
||||||
int index =0;
|
int index =0;
|
||||||
while ( index < (int)line.length() )
|
while ( index < (int)line.length() )
|
||||||
{
|
{
|
||||||
std::string line( line.substr( index, maxLineLength ) );
|
string line( line.substr( index, maxLineLength ) );
|
||||||
wrapped += line;
|
wrapped += line;
|
||||||
index += maxLineLength;
|
index += maxLineLength;
|
||||||
if ( index < (int)line.length() )
|
if ( index < (int)line.length() )
|
||||||
@@ -178,14 +178,14 @@ CompilerOutputter::wrap( std::string message )
|
|||||||
|
|
||||||
|
|
||||||
CompilerOutputter::Lines
|
CompilerOutputter::Lines
|
||||||
CompilerOutputter::splitMessageIntoLines( std::string message )
|
CompilerOutputter::splitMessageIntoLines( string message )
|
||||||
{
|
{
|
||||||
Lines lines;
|
Lines lines;
|
||||||
|
|
||||||
std::string::iterator itStart = message.begin();
|
string::iterator itStart = message.begin();
|
||||||
while ( true )
|
while ( true )
|
||||||
{
|
{
|
||||||
std::string::iterator itEol = std::find( itStart,
|
string::iterator itEol = find( itStart,
|
||||||
message.end(),
|
message.end(),
|
||||||
'\n' );
|
'\n' );
|
||||||
lines.push_back( message.substr( itStart - message.begin(),
|
lines.push_back( message.substr( itStart - message.begin(),
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ namespace CppUnit {
|
|||||||
/*!
|
/*!
|
||||||
* \deprecated Use SourceLine::isValid() instead.
|
* \deprecated Use SourceLine::isValid() instead.
|
||||||
*/
|
*/
|
||||||
const std::string Exception::UNKNOWNFILENAME = "<unknown>";
|
const string Exception::UNKNOWNFILENAME = "<unknown>";
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \deprecated Use SourceLine::isValid() instead.
|
* \deprecated Use SourceLine::isValid() instead.
|
||||||
@@ -19,7 +19,7 @@ const long Exception::UNKNOWNLINENUMBER = -1;
|
|||||||
|
|
||||||
/// Construct the exception
|
/// Construct the exception
|
||||||
Exception::Exception( const Exception &other ) :
|
Exception::Exception( const Exception &other ) :
|
||||||
std::exception( other )
|
exception( other )
|
||||||
{
|
{
|
||||||
m_message = other.m_message;
|
m_message = other.m_message;
|
||||||
m_sourceLine = other.m_sourceLine;
|
m_sourceLine = other.m_sourceLine;
|
||||||
@@ -29,7 +29,7 @@ Exception::Exception( const Exception &other ) :
|
|||||||
/*!
|
/*!
|
||||||
* \deprecated Use other constructor instead.
|
* \deprecated Use other constructor instead.
|
||||||
*/
|
*/
|
||||||
Exception::Exception( std::string message,
|
Exception::Exception( string message,
|
||||||
SourceLine sourceLine ) :
|
SourceLine sourceLine ) :
|
||||||
m_message( message ),
|
m_message( message ),
|
||||||
m_sourceLine( sourceLine )
|
m_sourceLine( sourceLine )
|
||||||
@@ -41,9 +41,9 @@ Exception::Exception( std::string message,
|
|||||||
/*!
|
/*!
|
||||||
* \deprecated Use other constructor instead.
|
* \deprecated Use other constructor instead.
|
||||||
*/
|
*/
|
||||||
Exception::Exception( std::string message,
|
Exception::Exception( string message,
|
||||||
long lineNumber,
|
long lineNumber,
|
||||||
std::string fileName ) :
|
string fileName ) :
|
||||||
m_message( message ),
|
m_message( message ),
|
||||||
m_sourceLine( fileName, lineNumber )
|
m_sourceLine( fileName, lineNumber )
|
||||||
{
|
{
|
||||||
@@ -63,7 +63,7 @@ Exception::operator =( const Exception& other )
|
|||||||
{
|
{
|
||||||
// Don't call superclass operator =(). VC++ STL implementation
|
// Don't call superclass operator =(). VC++ STL implementation
|
||||||
// has a bug. It calls the destructor and copy constructor of
|
// 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);
|
// SuperClass::operator =(other);
|
||||||
|
|
||||||
if ( &other != this )
|
if ( &other != this )
|
||||||
@@ -102,7 +102,7 @@ Exception::lineNumber() const
|
|||||||
|
|
||||||
|
|
||||||
/// The file in which the error occurred
|
/// The file in which the error occurred
|
||||||
std::string
|
string
|
||||||
Exception::fileName() const
|
Exception::fileName() const
|
||||||
{
|
{
|
||||||
return m_sourceLine.isValid() ? m_sourceLine.fileName() :
|
return m_sourceLine.isValid() ? m_sourceLine.fileName() :
|
||||||
|
|||||||
@@ -3,10 +3,10 @@
|
|||||||
namespace CppUnit {
|
namespace CppUnit {
|
||||||
|
|
||||||
|
|
||||||
NotEqualException::NotEqualException( std::string expected,
|
NotEqualException::NotEqualException( string expected,
|
||||||
std::string actual,
|
string actual,
|
||||||
SourceLine sourceLine ,
|
SourceLine sourceLine ,
|
||||||
std::string additionalMessage ) :
|
string additionalMessage ) :
|
||||||
Exception( "Expected: " + expected +
|
Exception( "Expected: " + expected +
|
||||||
", but was: " + actual +
|
", but was: " + actual +
|
||||||
"." + additionalMessage ,
|
"." + additionalMessage ,
|
||||||
@@ -22,10 +22,10 @@ NotEqualException::NotEqualException( std::string expected,
|
|||||||
/*!
|
/*!
|
||||||
* \deprecated Use other constructor instead.
|
* \deprecated Use other constructor instead.
|
||||||
*/
|
*/
|
||||||
NotEqualException::NotEqualException( std::string expected,
|
NotEqualException::NotEqualException( string expected,
|
||||||
std::string actual,
|
string actual,
|
||||||
long lineNumber,
|
long lineNumber,
|
||||||
std::string fileName ) :
|
string fileName ) :
|
||||||
Exception( "Expected: " + expected + ", but was: " + actual,
|
Exception( "Expected: " + expected + ", but was: " + actual,
|
||||||
lineNumber,
|
lineNumber,
|
||||||
fileName ),
|
fileName ),
|
||||||
@@ -87,21 +87,21 @@ NotEqualException::type()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::string
|
string
|
||||||
NotEqualException::expectedValue() const
|
NotEqualException::expectedValue() const
|
||||||
{
|
{
|
||||||
return m_expected;
|
return m_expected;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::string
|
string
|
||||||
NotEqualException::actualValue() const
|
NotEqualException::actualValue() const
|
||||||
{
|
{
|
||||||
return m_actual;
|
return m_actual;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::string
|
string
|
||||||
NotEqualException::additionalMessage() const
|
NotEqualException::additionalMessage() const
|
||||||
{
|
{
|
||||||
return m_additionalMessage;
|
return m_additionalMessage;
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ RepeatedTest::countTestCases() const
|
|||||||
|
|
||||||
|
|
||||||
// Returns the name of the test instance.
|
// Returns the name of the test instance.
|
||||||
std::string
|
string
|
||||||
RepeatedTest::toString() const
|
RepeatedTest::toString() const
|
||||||
{
|
{
|
||||||
return TestDecorator::toString () + " (repeated)";
|
return TestDecorator::toString () + " (repeated)";
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ SourceLine::SourceLine() :
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SourceLine::SourceLine( const std::string &fileName,
|
SourceLine::SourceLine( const string &fileName,
|
||||||
int lineNumber ) :
|
int lineNumber ) :
|
||||||
m_fileName( fileName ),
|
m_fileName( fileName ),
|
||||||
m_lineNumber( lineNumber )
|
m_lineNumber( lineNumber )
|
||||||
@@ -37,7 +37,7 @@ SourceLine::lineNumber() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::string
|
string
|
||||||
SourceLine::fileName() const
|
SourceLine::fileName() const
|
||||||
{
|
{
|
||||||
return m_fileName;
|
return m_fileName;
|
||||||
|
|||||||
@@ -15,9 +15,9 @@ namespace CppUnit {
|
|||||||
/// Check for a failed general assertion
|
/// Check for a failed general assertion
|
||||||
void
|
void
|
||||||
TestAssert::assertImplementation( bool condition,
|
TestAssert::assertImplementation( bool condition,
|
||||||
std::string conditionExpression,
|
string conditionExpression,
|
||||||
long lineNumber,
|
long lineNumber,
|
||||||
std::string fileName )
|
string fileName )
|
||||||
{
|
{
|
||||||
Asserter::failIf( condition,
|
Asserter::failIf( condition,
|
||||||
conditionExpression,
|
conditionExpression,
|
||||||
@@ -27,10 +27,10 @@ TestAssert::assertImplementation( bool condition,
|
|||||||
|
|
||||||
/// Reports failed equality
|
/// Reports failed equality
|
||||||
void
|
void
|
||||||
TestAssert::assertNotEqualImplementation( std::string expected,
|
TestAssert::assertNotEqualImplementation( string expected,
|
||||||
std::string actual,
|
string actual,
|
||||||
long lineNumber,
|
long lineNumber,
|
||||||
std::string fileName )
|
string fileName )
|
||||||
{
|
{
|
||||||
Asserter::failNotEqual( expected,
|
Asserter::failNotEqual( expected,
|
||||||
actual,
|
actual,
|
||||||
@@ -44,7 +44,7 @@ TestAssert::assertEquals( double expected,
|
|||||||
double actual,
|
double actual,
|
||||||
double delta,
|
double delta,
|
||||||
long lineNumber,
|
long lineNumber,
|
||||||
std::string fileName )
|
string fileName )
|
||||||
{
|
{
|
||||||
if (fabs (expected - actual) > delta)
|
if (fabs (expected - actual) > delta)
|
||||||
assertNotEqualImplementation( assertion_traits<double>::toString(expected),
|
assertNotEqualImplementation( assertion_traits<double>::toString(expected),
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ TestCase::run( TestResult *result )
|
|||||||
Exception *copy = e.clone();
|
Exception *copy = e.clone();
|
||||||
result->addFailure( this, copy );
|
result->addFailure( this, copy );
|
||||||
}
|
}
|
||||||
catch ( std::exception &e ) {
|
catch ( exception &e ) {
|
||||||
result->addError( this, new Exception( e.what() ) );
|
result->addError( this, new Exception( e.what() ) );
|
||||||
}
|
}
|
||||||
catch (...) {
|
catch (...) {
|
||||||
@@ -77,7 +77,7 @@ TestCase::runTest()
|
|||||||
/** Constructs a test case.
|
/** Constructs a test case.
|
||||||
* \param name the name of the TestCase.
|
* \param name the name of the TestCase.
|
||||||
**/
|
**/
|
||||||
TestCase::TestCase( std::string name )
|
TestCase::TestCase( string name )
|
||||||
: m_name(name)
|
: m_name(name)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -108,7 +108,7 @@ TestCase::countTestCases() const
|
|||||||
|
|
||||||
|
|
||||||
/// Returns the name of the test case
|
/// Returns the name of the test case
|
||||||
std::string
|
string
|
||||||
TestCase::getName() const
|
TestCase::getName() const
|
||||||
{
|
{
|
||||||
return m_name;
|
return m_name;
|
||||||
@@ -116,13 +116,13 @@ TestCase::getName() const
|
|||||||
|
|
||||||
|
|
||||||
/// Returns the name of the test case instance
|
/// Returns the name of the test case instance
|
||||||
std::string
|
string
|
||||||
TestCase::toString() const
|
TestCase::toString() const
|
||||||
{
|
{
|
||||||
std::string className;
|
string className;
|
||||||
|
|
||||||
#if CPPUNIT_USE_TYPEINFO_NAME
|
#if CPPUNIT_USE_TYPEINFO_NAME
|
||||||
const std::type_info& thisClass = typeid( *this );
|
const type_info& thisClass = typeid( *this );
|
||||||
className = thisClass.name();
|
className = thisClass.name();
|
||||||
#else
|
#else
|
||||||
className = "TestCase";
|
className = "TestCase";
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include <cppunit/extensions/TestFactoryRegistry.h>
|
#include <cppunit/extensions/TestFactoryRegistry.h>
|
||||||
#include <cppunit/TestSuite.h>
|
#include <cppunit/TestSuite.h>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
|
||||||
#if CPPUNIT_USE_TYPEINFO_NAME
|
#if CPPUNIT_USE_TYPEINFO_NAME
|
||||||
@@ -26,17 +27,17 @@ public:
|
|||||||
|
|
||||||
static NamedRegistries &getInstance();
|
static NamedRegistries &getInstance();
|
||||||
|
|
||||||
TestFactoryRegistry &getRegistry( std::string name );
|
TestFactoryRegistry &getRegistry( string name );
|
||||||
|
|
||||||
void wasDestroyed( TestFactory *factory );
|
void wasDestroyed( TestFactory *factory );
|
||||||
|
|
||||||
bool needDestroy( TestFactory *factory );
|
bool needDestroy( TestFactory *factory );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef std::map<std::string, TestFactoryRegistry *> Registries;
|
typedef map<string, TestFactoryRegistry *> Registries;
|
||||||
Registries m_registries;
|
Registries m_registries;
|
||||||
|
|
||||||
typedef std::set<TestFactory *> Factories;
|
typedef set<TestFactory *> Factories;
|
||||||
Factories m_factoriesToDestroy;
|
Factories m_factoriesToDestroy;
|
||||||
Factories m_destroyedFactories;
|
Factories m_destroyedFactories;
|
||||||
};
|
};
|
||||||
@@ -63,13 +64,24 @@ NamedRegistries::getInstance()
|
|||||||
|
|
||||||
|
|
||||||
TestFactoryRegistry &
|
TestFactoryRegistry &
|
||||||
NamedRegistries::getRegistry( std::string name )
|
NamedRegistries::getRegistry( string name )
|
||||||
{
|
{
|
||||||
Registries::const_iterator foundIt = m_registries.find( name );
|
Registries::const_iterator foundIt = m_registries.find( name );
|
||||||
if ( foundIt == m_registries.end() )
|
if ( foundIt == m_registries.end() )
|
||||||
{
|
{
|
||||||
TestFactoryRegistry *factory = new TestFactoryRegistry( name );
|
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 ) );
|
m_registries.insert( std::make_pair( name, factory ) );
|
||||||
|
#endif
|
||||||
m_factoriesToDestroy.insert( factory );
|
m_factoriesToDestroy.insert( factory );
|
||||||
return *factory;
|
return *factory;
|
||||||
}
|
}
|
||||||
@@ -93,7 +105,7 @@ NamedRegistries::needDestroy( TestFactory *factory )
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
TestFactoryRegistry::TestFactoryRegistry( std::string name ) :
|
TestFactoryRegistry::TestFactoryRegistry( string name ) :
|
||||||
m_name( name )
|
m_name( name )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -125,14 +137,14 @@ TestFactoryRegistry::getRegistry()
|
|||||||
|
|
||||||
|
|
||||||
TestFactoryRegistry &
|
TestFactoryRegistry &
|
||||||
TestFactoryRegistry::getRegistry( const std::string &name )
|
TestFactoryRegistry::getRegistry( const string &name )
|
||||||
{
|
{
|
||||||
return NamedRegistries::getInstance().getRegistry( name );
|
return NamedRegistries::getInstance().getRegistry( name );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TestFactoryRegistry::registerFactory( const std::string &name,
|
TestFactoryRegistry::registerFactory( const string &name,
|
||||||
TestFactory *factory )
|
TestFactory *factory )
|
||||||
{
|
{
|
||||||
m_factories[name] = factory;
|
m_factories[name] = factory;
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ TestFailure::isError() const
|
|||||||
|
|
||||||
|
|
||||||
/// Gets the name of the failed test.
|
/// Gets the name of the failed test.
|
||||||
std::string
|
string
|
||||||
TestFailure::failedTestName() const
|
TestFailure::failedTestName() const
|
||||||
{
|
{
|
||||||
return m_failedTest->getName();
|
return m_failedTest->getName();
|
||||||
@@ -61,7 +61,7 @@ TestFailure::failedTestName() const
|
|||||||
|
|
||||||
|
|
||||||
/// Returns a short description of the failure.
|
/// Returns a short description of the failure.
|
||||||
std::string
|
string
|
||||||
TestFailure::toString() const
|
TestFailure::toString() const
|
||||||
{
|
{
|
||||||
return m_failedTest->toString() + ": " + m_thrownException->what();
|
return m_failedTest->toString() + ": " + m_thrownException->what();
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ void
|
|||||||
TestResult::removeListener ( TestListener *listener )
|
TestResult::removeListener ( TestListener *listener )
|
||||||
{
|
{
|
||||||
ExclusiveZone zone( m_syncObject );
|
ExclusiveZone zone( m_syncObject );
|
||||||
m_listeners.erase( std::remove( m_listeners.begin(),
|
m_listeners.erase( remove( m_listeners.begin(),
|
||||||
m_listeners.end(),
|
m_listeners.end(),
|
||||||
listener ),
|
listener ),
|
||||||
m_listeners.end());
|
m_listeners.end());
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ TestRunner::TestRunner( Outputter *outputter )
|
|||||||
, m_outputter( outputter )
|
, m_outputter( outputter )
|
||||||
{
|
{
|
||||||
if ( !m_outputter )
|
if ( !m_outputter )
|
||||||
m_outputter = new TextOutputter( m_result, std::cout );
|
m_outputter = new TextOutputter( m_result, cout );
|
||||||
m_eventManager->addListener( m_result );
|
m_eventManager->addListener( m_result );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,7 +61,7 @@ TestRunner::addTest( Test *test )
|
|||||||
* failed or was not found.
|
* failed or was not found.
|
||||||
*/
|
*/
|
||||||
bool
|
bool
|
||||||
TestRunner::run( std::string testName,
|
TestRunner::run( string testName,
|
||||||
bool doWait,
|
bool doWait,
|
||||||
bool doPrintResult,
|
bool doPrintResult,
|
||||||
bool doPrintProgress )
|
bool doPrintProgress )
|
||||||
@@ -74,7 +74,7 @@ TestRunner::run( std::string testName,
|
|||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
TestRunner::runTestByName( std::string testName,
|
TestRunner::runTestByName( string testName,
|
||||||
bool doPrintProgress )
|
bool doPrintProgress )
|
||||||
{
|
{
|
||||||
if ( testName.empty() )
|
if ( testName.empty() )
|
||||||
@@ -84,7 +84,7 @@ TestRunner::runTestByName( std::string testName,
|
|||||||
if ( test != NULL )
|
if ( test != NULL )
|
||||||
return runTest( test, doPrintProgress );
|
return runTest( test, doPrintProgress );
|
||||||
|
|
||||||
std::cout << "Test " << testName << " not found." << std::endl;
|
cout << "Test " << testName << " not found." << endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,8 +94,8 @@ TestRunner::wait( bool doWait )
|
|||||||
{
|
{
|
||||||
if ( doWait )
|
if ( doWait )
|
||||||
{
|
{
|
||||||
std::cout << "<RETURN> to continue" << std::endl;
|
cout << "<RETURN> to continue" << endl;
|
||||||
std::cin.get ();
|
cin.get ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,16 +103,16 @@ TestRunner::wait( bool doWait )
|
|||||||
void
|
void
|
||||||
TestRunner::printResult( bool doPrintResult )
|
TestRunner::printResult( bool doPrintResult )
|
||||||
{
|
{
|
||||||
std::cout << std::endl;
|
cout << endl;
|
||||||
if ( doPrintResult )
|
if ( doPrintResult )
|
||||||
m_outputter->write();
|
m_outputter->write();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Test *
|
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 != m_suite->getTests().end();
|
||||||
++it )
|
++it )
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
namespace CppUnit {
|
namespace CppUnit {
|
||||||
|
|
||||||
/// Default constructor
|
/// Default constructor
|
||||||
TestSuite::TestSuite( std::string name )
|
TestSuite::TestSuite( string name )
|
||||||
: m_name( name )
|
: m_name( name )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -21,7 +21,7 @@ TestSuite::~TestSuite()
|
|||||||
void
|
void
|
||||||
TestSuite::deleteContents()
|
TestSuite::deleteContents()
|
||||||
{
|
{
|
||||||
for ( std::vector<Test *>::iterator it = m_tests.begin();
|
for ( vector<Test *>::iterator it = m_tests.begin();
|
||||||
it != m_tests.end();
|
it != m_tests.end();
|
||||||
++it)
|
++it)
|
||||||
delete *it;
|
delete *it;
|
||||||
@@ -33,7 +33,7 @@ TestSuite::deleteContents()
|
|||||||
void
|
void
|
||||||
TestSuite::run( TestResult *result )
|
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 != m_tests.end();
|
||||||
++it )
|
++it )
|
||||||
{
|
{
|
||||||
@@ -52,7 +52,7 @@ TestSuite::countTestCases() const
|
|||||||
{
|
{
|
||||||
int count = 0;
|
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 != m_tests.end();
|
||||||
++it )
|
++it )
|
||||||
count += (*it)->countTestCases();
|
count += (*it)->countTestCases();
|
||||||
@@ -70,7 +70,7 @@ TestSuite::addTest( Test *test )
|
|||||||
|
|
||||||
|
|
||||||
/// Returns a string representation of the test suite.
|
/// Returns a string representation of the test suite.
|
||||||
std::string
|
string
|
||||||
TestSuite::toString() const
|
TestSuite::toString() const
|
||||||
{
|
{
|
||||||
return "suite " + getName();
|
return "suite " + getName();
|
||||||
@@ -78,14 +78,14 @@ TestSuite::toString() const
|
|||||||
|
|
||||||
|
|
||||||
/// Returns the name of the test suite.
|
/// Returns the name of the test suite.
|
||||||
std::string
|
string
|
||||||
TestSuite::getName() const
|
TestSuite::getName() const
|
||||||
{
|
{
|
||||||
return m_name;
|
return m_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const std::vector<Test *> &
|
const vector<Test *> &
|
||||||
TestSuite::getTests() const
|
TestSuite::getTests() const
|
||||||
{
|
{
|
||||||
return m_tests;
|
return m_tests;
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ namespace CppUnit
|
|||||||
|
|
||||||
|
|
||||||
TextOutputter::TextOutputter( TestResultCollector *result,
|
TextOutputter::TextOutputter( TestResultCollector *result,
|
||||||
std::ostream &stream )
|
ostream &stream )
|
||||||
: m_result( result )
|
: m_result( result )
|
||||||
, m_stream( stream )
|
, m_stream( stream )
|
||||||
{
|
{
|
||||||
@@ -26,9 +26,9 @@ void
|
|||||||
TextOutputter::write()
|
TextOutputter::write()
|
||||||
{
|
{
|
||||||
printHeader();
|
printHeader();
|
||||||
m_stream << std::endl;
|
m_stream << endl;
|
||||||
printFailures();
|
printFailures();
|
||||||
m_stream << std::endl;
|
m_stream << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -39,7 +39,7 @@ TextOutputter::printFailures()
|
|||||||
int failureNumber = 1;
|
int failureNumber = 1;
|
||||||
while ( itFailure != m_result->failures().end() )
|
while ( itFailure != m_result->failures().end() )
|
||||||
{
|
{
|
||||||
m_stream << std::endl;
|
m_stream << endl;
|
||||||
printFailure( *itFailure++, failureNumber++ );
|
printFailure( *itFailure++, failureNumber++ );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -56,9 +56,9 @@ TextOutputter::printFailure( TestFailure *failure,
|
|||||||
printFailureType( failure );
|
printFailureType( failure );
|
||||||
m_stream << ' ';
|
m_stream << ' ';
|
||||||
printFailureLocation( failure->sourceLine() );
|
printFailureLocation( failure->sourceLine() );
|
||||||
m_stream << std::endl;
|
m_stream << endl;
|
||||||
printFailureDetail( failure->thrownException() );
|
printFailureDetail( failure->thrownException() );
|
||||||
m_stream << std::endl;
|
m_stream << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -102,12 +102,12 @@ TextOutputter::printFailureDetail( Exception *thrownException )
|
|||||||
if ( thrownException->isInstanceOf( NotEqualException::type() ) )
|
if ( thrownException->isInstanceOf( NotEqualException::type() ) )
|
||||||
{
|
{
|
||||||
NotEqualException *e = (NotEqualException*)thrownException;
|
NotEqualException *e = (NotEqualException*)thrownException;
|
||||||
m_stream << "expected: " << e->expectedValue() << std::endl
|
m_stream << "expected: " << e->expectedValue() << endl
|
||||||
<< "but was: " << e->actualValue();
|
<< "but was: " << e->actualValue();
|
||||||
if ( !e->additionalMessage().empty() )
|
if ( !e->additionalMessage().empty() )
|
||||||
{
|
{
|
||||||
m_stream << std::endl;
|
m_stream << endl;
|
||||||
m_stream << "additional message:" << std::endl
|
m_stream << "additional message:" << endl
|
||||||
<< e->additionalMessage();
|
<< e->additionalMessage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -122,11 +122,11 @@ void
|
|||||||
TextOutputter::printHeader()
|
TextOutputter::printHeader()
|
||||||
{
|
{
|
||||||
if ( m_result->wasSuccessful() )
|
if ( m_result->wasSuccessful() )
|
||||||
m_stream << std::endl << "OK (" << m_result->runTests () << " tests)"
|
m_stream << endl << "OK (" << m_result->runTests () << " tests)"
|
||||||
<< std::endl;
|
<< endl;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_stream << std::endl;
|
m_stream << endl;
|
||||||
printFailureWarning();
|
printFailureWarning();
|
||||||
printStatistics();
|
printStatistics();
|
||||||
}
|
}
|
||||||
@@ -136,19 +136,19 @@ TextOutputter::printHeader()
|
|||||||
void
|
void
|
||||||
TextOutputter::printFailureWarning()
|
TextOutputter::printFailureWarning()
|
||||||
{
|
{
|
||||||
m_stream << "!!!FAILURES!!!" << std::endl;
|
m_stream << "!!!FAILURES!!!" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TextOutputter::printStatistics()
|
TextOutputter::printStatistics()
|
||||||
{
|
{
|
||||||
m_stream << "Test Results:" << std::endl;
|
m_stream << "Test Results:" << endl;
|
||||||
|
|
||||||
m_stream << "Run: " << m_result->runTests()
|
m_stream << "Run: " << m_result->runTests()
|
||||||
<< " Failures: " << m_result->testFailures()
|
<< " Failures: " << m_result->testFailures()
|
||||||
<< " Errors: " << m_result->testErrors()
|
<< " Errors: " << m_result->testErrors()
|
||||||
<< std::endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -20,24 +20,24 @@ TextTestProgressListener::~TextTestProgressListener()
|
|||||||
void
|
void
|
||||||
TextTestProgressListener::startTest( Test *test )
|
TextTestProgressListener::startTest( Test *test )
|
||||||
{
|
{
|
||||||
std::cerr << ".";
|
cerr << ".";
|
||||||
std::cerr.flush();
|
cerr.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TextTestProgressListener::addFailure( const TestFailure &failure )
|
TextTestProgressListener::addFailure( const TestFailure &failure )
|
||||||
{
|
{
|
||||||
std::cerr << ( failure.isError() ? "E" : "F" );
|
cerr << ( failure.isError() ? "E" : "F" );
|
||||||
std::cerr.flush();
|
cerr.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TextTestProgressListener::done()
|
TextTestProgressListener::done()
|
||||||
{
|
{
|
||||||
std::cerr << std::endl;
|
cerr << endl;
|
||||||
std::cerr.flush();
|
cerr.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace CppUnit
|
} // namespace CppUnit
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ void
|
|||||||
TextTestResult::addFailure( const TestFailure &failure )
|
TextTestResult::addFailure( const TestFailure &failure )
|
||||||
{
|
{
|
||||||
TestResultCollector::addFailure( failure );
|
TestResultCollector::addFailure( failure );
|
||||||
std::cerr << ( failure.isError() ? "E" : "F" );
|
cerr << ( failure.isError() ? "E" : "F" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -34,18 +34,18 @@ void
|
|||||||
TextTestResult::startTest( Test *test )
|
TextTestResult::startTest( Test *test )
|
||||||
{
|
{
|
||||||
TestResultCollector::startTest (test);
|
TestResultCollector::startTest (test);
|
||||||
std::cerr << ".";
|
cerr << ".";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TextTestResult::printFailures( std::ostream &stream )
|
TextTestResult::printFailures( ostream &stream )
|
||||||
{
|
{
|
||||||
TestFailures::const_iterator itFailure = failures().begin();
|
TestFailures::const_iterator itFailure = failures().begin();
|
||||||
int failureNumber = 1;
|
int failureNumber = 1;
|
||||||
while ( itFailure != failures().end() )
|
while ( itFailure != failures().end() )
|
||||||
{
|
{
|
||||||
stream << std::endl;
|
stream << endl;
|
||||||
printFailure( *itFailure++, failureNumber++, stream );
|
printFailure( *itFailure++, failureNumber++, stream );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -54,7 +54,7 @@ TextTestResult::printFailures( std::ostream &stream )
|
|||||||
void
|
void
|
||||||
TextTestResult::printFailure( TestFailure *failure,
|
TextTestResult::printFailure( TestFailure *failure,
|
||||||
int failureNumber,
|
int failureNumber,
|
||||||
std::ostream &stream )
|
ostream &stream )
|
||||||
{
|
{
|
||||||
printFailureListMark( failureNumber, stream );
|
printFailureListMark( failureNumber, stream );
|
||||||
stream << ' ';
|
stream << ' ';
|
||||||
@@ -63,15 +63,15 @@ TextTestResult::printFailure( TestFailure *failure,
|
|||||||
printFailureType( failure, stream );
|
printFailureType( failure, stream );
|
||||||
stream << ' ';
|
stream << ' ';
|
||||||
printFailureLocation( failure->sourceLine(), stream );
|
printFailureLocation( failure->sourceLine(), stream );
|
||||||
stream << std::endl;
|
stream << endl;
|
||||||
printFailureDetail( failure->thrownException(), stream );
|
printFailureDetail( failure->thrownException(), stream );
|
||||||
stream << std::endl;
|
stream << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TextTestResult::printFailureListMark( int failureNumber,
|
TextTestResult::printFailureListMark( int failureNumber,
|
||||||
std::ostream &stream )
|
ostream &stream )
|
||||||
{
|
{
|
||||||
stream << failureNumber << ")";
|
stream << failureNumber << ")";
|
||||||
}
|
}
|
||||||
@@ -79,7 +79,7 @@ TextTestResult::printFailureListMark( int failureNumber,
|
|||||||
|
|
||||||
void
|
void
|
||||||
TextTestResult::printFailureTestName( TestFailure *failure,
|
TextTestResult::printFailureTestName( TestFailure *failure,
|
||||||
std::ostream &stream )
|
ostream &stream )
|
||||||
{
|
{
|
||||||
stream << "test: " << failure->failedTest()->getName();
|
stream << "test: " << failure->failedTest()->getName();
|
||||||
}
|
}
|
||||||
@@ -87,7 +87,7 @@ TextTestResult::printFailureTestName( TestFailure *failure,
|
|||||||
|
|
||||||
void
|
void
|
||||||
TextTestResult::printFailureType( TestFailure *failure,
|
TextTestResult::printFailureType( TestFailure *failure,
|
||||||
std::ostream &stream )
|
ostream &stream )
|
||||||
{
|
{
|
||||||
stream << "("
|
stream << "("
|
||||||
<< (failure->isError() ? "E" : "F")
|
<< (failure->isError() ? "E" : "F")
|
||||||
@@ -97,7 +97,7 @@ TextTestResult::printFailureType( TestFailure *failure,
|
|||||||
|
|
||||||
void
|
void
|
||||||
TextTestResult::printFailureLocation( SourceLine sourceLine,
|
TextTestResult::printFailureLocation( SourceLine sourceLine,
|
||||||
std::ostream &stream )
|
ostream &stream )
|
||||||
{
|
{
|
||||||
if ( !sourceLine.isValid() )
|
if ( !sourceLine.isValid() )
|
||||||
return;
|
return;
|
||||||
@@ -109,17 +109,17 @@ TextTestResult::printFailureLocation( SourceLine sourceLine,
|
|||||||
|
|
||||||
void
|
void
|
||||||
TextTestResult::printFailureDetail( Exception *thrownException,
|
TextTestResult::printFailureDetail( Exception *thrownException,
|
||||||
std::ostream &stream )
|
ostream &stream )
|
||||||
{
|
{
|
||||||
if ( thrownException->isInstanceOf( NotEqualException::type() ) )
|
if ( thrownException->isInstanceOf( NotEqualException::type() ) )
|
||||||
{
|
{
|
||||||
NotEqualException *e = (NotEqualException*)thrownException;
|
NotEqualException *e = (NotEqualException*)thrownException;
|
||||||
stream << "expected: " << e->expectedValue() << std::endl
|
stream << "expected: " << e->expectedValue() << endl
|
||||||
<< "but was: " << e->actualValue();
|
<< "but was: " << e->actualValue();
|
||||||
if ( !e->additionalMessage().empty() )
|
if ( !e->additionalMessage().empty() )
|
||||||
{
|
{
|
||||||
stream << std::endl;
|
stream << endl;
|
||||||
stream << "additional message:" << std::endl
|
stream << "additional message:" << endl
|
||||||
<< e->additionalMessage();
|
<< e->additionalMessage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -131,23 +131,23 @@ TextTestResult::printFailureDetail( Exception *thrownException,
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TextTestResult::print( std::ostream& stream )
|
TextTestResult::print( ostream& stream )
|
||||||
{
|
{
|
||||||
printHeader( stream );
|
printHeader( stream );
|
||||||
stream << std::endl;
|
stream << endl;
|
||||||
printFailures( stream );
|
printFailures( stream );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TextTestResult::printHeader( std::ostream &stream )
|
TextTestResult::printHeader( ostream &stream )
|
||||||
{
|
{
|
||||||
if (wasSuccessful ())
|
if (wasSuccessful ())
|
||||||
stream << std::endl << "OK (" << runTests () << " tests)"
|
stream << endl << "OK (" << runTests () << " tests)"
|
||||||
<< std::endl;
|
<< endl;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
stream << std::endl;
|
stream << endl;
|
||||||
printFailureWarning( stream );
|
printFailureWarning( stream );
|
||||||
printStatistics( stream );
|
printStatistics( stream );
|
||||||
}
|
}
|
||||||
@@ -155,26 +155,26 @@ TextTestResult::printHeader( std::ostream &stream )
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TextTestResult::printFailureWarning( std::ostream &stream )
|
TextTestResult::printFailureWarning( ostream &stream )
|
||||||
{
|
{
|
||||||
stream << "!!!FAILURES!!!" << std::endl;
|
stream << "!!!FAILURES!!!" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TextTestResult::printStatistics( std::ostream &stream )
|
TextTestResult::printStatistics( ostream &stream )
|
||||||
{
|
{
|
||||||
stream << "Test Results:" << std::endl;
|
stream << "Test Results:" << endl;
|
||||||
|
|
||||||
stream << "Run: " << runTests()
|
stream << "Run: " << runTests()
|
||||||
<< " Failures: " << testFailures()
|
<< " Failures: " << testFailures()
|
||||||
<< " Errors: " << testErrors()
|
<< " Errors: " << testErrors()
|
||||||
<< std::endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::ostream &
|
ostream &
|
||||||
operator <<( std::ostream &stream,
|
operator <<( ostream &stream,
|
||||||
TextTestResult &result )
|
TextTestResult &result )
|
||||||
{
|
{
|
||||||
result.print (stream); return stream;
|
result.print (stream); return stream;
|
||||||
|
|||||||
@@ -8,11 +8,11 @@
|
|||||||
|
|
||||||
namespace CppUnit {
|
namespace CppUnit {
|
||||||
|
|
||||||
std::string
|
string
|
||||||
TypeInfoHelper::getClassName( const std::type_info &info )
|
TypeInfoHelper::getClassName( const type_info &info )
|
||||||
{
|
{
|
||||||
static std::string classPrefix( "class " );
|
static const string classPrefix( "class " );
|
||||||
std::string name( info.name() );
|
string name( info.name() );
|
||||||
|
|
||||||
bool has_class_prefix = 0 ==
|
bool has_class_prefix = 0 ==
|
||||||
#if CPPUNIT_FUNC_STRING_COMPARE_STRING_FIRST
|
#if CPPUNIT_FUNC_STRING_COMPARE_STRING_FIRST
|
||||||
|
|||||||
@@ -14,15 +14,15 @@ namespace CppUnit
|
|||||||
// //////////////////////////////////////////////////////////////////
|
// //////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
XmlOutputter::Node::Node( std::string elementName,
|
XmlOutputter::Node::Node( string elementName,
|
||||||
std::string content ) :
|
string content ) :
|
||||||
m_name( elementName ),
|
m_name( elementName ),
|
||||||
m_content( content )
|
m_content( content )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
XmlOutputter::Node::Node( std::string elementName,
|
XmlOutputter::Node::Node( string elementName,
|
||||||
int numericContent ) :
|
int numericContent ) :
|
||||||
m_name( elementName )
|
m_name( elementName )
|
||||||
{
|
{
|
||||||
@@ -39,15 +39,15 @@ XmlOutputter::Node::~Node()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
XmlOutputter::Node::addAttribute( std::string attributeName,
|
XmlOutputter::Node::addAttribute( string attributeName,
|
||||||
std::string value )
|
string value )
|
||||||
{
|
{
|
||||||
m_attributes.push_back( Attribute( attributeName, value ) );
|
m_attributes.push_back( Attribute( attributeName, value ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
XmlOutputter::Node::addAttribute( std::string attributeName,
|
XmlOutputter::Node::addAttribute( string attributeName,
|
||||||
int numericValue )
|
int numericValue )
|
||||||
{
|
{
|
||||||
addAttribute( attributeName, asString( numericValue ) );
|
addAttribute( attributeName, asString( numericValue ) );
|
||||||
@@ -61,10 +61,10 @@ XmlOutputter::Node::addNode( Node *node )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::string
|
string
|
||||||
XmlOutputter::Node::toString() const
|
XmlOutputter::Node::toString() const
|
||||||
{
|
{
|
||||||
std::string element = "<";
|
string element = "<";
|
||||||
element += m_name;
|
element += m_name;
|
||||||
element += " ";
|
element += " ";
|
||||||
element += attributesAsString();
|
element += attributesAsString();
|
||||||
@@ -87,10 +87,10 @@ XmlOutputter::Node::toString() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::string
|
string
|
||||||
XmlOutputter::Node::attributesAsString() const
|
XmlOutputter::Node::attributesAsString() const
|
||||||
{
|
{
|
||||||
std::string attributes;
|
string attributes;
|
||||||
Attributes::const_iterator itAttribute = m_attributes.begin();
|
Attributes::const_iterator itAttribute = m_attributes.begin();
|
||||||
while ( itAttribute != m_attributes.end() )
|
while ( itAttribute != m_attributes.end() )
|
||||||
{
|
{
|
||||||
@@ -104,10 +104,10 @@ XmlOutputter::Node::attributesAsString() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::string
|
string
|
||||||
XmlOutputter::Node::escape( std::string value ) const
|
XmlOutputter::Node::escape( string value ) const
|
||||||
{
|
{
|
||||||
std::string escaped;
|
string escaped;
|
||||||
for ( int index =0; index < (int)value.length(); ++index )
|
for ( int index =0; index < (int)value.length(); ++index )
|
||||||
{
|
{
|
||||||
char c = value[index ];
|
char c = value[index ];
|
||||||
@@ -137,7 +137,7 @@ XmlOutputter::Node::escape( std::string value ) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
// should be somewhere else... Future CppUnit::String ?
|
// should be somewhere else... Future CppUnit::String ?
|
||||||
std::string
|
string
|
||||||
XmlOutputter::Node::asString( int value )
|
XmlOutputter::Node::asString( int value )
|
||||||
{
|
{
|
||||||
OStringStream stream;
|
OStringStream stream;
|
||||||
@@ -152,8 +152,8 @@ XmlOutputter::Node::asString( int value )
|
|||||||
// //////////////////////////////////////////////////////////////////
|
// //////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
XmlOutputter::XmlOutputter( TestResultCollector *result,
|
XmlOutputter::XmlOutputter( TestResultCollector *result,
|
||||||
std::ostream &stream,
|
ostream &stream,
|
||||||
std::string encoding ) :
|
string encoding ) :
|
||||||
m_result( result ),
|
m_result( result ),
|
||||||
m_stream( stream ),
|
m_stream( stream ),
|
||||||
m_encoding( encoding )
|
m_encoding( encoding )
|
||||||
@@ -179,7 +179,7 @@ XmlOutputter::writeProlog()
|
|||||||
{
|
{
|
||||||
m_stream << "<?xml version=\"1.0\" "
|
m_stream << "<?xml version=\"1.0\" "
|
||||||
"encoding='" << m_encoding << "' standalone='yes' ?>"
|
"encoding='" << m_encoding << "' standalone='yes' ?>"
|
||||||
<< std::endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -216,7 +216,12 @@ XmlOutputter::fillFailedTestsMap( FailedTests &failedTests )
|
|||||||
while ( itFailure != failures.end() )
|
while ( itFailure != failures.end() )
|
||||||
{
|
{
|
||||||
TestFailure *failure = *itFailure++;
|
TestFailure *failure = *itFailure++;
|
||||||
failedTests.insert( std::make_pair(failure->failedTest(), failure ) );
|
failedTests.insert(
|
||||||
|
pair< CppUnit::Test* const, CppUnit::TestFailure*
|
||||||
|
>(
|
||||||
|
failure->failedTest(), failure
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user