* fix gcc4 build of cppunit library by explicitly spelling out std:: in
the headers and importing the required classes in the implementation files * automatic whitespace cleanup git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30586 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -16,23 +16,23 @@ namespace CppUnit
|
||||
* \code
|
||||
* #include <cppunit/SourceLine.h>
|
||||
* #include <cppunit/TestAssert.h>
|
||||
*
|
||||
* void
|
||||
*
|
||||
* void
|
||||
* checkXmlEqual( string expectedXml,
|
||||
* string actualXml,
|
||||
* CppUnit::SourceLine sourceLine )
|
||||
* {
|
||||
* string expected = XmlUniformiser( expectedXml ).stripped();
|
||||
* string actual = XmlUniformiser( actualXml ).stripped();
|
||||
*
|
||||
*
|
||||
* if ( expected == actual )
|
||||
* return;
|
||||
*
|
||||
*
|
||||
* ::CppUnit::Asserter::failNotEqual( expected,
|
||||
* actual,
|
||||
* sourceLine );
|
||||
* }
|
||||
*
|
||||
*
|
||||
* /// Asserts that two XML strings are equivalent.
|
||||
* #define CPPUNITTEST_ASSERT_XML_EQUAL( expected, actual ) \
|
||||
* checkXmlEqual( expected, actual, \
|
||||
@@ -44,7 +44,7 @@ namespace Asserter
|
||||
|
||||
/*! Throws a Exception with the specified message and location.
|
||||
*/
|
||||
void CPPUNIT_API fail( string message,
|
||||
void CPPUNIT_API fail( std::string message,
|
||||
SourceLine sourceLine = SourceLine() );
|
||||
|
||||
/*! Throws a Exception with the specified message and location.
|
||||
@@ -53,8 +53,8 @@ namespace Asserter
|
||||
* \param message Message explaining the assertion failiure.
|
||||
* \param sourceLine Location of the assertion.
|
||||
*/
|
||||
void CPPUNIT_API failIf( bool shouldFail,
|
||||
string message,
|
||||
void CPPUNIT_API failIf( bool shouldFail,
|
||||
std::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( string expected,
|
||||
string actual,
|
||||
void CPPUNIT_API failNotEqual( std::string expected,
|
||||
std::string actual,
|
||||
SourceLine sourceLine = SourceLine(),
|
||||
string additionalMessage ="" );
|
||||
std::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,
|
||||
string expected,
|
||||
string actual,
|
||||
std::string expected,
|
||||
std::string actual,
|
||||
SourceLine sourceLine = SourceLine(),
|
||||
string additionalMessage ="" );
|
||||
std::string additionalMessage ="" );
|
||||
|
||||
} // namespace Asserter
|
||||
} // namespace CppUnit
|
||||
|
||||
@@ -15,7 +15,7 @@ class Test;
|
||||
class TestFailure;
|
||||
class TestResultCollector;
|
||||
|
||||
/*!
|
||||
/*!
|
||||
* \brief Outputs a TestResultCollector in a compiler compatible format.
|
||||
* \ingroup WritingTestResult
|
||||
*
|
||||
@@ -33,23 +33,23 @@ class TestResultCollector;
|
||||
* int main( int argc, char* argv[] ) {
|
||||
* // 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) &&
|
||||
* bool selfTest = (argc > 1) &&
|
||||
* (string("-selftest") == argv[1]);
|
||||
*
|
||||
* CppUnit::TextUi::TestRunner runner;
|
||||
* runner.addTest( CppUnitTest::suite() ); // Add the top suite to the test runner
|
||||
*
|
||||
*
|
||||
* if ( selfTest )
|
||||
* { // Change the default outputter to a compiler error format outputter
|
||||
* // The test runner owns the new outputter.
|
||||
* runner.setOutputter( CppUnit::CompilerOutputter::defaultOutputter(
|
||||
* runner.setOutputter( CppUnit::CompilerOutputter::defaultOutputter(
|
||||
* &runner.result(),
|
||||
* cerr ) );
|
||||
* }
|
||||
*
|
||||
*
|
||||
* // Run the test and don't wait a key if post build check.
|
||||
* bool wasSucessful = runner.run( "", !selfTest );
|
||||
*
|
||||
*
|
||||
* // Return error code 1 if the one of test failed.
|
||||
* return wasSucessful ? 0 : 1;
|
||||
* }
|
||||
@@ -61,7 +61,7 @@ public:
|
||||
/*! Constructs a CompilerOutputter object.
|
||||
*/
|
||||
CompilerOutputter( TestResultCollector *result,
|
||||
ostream &stream );
|
||||
std::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,
|
||||
ostream &stream );
|
||||
std::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 string wrap( string message );
|
||||
virtual std::string wrap( std::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 vector<string> Lines;
|
||||
static Lines splitMessageIntoLines( string message );
|
||||
typedef std::vector<std::string> Lines;
|
||||
static Lines splitMessageIntoLines( std::string message );
|
||||
|
||||
private:
|
||||
TestResultCollector *m_result;
|
||||
ostream &m_stream;
|
||||
std::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 exception
|
||||
class CPPUNIT_API Exception : public std::exception
|
||||
{
|
||||
public:
|
||||
|
||||
class Type
|
||||
{
|
||||
public:
|
||||
Type( string type ) : m_type ( type ) {}
|
||||
Type( std::string type ) : m_type ( type ) {}
|
||||
|
||||
bool operator ==( const Type &other ) const
|
||||
{
|
||||
return m_type == other.m_type;
|
||||
}
|
||||
private:
|
||||
const string m_type;
|
||||
const std::string m_type;
|
||||
};
|
||||
|
||||
|
||||
Exception( string message = "",
|
||||
Exception( std::string message = "",
|
||||
SourceLine sourceLine = SourceLine() );
|
||||
|
||||
#ifdef CPPUNIT_ENABLE_SOURCELINE_DEPRECATED
|
||||
Exception( string message,
|
||||
long lineNumber,
|
||||
string fileName );
|
||||
Exception( std::string message,
|
||||
long lineNumber,
|
||||
std::string fileName );
|
||||
#endif
|
||||
|
||||
Exception (const Exception& other);
|
||||
@@ -55,12 +55,12 @@ public:
|
||||
long lineNumber() const;
|
||||
string fileName() const;
|
||||
|
||||
static const string UNKNOWNFILENAME;
|
||||
static const std::string UNKNOWNFILENAME;
|
||||
static const long UNKNOWNLINENUMBER;
|
||||
#endif
|
||||
|
||||
virtual Exception *clone() const;
|
||||
|
||||
|
||||
virtual bool isInstanceOf( const Type &type ) const;
|
||||
|
||||
static Type type();
|
||||
@@ -68,9 +68,9 @@ public:
|
||||
private:
|
||||
// VC++ does not recognize call to parent class when prefixed
|
||||
// with a namespace. This is a workaround.
|
||||
typedef exception SuperClass;
|
||||
typedef std::exception SuperClass;
|
||||
|
||||
string m_message;
|
||||
std::string m_message;
|
||||
SourceLine m_sourceLine;
|
||||
};
|
||||
|
||||
|
||||
@@ -19,16 +19,16 @@ public:
|
||||
* \param additionalMessage Additionnal information provided to further qualify
|
||||
* the inequality.
|
||||
*/
|
||||
NotEqualException( string expected,
|
||||
string actual,
|
||||
NotEqualException( std::string expected,
|
||||
std::string actual,
|
||||
SourceLine sourceLine = SourceLine(),
|
||||
string additionalMessage = "" );
|
||||
std::string additionalMessage = "" );
|
||||
|
||||
#ifdef CPPUNIT_ENABLE_SOURCELINE_DEPRECATED
|
||||
NotEqualException( string expected,
|
||||
string actual,
|
||||
long lineNumber,
|
||||
string fileName );
|
||||
NotEqualException( std::string expected,
|
||||
std::string actual,
|
||||
long lineNumber,
|
||||
std::string fileName );
|
||||
#endif
|
||||
|
||||
NotEqualException( const NotEqualException &other );
|
||||
@@ -36,11 +36,11 @@ public:
|
||||
|
||||
virtual ~NotEqualException() throw();
|
||||
|
||||
string expectedValue() const;
|
||||
std::string expectedValue() const;
|
||||
|
||||
string actualValue() const;
|
||||
std::string actualValue() const;
|
||||
|
||||
string additionalMessage() const;
|
||||
std::string additionalMessage() const;
|
||||
|
||||
/*! Copy operator.
|
||||
* @param other Object to copy.
|
||||
@@ -55,9 +55,9 @@ public:
|
||||
static Type type();
|
||||
|
||||
private:
|
||||
string m_expected;
|
||||
string m_actual;
|
||||
string m_additionalMessage;
|
||||
std::string m_expected;
|
||||
std::string m_actual;
|
||||
std::string m_additionalMessage;
|
||||
};
|
||||
|
||||
} // namespace CppUnit
|
||||
|
||||
@@ -21,6 +21,10 @@
|
||||
#undef CPPUNIT_FUNC_STRING_COMPARE_STRING_FIRST
|
||||
#endif
|
||||
|
||||
#if __GNUC__ > 2
|
||||
#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
|
||||
@@ -33,7 +37,7 @@
|
||||
#define CPPUNIT_ENABLE_CU_TEST_MACROS 0
|
||||
#endif
|
||||
|
||||
/* Define to 1 if the preprocessor expands (#foo) to "foo" (quotes incl.)
|
||||
/* Define to 1 if the preprocessor expands (#foo) to "foo" (quotes incl.)
|
||||
I don't think there is any C preprocess that does NOT support this! */
|
||||
#ifndef CPPUNIT_HAVE_CPP_SOURCE_ANNOTATION
|
||||
#define CPPUNIT_HAVE_CPP_SOURCE_ANNOTATION 1
|
||||
@@ -60,11 +64,11 @@
|
||||
#if CPPUNIT_HAVE_SSTREAM
|
||||
# include <sstream>
|
||||
namespace CppUnit {
|
||||
class OStringStream : public ostringstream
|
||||
class OStringStream : public ostringstream
|
||||
{
|
||||
};
|
||||
}
|
||||
#else
|
||||
#else
|
||||
#if CPPUNIT_HAVE_CLASS_STRSTREAM
|
||||
# include <string>
|
||||
# if CPPUNIT_HAVE_STRSTREAM
|
||||
@@ -74,14 +78,14 @@
|
||||
# endif
|
||||
|
||||
namespace CppUnit {
|
||||
class OStringStream : public ostrstream
|
||||
class OStringStream : public std::ostrstream
|
||||
{
|
||||
public:
|
||||
string str()
|
||||
std::string str()
|
||||
{
|
||||
(*this) << '\0';
|
||||
string msg(ostrstream::str());
|
||||
ostrstream::freeze(false);
|
||||
std::string msg(std::ostrstream::str());
|
||||
std::ostrstream::freeze(false);
|
||||
return msg;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace CppUnit
|
||||
* \ingroup BrowsingCollectedTestResult
|
||||
*
|
||||
* Used to capture the failure location in assertion.
|
||||
*
|
||||
*
|
||||
* Use the CPPUNIT_SOURCELINE() macro to construct that object. Typically used when
|
||||
* writing an assertion macro in association with Asserter.
|
||||
*
|
||||
@@ -32,7 +32,7 @@ class CPPUNIT_API SourceLine
|
||||
public:
|
||||
SourceLine();
|
||||
|
||||
SourceLine( const string &fileName,
|
||||
SourceLine( const std::string &fileName,
|
||||
int lineNumber );
|
||||
|
||||
/// Destructor.
|
||||
@@ -42,13 +42,13 @@ public:
|
||||
|
||||
int lineNumber() const;
|
||||
|
||||
string fileName() const;
|
||||
std::string fileName() const;
|
||||
|
||||
bool operator ==( const SourceLine &other ) const;
|
||||
bool operator !=( const SourceLine &other ) const;
|
||||
|
||||
private:
|
||||
string m_fileName;
|
||||
std::string m_fileName;
|
||||
int m_lineNumber;
|
||||
};
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ class TestResult;
|
||||
*
|
||||
* All test objects should be a subclass of Test. Some test objects,
|
||||
* TestCase for example, represent one individual test. Other test
|
||||
* objects, such as TestSuite, are comprised of several tests.
|
||||
* objects, such as TestSuite, are comprised of several tests.
|
||||
*
|
||||
* When a Test is run, the result is collected by a TestResult object.
|
||||
*
|
||||
@@ -38,20 +38,20 @@ public:
|
||||
virtual int countTestCases () const = 0;
|
||||
|
||||
/*! \brief Returns the test name.
|
||||
*
|
||||
*
|
||||
* Each test has a name. This name may be used to find the
|
||||
* test in a suite or registry of tests.
|
||||
*/
|
||||
virtual string getName () const = 0;
|
||||
virtual std::string getName () const = 0;
|
||||
|
||||
/*! \brief Description of the test, for diagnostic output.
|
||||
*
|
||||
* The test description will typically include the test name,
|
||||
* but may have additional description. For example, a test
|
||||
* 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>.
|
||||
*/
|
||||
virtual string toString () const = 0;
|
||||
virtual std::string toString () const = 0;
|
||||
|
||||
|
||||
};
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace CppUnit {
|
||||
* {
|
||||
* return x == y;
|
||||
* }
|
||||
*
|
||||
*
|
||||
* static string toString( const string& x )
|
||||
* {
|
||||
* string text = '"' + x + '"'; // adds quote around the string to see whitespace
|
||||
@@ -32,14 +32,14 @@ namespace CppUnit {
|
||||
* \endcode
|
||||
*/
|
||||
template <class T>
|
||||
struct assertion_traits
|
||||
{
|
||||
struct assertion_traits
|
||||
{
|
||||
static bool equal( const T& x, const T& y )
|
||||
{
|
||||
return x == y;
|
||||
}
|
||||
|
||||
static string toString( const T& x )
|
||||
static std::string toString( const T& x )
|
||||
{
|
||||
OStringStream ost;
|
||||
ost << x;
|
||||
@@ -51,37 +51,37 @@ namespace CppUnit {
|
||||
namespace TestAssert
|
||||
{
|
||||
#ifdef CPPUNIT_ENABLE_SOURCELINE_DEPRECATED
|
||||
void CPPUNIT_API assertImplementation( bool condition,
|
||||
string conditionExpression = "",
|
||||
void CPPUNIT_API assertImplementation( bool condition,
|
||||
std::string conditionExpression = "",
|
||||
long lineNumber,
|
||||
string fileName );
|
||||
std::string fileName );
|
||||
|
||||
void CPPUNIT_API assertNotEqualImplementation( string expected,
|
||||
string actual,
|
||||
void CPPUNIT_API assertNotEqualImplementation( std::string expected,
|
||||
std::string actual,
|
||||
long lineNumber,
|
||||
string fileName );
|
||||
|
||||
std::string fileName );
|
||||
|
||||
|
||||
template <class T>
|
||||
void assertEquals( const T& expected,
|
||||
const T& actual,
|
||||
long lineNumber,
|
||||
string fileName )
|
||||
std::string fileName )
|
||||
{
|
||||
if ( !assertion_traits<T>::equal(expected,actual) ) // lazy toString conversion...
|
||||
{
|
||||
assertNotEqualImplementation( assertion_traits<T>::toString(expected),
|
||||
assertion_traits<T>::toString(actual),
|
||||
lineNumber,
|
||||
lineNumber,
|
||||
fileName );
|
||||
}
|
||||
}
|
||||
|
||||
void CPPUNIT_API assertEquals( double expected,
|
||||
double actual,
|
||||
double delta,
|
||||
void CPPUNIT_API assertEquals( double expected,
|
||||
double actual,
|
||||
double delta,
|
||||
long lineNumber,
|
||||
string fileName );
|
||||
std::string fileName );
|
||||
|
||||
#else // using SourceLine
|
||||
|
||||
@@ -89,7 +89,7 @@ namespace CppUnit {
|
||||
void assertEquals( const T& expected,
|
||||
const T& actual,
|
||||
SourceLine sourceLine,
|
||||
const string &message ="" )
|
||||
const std::string &message ="" )
|
||||
{
|
||||
if ( !assertion_traits<T>::equal(expected,actual) ) // lazy toString conversion...
|
||||
{
|
||||
@@ -167,7 +167,7 @@ namespace CppUnit {
|
||||
* Requirement for \a expected and \a actual parameters:
|
||||
* - They are exactly of the same type
|
||||
* - 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
|
||||
* removed by specializing the CppUnit::assertion_traits.
|
||||
@@ -190,7 +190,7 @@ namespace CppUnit {
|
||||
* Requirement for \a expected and \a actual parameters:
|
||||
* - They are exactly of the same type
|
||||
* - 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
|
||||
* removed by specializing the CppUnit::assertion_traits.
|
||||
|
||||
@@ -33,18 +33,18 @@ struct ExpectedExceptionTraits
|
||||
static void expectedException()
|
||||
{
|
||||
#if CPPUNIT_USE_TYPEINFO_NAME
|
||||
string message( "Expected exception of type " );
|
||||
std::string message( "Expected exception of type " );
|
||||
message += TypeInfoHelper::getClassName( typeid( ExceptionType ) );
|
||||
message += ", but got none";
|
||||
#else
|
||||
string message( "Expected exception but got none" );
|
||||
std::string message( "Expected exception but got none" );
|
||||
#endif
|
||||
throw Exception( message );
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/*! \brief (Implementation) Traits specialization used by TestCaller to
|
||||
/*! \brief (Implementation) Traits specialization used by TestCaller to
|
||||
* expect no exception.
|
||||
*
|
||||
* This class is an implementation detail. You should never use this class directly.
|
||||
@@ -65,13 +65,13 @@ struct ExpectedExceptionTraits<NoExceptionExpected>
|
||||
/*! \brief Generate a test case from a fixture method.
|
||||
* \ingroup WritingTestFixture
|
||||
*
|
||||
* A test caller provides access to a test case method
|
||||
* on a test fixture class. Test callers are useful when
|
||||
* you want to run an individual test or add it to a
|
||||
* A test caller provides access to a test case method
|
||||
* on a test fixture class. Test callers are useful when
|
||||
* you want to run an individual test or add it to a
|
||||
* suite.
|
||||
* Test Callers invoke only one Test (i.e. test method) on one
|
||||
* Test Callers invoke only one Test (i.e. test method) on one
|
||||
* Fixture of a TestFixture.
|
||||
*
|
||||
*
|
||||
* Here is an example:
|
||||
* \code
|
||||
* class MathTest : public CppUnit::TestFixture {
|
||||
@@ -94,16 +94,16 @@ struct ExpectedExceptionTraits<NoExceptionExpected>
|
||||
*
|
||||
* You can use a TestCaller to bind any test method on a TestFixture
|
||||
* class, as long as it accepts void and returns void.
|
||||
*
|
||||
*
|
||||
* \see TestCase
|
||||
*/
|
||||
|
||||
template <typename Fixture,
|
||||
template <typename Fixture,
|
||||
typename ExpectedException = NoExceptionExpected>
|
||||
class TestCaller : public TestCase
|
||||
{
|
||||
{
|
||||
typedef void (Fixture::*TestMethod)();
|
||||
|
||||
|
||||
public:
|
||||
/*!
|
||||
* Constructor for TestCaller. This constructor builds a new Fixture
|
||||
@@ -111,8 +111,8 @@ public:
|
||||
* \param name name of this TestCaller
|
||||
* \param test the method this TestCaller calls in runTest()
|
||||
*/
|
||||
TestCaller( string name, TestMethod test ) :
|
||||
TestCase( name ),
|
||||
TestCaller( std::string name, TestMethod test ) :
|
||||
TestCase( name ),
|
||||
m_ownFixture( true ),
|
||||
m_fixture( new Fixture() ),
|
||||
m_test( test )
|
||||
@@ -120,7 +120,7 @@ public:
|
||||
}
|
||||
|
||||
/*!
|
||||
* Constructor for TestCaller.
|
||||
* Constructor for TestCaller.
|
||||
* This constructor does not create a new Fixture instance but accepts
|
||||
* an existing one as parameter. The TestCaller will not own the
|
||||
* Fixture object.
|
||||
@@ -128,16 +128,16 @@ public:
|
||||
* \param test the method this TestCaller calls in runTest()
|
||||
* \param fixture the Fixture to invoke the test method on.
|
||||
*/
|
||||
TestCaller(string name, TestMethod test, Fixture& fixture) :
|
||||
TestCase( name ),
|
||||
TestCaller(std::string name, TestMethod test, Fixture& fixture) :
|
||||
TestCase( name ),
|
||||
m_ownFixture( false ),
|
||||
m_fixture( &fixture ),
|
||||
m_test( test )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
* Constructor for TestCaller.
|
||||
* Constructor for TestCaller.
|
||||
* This constructor does not create a new Fixture instance but accepts
|
||||
* an existing one as parameter. The TestCaller will own the
|
||||
* Fixture object and delete it in its destructor.
|
||||
@@ -145,15 +145,15 @@ public:
|
||||
* \param test the method this TestCaller calls in runTest()
|
||||
* \param fixture the Fixture to invoke the test method on.
|
||||
*/
|
||||
TestCaller(string name, TestMethod test, Fixture* fixture) :
|
||||
TestCase( name ),
|
||||
TestCaller(std::string name, TestMethod test, Fixture* fixture) :
|
||||
TestCase( name ),
|
||||
m_ownFixture( true ),
|
||||
m_fixture( fixture ),
|
||||
m_test( test )
|
||||
{
|
||||
}
|
||||
|
||||
~TestCaller()
|
||||
|
||||
~TestCaller()
|
||||
{
|
||||
if (m_ownFixture)
|
||||
delete m_fixture;
|
||||
@@ -161,7 +161,7 @@ public:
|
||||
|
||||
protected:
|
||||
void runTest()
|
||||
{
|
||||
{
|
||||
try {
|
||||
(m_fixture->*m_test)();
|
||||
}
|
||||
@@ -170,25 +170,25 @@ protected:
|
||||
}
|
||||
|
||||
ExpectedExceptionTraits<ExpectedException>::expectedException();
|
||||
}
|
||||
}
|
||||
|
||||
void setUp()
|
||||
{
|
||||
m_fixture->setUp ();
|
||||
{
|
||||
m_fixture->setUp ();
|
||||
}
|
||||
|
||||
void tearDown()
|
||||
{
|
||||
m_fixture->tearDown ();
|
||||
{
|
||||
m_fixture->tearDown ();
|
||||
}
|
||||
|
||||
string toString() const
|
||||
{
|
||||
return "TestCaller " + getName();
|
||||
std::string toString() const
|
||||
{
|
||||
return "TestCaller " + getName();
|
||||
}
|
||||
|
||||
private:
|
||||
TestCaller( const TestCaller &other );
|
||||
private:
|
||||
TestCaller( const TestCaller &other );
|
||||
TestCaller &operator =( const TestCaller &other );
|
||||
|
||||
private:
|
||||
|
||||
@@ -28,34 +28,34 @@ class CPPUNIT_API TestCase : public Test,
|
||||
{
|
||||
public:
|
||||
|
||||
TestCase( string Name );
|
||||
TestCase( std::string Name );
|
||||
//! \internal
|
||||
TestCase();
|
||||
~TestCase();
|
||||
|
||||
|
||||
virtual void run(TestResult *result);
|
||||
virtual int countTestCases() const;
|
||||
string getName() const;
|
||||
string toString() const;
|
||||
std::string getName() const;
|
||||
std::string toString() const;
|
||||
|
||||
//! FIXME: what is this for?
|
||||
virtual TestResult *run();
|
||||
|
||||
|
||||
protected:
|
||||
//! FIXME: this should probably be pure virtual.
|
||||
virtual void runTest();
|
||||
|
||||
//! Create TestResult for the run(void) method.
|
||||
TestResult *defaultResult();
|
||||
|
||||
|
||||
private:
|
||||
TestCase( const TestCase &other );
|
||||
TestCase &operator=( const TestCase &other );
|
||||
|
||||
TestCase( const TestCase &other );
|
||||
TestCase &operator=( const TestCase &other );
|
||||
|
||||
private:
|
||||
const string m_name;
|
||||
const std::string m_name;
|
||||
};
|
||||
|
||||
} // namespace CppUnit
|
||||
|
||||
#endif // CPPUNIT_TESTCASE_H
|
||||
#endif // CPPUNIT_TESTCASE_H
|
||||
|
||||
@@ -20,7 +20,7 @@ class Test;
|
||||
* TestFailure assumes lifetime control for any exception
|
||||
* passed to it.
|
||||
*/
|
||||
class CPPUNIT_API TestFailure
|
||||
class CPPUNIT_API TestFailure
|
||||
{
|
||||
public:
|
||||
TestFailure( Test *failedTest,
|
||||
@@ -37,9 +37,9 @@ public:
|
||||
|
||||
virtual bool isError() const;
|
||||
|
||||
virtual string failedTestName() const;
|
||||
|
||||
virtual string toString() const;
|
||||
virtual std::string failedTestName() const;
|
||||
|
||||
virtual std::string toString() const;
|
||||
|
||||
virtual TestFailure *clone() const;
|
||||
|
||||
@@ -48,9 +48,9 @@ protected:
|
||||
Exception *m_thrownException;
|
||||
bool m_isError;
|
||||
|
||||
private:
|
||||
TestFailure( const TestFailure &other );
|
||||
TestFailure &operator =( const TestFailure& other );
|
||||
private:
|
||||
TestFailure( const TestFailure &other );
|
||||
TestFailure &operator =( const TestFailure& other );
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -35,9 +35,9 @@ class TestListener;
|
||||
* TestResult supplies a template method 'setSynchronizationObject()'
|
||||
* so that subclasses can provide mutual exclusion in the face of multiple
|
||||
* threads. This can be useful when tests execute in one thread and
|
||||
* they fill a subclass of TestResult which effects change in another
|
||||
* they fill a subclass of TestResult which effects change in another
|
||||
* thread. To have mutual exclusion, override setSynchronizationObject()
|
||||
* and make sure that you create an instance of ExclusiveZone at the
|
||||
* and make sure that you create an instance of ExclusiveZone at the
|
||||
* beginning of each method.
|
||||
*
|
||||
* \see Test, TestListener, TestResultCollector, Outputter.
|
||||
@@ -63,13 +63,13 @@ public:
|
||||
|
||||
protected:
|
||||
void addFailure( const TestFailure &failure );
|
||||
|
||||
|
||||
protected:
|
||||
typedef deque<TestListener *> TestListeners;
|
||||
typedef std::deque<TestListener *> TestListeners;
|
||||
TestListeners m_listeners;
|
||||
bool m_stop;
|
||||
|
||||
private:
|
||||
private:
|
||||
TestResult( const TestResult &other );
|
||||
TestResult &operator =( const TestResult &other );
|
||||
};
|
||||
|
||||
@@ -25,8 +25,8 @@ namespace CppUnit
|
||||
/*! \brief Collects test result.
|
||||
* \ingroup WritingTestResult
|
||||
* \ingroup BrowsingCollectedTestResult
|
||||
*
|
||||
* A TestResultCollector is a TestListener which collects the results of executing
|
||||
*
|
||||
* A TestResultCollector is a TestListener which collects the results of executing
|
||||
* a test case. It is an instance of the Collecting Parameter pattern.
|
||||
*
|
||||
* The test framework distinguishes between failures and errors.
|
||||
@@ -38,8 +38,8 @@ namespace CppUnit
|
||||
class CPPUNIT_API TestResultCollector : public TestSucessListener
|
||||
{
|
||||
public:
|
||||
typedef deque<TestFailure *> TestFailures;
|
||||
typedef deque<Test *> Tests;
|
||||
typedef std::deque<TestFailure *> TestFailures;
|
||||
typedef std::deque<Test *> Tests;
|
||||
|
||||
|
||||
/*! Constructs a TestResultCollector object.
|
||||
|
||||
@@ -12,6 +12,9 @@
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
using std::string;
|
||||
using std::vector;
|
||||
|
||||
namespace CppUnit {
|
||||
|
||||
class TestResult;
|
||||
@@ -36,7 +39,7 @@ class TestResult;
|
||||
* control for any tests added to them.
|
||||
*
|
||||
* TestSuites do not register themselves in the TestRegistry.
|
||||
* \see Test
|
||||
* \see Test
|
||||
* \see TestCaller
|
||||
*/
|
||||
|
||||
@@ -59,7 +62,7 @@ public:
|
||||
|
||||
private:
|
||||
TestSuite( const TestSuite &other );
|
||||
TestSuite &operator =( const TestSuite &other );
|
||||
TestSuite &operator =( const TestSuite &other );
|
||||
|
||||
private:
|
||||
vector<Test *> m_tests;
|
||||
|
||||
@@ -21,7 +21,7 @@ class CPPUNIT_API TextOutputter : public Outputter
|
||||
{
|
||||
public:
|
||||
TextOutputter( TestResultCollector *result,
|
||||
ostream &stream );
|
||||
std::ostream &stream );
|
||||
|
||||
/// Destructor.
|
||||
virtual ~TextOutputter();
|
||||
@@ -42,7 +42,7 @@ public:
|
||||
|
||||
protected:
|
||||
TestResultCollector *m_result;
|
||||
ostream &m_stream;
|
||||
std::ostream &m_stream;
|
||||
|
||||
private:
|
||||
/// Prevents the use of the copy constructor.
|
||||
|
||||
@@ -13,7 +13,7 @@ class Test;
|
||||
|
||||
/*! \brief Holds printable test result (DEPRECATED).
|
||||
* \ingroup TrackingTestExecution
|
||||
*
|
||||
*
|
||||
* deprecated Use class TextTestProgressListener and TextOutputter instead.
|
||||
*/
|
||||
class CPPUNIT_API TextTestResult : public TestResult,
|
||||
@@ -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( ostream &stream );
|
||||
virtual void printFailures( ostream &stream );
|
||||
virtual void printHeader( ostream &stream );
|
||||
virtual void print( std::ostream &stream );
|
||||
virtual void printFailures( std::ostream &stream );
|
||||
virtual void printHeader( std::ostream &stream );
|
||||
|
||||
virtual void printFailure( TestFailure *failure,
|
||||
int failureNumber,
|
||||
ostream &stream );
|
||||
std::ostream &stream );
|
||||
virtual void printFailureListMark( int failureNumber,
|
||||
ostream &stream );
|
||||
std::ostream &stream );
|
||||
virtual void printFailureTestName( TestFailure *failure,
|
||||
ostream &stream );
|
||||
std::ostream &stream );
|
||||
virtual void printFailureType( TestFailure *failure,
|
||||
ostream &stream );
|
||||
std::ostream &stream );
|
||||
virtual void printFailureLocation( SourceLine sourceLine,
|
||||
ostream &stream );
|
||||
std::ostream &stream );
|
||||
virtual void printFailureDetail( Exception *thrownException,
|
||||
ostream &stream );
|
||||
virtual void printFailureWarning( ostream &stream );
|
||||
virtual void printStatistics( ostream &stream );
|
||||
std::ostream &stream );
|
||||
virtual void printFailureWarning( std::ostream &stream );
|
||||
virtual void printStatistics( std::ostream &stream );
|
||||
};
|
||||
|
||||
/** insertion operator for easy output */
|
||||
ostream &operator <<( ostream &stream,
|
||||
std::ostream &operator <<( std::ostream &stream,
|
||||
TextTestResult &result );
|
||||
|
||||
} // namespace CppUnit
|
||||
|
||||
@@ -33,11 +33,11 @@ public:
|
||||
/*! Constructs a XmlOutputter object.
|
||||
* \param result Result of the test run.
|
||||
* \param stream Stream used to output the XML output.
|
||||
* \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,
|
||||
ostream &stream,
|
||||
string encoding = "ISO-8859-1" );
|
||||
std::ostream &stream,
|
||||
std::string encoding = "ISO-8859-1" );
|
||||
|
||||
/// Destructor.
|
||||
virtual ~XmlOutputter();
|
||||
@@ -56,33 +56,33 @@ public:
|
||||
class CPPUNIT_API Node
|
||||
{
|
||||
public:
|
||||
Node( string elementName,
|
||||
string content ="" );
|
||||
Node( string elementName,
|
||||
Node( std::string elementName,
|
||||
std::string content ="" );
|
||||
Node( std::string elementName,
|
||||
int numericContent );
|
||||
virtual ~Node();
|
||||
|
||||
void addAttribute( string attributeName,
|
||||
string value );
|
||||
void addAttribute( string attributeName,
|
||||
void addAttribute( std::string attributeName,
|
||||
std::string value );
|
||||
void addAttribute( std::string attributeName,
|
||||
int numericValue );
|
||||
void addNode( Node *node );
|
||||
|
||||
string toString() const;
|
||||
std::string toString() const;
|
||||
|
||||
private:
|
||||
typedef pair<string,string> Attribute;
|
||||
typedef std::pair<std::string,std::string> Attribute;
|
||||
|
||||
string attributesAsString() const;
|
||||
string escape( string value ) const;
|
||||
static string asString( int value );
|
||||
std::string attributesAsString() const;
|
||||
std::string escape( std::string value ) const;
|
||||
static std::string asString( int value );
|
||||
|
||||
private:
|
||||
string m_name;
|
||||
string m_content;
|
||||
typedef deque<Attribute> Attributes;
|
||||
std::string m_name;
|
||||
std::string m_content;
|
||||
typedef std::deque<Attribute> Attributes;
|
||||
Attributes m_attributes;
|
||||
typedef deque<Node *> Nodes;
|
||||
typedef std::deque<Node *> Nodes;
|
||||
Nodes m_nodes;
|
||||
};
|
||||
|
||||
@@ -90,7 +90,7 @@ public:
|
||||
virtual void writeProlog();
|
||||
virtual void writeTestsResult();
|
||||
|
||||
typedef map<Test *,TestFailure*> FailedTests;
|
||||
typedef std::map<Test *,TestFailure*> FailedTests;
|
||||
virtual Node *makeRootNode();
|
||||
virtual void addFailedTests( FailedTests &failedTests,
|
||||
Node *rootNode );
|
||||
@@ -103,7 +103,7 @@ public:
|
||||
Node *testsNode );
|
||||
virtual void addFailureLocation( TestFailure *failure,
|
||||
Node *testNode );
|
||||
virtual void addSucessfulTest( Test *test,
|
||||
virtual void addSucessfulTest( Test *test,
|
||||
int testNumber,
|
||||
Node *testsNode );
|
||||
protected:
|
||||
@@ -111,8 +111,8 @@ protected:
|
||||
|
||||
protected:
|
||||
TestResultCollector *m_result;
|
||||
ostream &m_stream;
|
||||
string m_encoding;
|
||||
std::ostream &m_stream;
|
||||
std::string m_encoding;
|
||||
|
||||
private:
|
||||
/// Prevents the use of the copy constructor.
|
||||
|
||||
@@ -14,17 +14,17 @@ class TestResult;
|
||||
*
|
||||
* Does not assume ownership of the test it decorates
|
||||
*/
|
||||
class CPPUNIT_API RepeatedTest : public TestDecorator
|
||||
class CPPUNIT_API RepeatedTest : public TestDecorator
|
||||
{
|
||||
public:
|
||||
RepeatedTest( Test *test,
|
||||
int timesRepeat ) :
|
||||
TestDecorator( test ),
|
||||
RepeatedTest( Test *test,
|
||||
int timesRepeat ) :
|
||||
TestDecorator( test ),
|
||||
m_timesRepeat(timesRepeat) {}
|
||||
|
||||
void run( TestResult *result );
|
||||
int countTestCases() const;
|
||||
string toString() const;
|
||||
std::string toString() const;
|
||||
|
||||
private:
|
||||
RepeatedTest( const RepeatedTest & );
|
||||
|
||||
@@ -16,8 +16,8 @@ class TestResult;
|
||||
* subclass the decorater and use it to wrap the test class.
|
||||
*
|
||||
* Does not assume ownership of the test it decorates
|
||||
*/
|
||||
class CPPUNIT_API TestDecorator : public Test
|
||||
*/
|
||||
class CPPUNIT_API TestDecorator : public Test
|
||||
{
|
||||
public:
|
||||
TestDecorator (Test *test);
|
||||
@@ -25,8 +25,8 @@ public:
|
||||
|
||||
void run (TestResult *result);
|
||||
int countTestCases () const;
|
||||
string getName () const;
|
||||
string toString () const;
|
||||
std::string getName () const;
|
||||
std::string toString () const;
|
||||
|
||||
protected:
|
||||
Test *m_test;
|
||||
@@ -53,11 +53,11 @@ inline void TestDecorator::run (TestResult *result)
|
||||
{ m_test->run (result); }
|
||||
|
||||
|
||||
inline string TestDecorator::toString () const
|
||||
inline std::string TestDecorator::toString () const
|
||||
{ return m_test->toString (); }
|
||||
|
||||
|
||||
inline string TestDecorator::getName () const
|
||||
inline std::string TestDecorator::getName () const
|
||||
{ return m_test->getName(); }
|
||||
|
||||
} // namespace CppUnit
|
||||
|
||||
@@ -66,7 +66,7 @@ class TestSuite;
|
||||
* CppUnit::TestSuite *suite = registry.makeTest();
|
||||
* \endcode
|
||||
*
|
||||
* Since a TestFactoryRegistry is a TestFactory, the named registries can be
|
||||
* Since a TestFactoryRegistry is a TestFactory, the named registries can be
|
||||
* registered in the unnamed registry, creating the hierarchy links.
|
||||
*
|
||||
* \see TestSuiteFactory, AutoRegisterSuite
|
||||
@@ -79,19 +79,19 @@ public:
|
||||
* \param name Name of the registry. It is the name of TestSuite returned by
|
||||
* makeTest().
|
||||
*/
|
||||
TestFactoryRegistry( string name = "All Tests" );
|
||||
TestFactoryRegistry( std::string name = "All Tests" );
|
||||
|
||||
/// Destructor.
|
||||
virtual ~TestFactoryRegistry();
|
||||
|
||||
/** Returns a new TestSuite that contains the registered test.
|
||||
* \return A new TestSuite which contains all the test added using
|
||||
* \return A new TestSuite which contains all the test added using
|
||||
* registerFactory(TestFactory *).
|
||||
*/
|
||||
virtual Test *makeTest();
|
||||
|
||||
/** Returns unnamed the registry.
|
||||
* TestSuite registered using CPPUNIT_TEST_SUITE_REGISTRATION() are registered
|
||||
* TestSuite registered using CPPUNIT_TEST_SUITE_REGISTRATION() are registered
|
||||
* in this registry.
|
||||
* \return Registry which name is "All Tests".
|
||||
*/
|
||||
@@ -104,7 +104,7 @@ public:
|
||||
* \return Registry. If the registry does not exist, it is created with the
|
||||
* specified name.
|
||||
*/
|
||||
static TestFactoryRegistry &getRegistry( const string &name );
|
||||
static TestFactoryRegistry &getRegistry( const std::string &name );
|
||||
|
||||
/** Adds the registered tests to the specified suite.
|
||||
* \param suite Suite the tests are added to.
|
||||
@@ -113,15 +113,15 @@ public:
|
||||
|
||||
/** Adds the specified TestFactory with a specific name (DEPRECATED).
|
||||
* \param name Name associated to the factory.
|
||||
* \param factory Factory to register.
|
||||
* \param factory Factory to register.
|
||||
* \deprecated Use registerFactory( TestFactory *) instead.
|
||||
*/
|
||||
void registerFactory( const string &name,
|
||||
void registerFactory( const std::string &name,
|
||||
TestFactory *factory );
|
||||
|
||||
/** Adds the specified TestFactory to the registry.
|
||||
*
|
||||
* \param factory Factory to register.
|
||||
* \param factory Factory to register.
|
||||
*/
|
||||
void registerFactory( TestFactory *factory );
|
||||
|
||||
@@ -130,10 +130,10 @@ private:
|
||||
void operator =( const TestFactoryRegistry © );
|
||||
|
||||
private:
|
||||
typedef map<string, TestFactory *> Factories;
|
||||
typedef std::map<std::string, TestFactory *> Factories;
|
||||
Factories m_factories;
|
||||
|
||||
string m_name;
|
||||
std::string m_name;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace CppUnit {
|
||||
* the "class" prefix. If the name is not prefixed
|
||||
* by "class", it is returned as this.
|
||||
*/
|
||||
static string getClassName( const type_info &info );
|
||||
static std::string getClassName( const std::type_info &info );
|
||||
};
|
||||
|
||||
} // namespace CppUnit
|
||||
|
||||
Reference in New Issue
Block a user