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