Changed some std::string args to char* to improve compile time

This commit is contained in:
Phil Nash 2011-01-07 09:38:32 +00:00
parent 896a04f5e8
commit a65f210cb2
4 changed files with 23 additions and 21 deletions

View File

@ -95,8 +95,8 @@ public:
MutableResultInfo()
{}
MutableResultInfo( const std::string& expr, bool isNot, const std::string& filename, std::size_t line, const std::string& macroName )
: ResultInfo( ( isNot ? "!" : "" ) + expr, ResultWas::Unknown, isNot, filename, line, macroName )
MutableResultInfo( const char* expr, bool isNot, const char* filename, std::size_t line, const char* macroName )
: ResultInfo( expr, ResultWas::Unknown, isNot, filename, line, macroName )
{
}
void setResultType( ResultWas::OfType result )
@ -138,7 +138,7 @@ private:
class ResultBuilder
{
public:
ResultBuilder( const char* expr, bool isNot, const std::string& filename, std::size_t line, const std::string& macroName )
ResultBuilder( const char* expr, bool isNot, const char* filename, std::size_t line, const char* macroName )
: m_result( expr, isNot, filename, line, macroName )
{}

View File

@ -46,7 +46,7 @@ namespace Catch
m_expressionIncomplete( false )
{}
ResultInfo( const std::string& expr, ResultWas::OfType result, bool isNot, const std::string& filename, std::size_t line, const std::string& macroName )
ResultInfo( const char* expr, ResultWas::OfType result, bool isNot, const char* filename, std::size_t line, const char* macroName )
: m_macroName( macroName ),
m_filename( filename ),
m_line( line ),
@ -56,6 +56,8 @@ namespace Catch
m_isNot( isNot ),
m_expressionIncomplete( false )
{
if( isNot )
m_expr = "!" + m_expr;
}
bool ok() const

View File

@ -55,7 +55,7 @@ private:
typedef void(*TestFunction)();
struct FreeFunctionTestCase : TestCase
struct FreeFunctionTestCase : ITestCase
{
FreeFunctionTestCase( TestFunction fun )
: fun( fun )
@ -66,18 +66,18 @@ struct FreeFunctionTestCase : TestCase
fun();
}
virtual TestCase* clone() const
virtual ITestCase* clone() const
{
return new FreeFunctionTestCase( fun );
}
virtual bool operator == ( const TestCase& other ) const
virtual bool operator == ( const ITestCase& other ) const
{
const FreeFunctionTestCase* ffOther = dynamic_cast<const FreeFunctionTestCase*> ( &other );
return ffOther && fun == ffOther->fun;
}
virtual bool operator < ( const TestCase& other ) const
virtual bool operator < ( const ITestCase& other ) const
{
const FreeFunctionTestCase* ffOther = dynamic_cast<const FreeFunctionTestCase*> ( &other );
return ffOther && fun < ffOther->fun;
@ -88,7 +88,7 @@ private:
};
template<typename C>
struct MethodTestCase : TestCase
struct MethodTestCase : ITestCase
{
MethodTestCase( void (C::*method)() )
: method( method )
@ -100,18 +100,18 @@ struct MethodTestCase : TestCase
(obj.*method)();
}
virtual TestCase* clone() const
virtual ITestCase* clone() const
{
return new MethodTestCase<C>( method );
}
virtual bool operator == ( const TestCase& other ) const
virtual bool operator == ( const ITestCase& other ) const
{
const MethodTestCase* mtOther = dynamic_cast<const MethodTestCase*>( &other );
return mtOther && method == mtOther->method;
}
virtual bool operator < ( const TestCase& other ) const
virtual bool operator < ( const ITestCase& other ) const
{
const MethodTestCase* mtOther = dynamic_cast<const MethodTestCase*>( &other );
return mtOther && &method < &mtOther->method;
@ -123,13 +123,13 @@ private:
struct AutoReg
{
AutoReg( TestFunction function, const std::string& name, const std::string& description )
AutoReg( TestFunction function, const char* name, const char* description )
{
TestRegistry::instance().registerTest( TestCaseInfo( new FreeFunctionTestCase( function ), name, description ) );
}
template<typename C>
AutoReg( void (C::*method)(), const std::string& name, const std::string& description )
AutoReg( void (C::*method)(), const char* name, const char* description )
{
TestRegistry::instance().registerTest( TestCaseInfo( new MethodTestCase<C>( method ), name, description ) );
}

View File

@ -18,19 +18,19 @@
namespace Catch
{
struct TestCase
struct ITestCase
{
virtual ~TestCase(){}
virtual ~ITestCase(){}
virtual void invoke() const = 0;
virtual TestCase* clone() const = 0;
virtual bool operator == ( const TestCase& other ) const = 0;
virtual bool operator < ( const TestCase& other ) const = 0;
virtual ITestCase* clone() const = 0;
virtual bool operator == ( const ITestCase& other ) const = 0;
virtual bool operator < ( const ITestCase& other ) const = 0;
};
class TestCaseInfo
{
public:
TestCaseInfo( TestCase* testCase, const std::string& name, const std::string& description )
TestCaseInfo( ITestCase* testCase, const char* name, const char* description )
: test( testCase ),
name( name ),
description( description )
@ -97,7 +97,7 @@ namespace Catch
}
private:
TestCase* test;
ITestCase* test;
std::string name;
std::string description;
};