Fixed most pedantic warnings

This commit is contained in:
Phil Nash 2011-01-31 10:10:20 +00:00
parent 44488f6331
commit db378d8939
12 changed files with 102 additions and 86 deletions

View File

@ -56,8 +56,8 @@ TEST_CASE( "./failing/conditions/equality", "Equality checks that should fail" )
CHECK( data.int_seven == 0 );
CHECK( data.float_nine_point_one == Approx( 9.11f ) );
CHECK( data.float_nine_point_one == Approx( 9.0f ) );
CHECK( data.float_nine_point_one == 1 );
CHECK( data.float_nine_point_one == 0 );
CHECK( data.float_nine_point_one == Approx( 1 ) );
CHECK( data.float_nine_point_one == Approx( 0 ) );
CHECK( data.double_pi == Approx( 3.1415 ) );
CHECK( data.str_hello == "goodbye" );
CHECK( data.str_hello == "hell" );
@ -76,8 +76,8 @@ TEST_CASE( "./succeeding/conditions/inequality", "Inequality checks that should
REQUIRE( data.int_seven != 8 );
REQUIRE( data.float_nine_point_one != Approx( 9.11f ) );
REQUIRE( data.float_nine_point_one != Approx( 9.0f ) );
REQUIRE( data.float_nine_point_one != 1 );
REQUIRE( data.float_nine_point_one != 0 );
REQUIRE( data.float_nine_point_one != Approx( 1 ) );
REQUIRE( data.float_nine_point_one != Approx( 0 ) );
REQUIRE( data.double_pi != Approx( 3.1415 ) );
REQUIRE( data.str_hello != "goodbye" );
REQUIRE( data.str_hello != "hell" );

View File

@ -23,46 +23,46 @@ namespace Catch
{
struct TestStats
{
std::string element;
std::string resultType;
std::string message;
std::string content;
std::string m_element;
std::string m_resultType;
std::string m_message;
std::string m_content;
};
struct TestCaseStats
{
TestCaseStats( const std::string& name = std::string() )
: name( name )
: m_name( name )
{
}
double timeInSeconds;
std::string status;
std::string className;
std::string name;
std::vector<TestStats> testStats;
double m_timeInSeconds;
std::string m_status;
std::string m_className;
std::string m_name;
std::vector<TestStats> m_testStats;
};
struct Stats
{
Stats( const std::string& name = std::string() )
: testsCount( 0 ),
failuresCount( 0 ),
disabledCount( 0 ),
errorsCount( 0 ),
timeInSeconds( 0 ),
name( name )
: m_testsCount( 0 ),
m_failuresCount( 0 ),
m_disabledCount( 0 ),
m_errorsCount( 0 ),
m_timeInSeconds( 0 ),
m_name( name )
{
}
std::size_t testsCount;
std::size_t failuresCount;
std::size_t disabledCount;
std::size_t errorsCount;
double timeInSeconds;
std::string name;
std::size_t m_testsCount;
std::size_t m_failuresCount;
std::size_t m_disabledCount;
std::size_t m_errorsCount;
double m_timeInSeconds;
std::string m_name;
std::vector<TestCaseStats> testCaseStats;
std::vector<TestCaseStats> m_testCaseStats;
};
public:
@ -98,7 +98,7 @@ namespace Catch
///////////////////////////////////////////////////////////////////////////
virtual void EndGroup( const std::string&, std::size_t succeeded, std::size_t failed )
{
m_currentStats->testsCount = failed+succeeded;
m_currentStats->m_testsCount = failed+succeeded;
m_currentStats = &m_testSuiteStats;
}
@ -113,7 +113,7 @@ namespace Catch
///////////////////////////////////////////////////////////////////////////
virtual void StartTestCase( const Catch::TestCaseInfo& testInfo )
{
m_currentStats->testCaseStats.push_back( TestCaseStats( testInfo.getName() ) );
m_currentStats->m_testCaseStats.push_back( TestCaseStats( testInfo.getName() ) );
}
@ -122,7 +122,7 @@ namespace Catch
{
if( resultInfo.getResultType() != ResultWas::Ok || m_config.includeSuccessfulResults() )
{
TestCaseStats& testCaseStats = m_currentStats->testCaseStats.back();
TestCaseStats& testCaseStats = m_currentStats->m_testCaseStats.back();
TestStats stats;
std::ostringstream oss;
if( !resultInfo.getMessage().empty() )
@ -130,37 +130,37 @@ namespace Catch
oss << resultInfo.getMessage() << " at ";
}
oss << resultInfo.getFilename() << ":" << resultInfo.getLine();
stats.content = oss.str();
stats.message = resultInfo.getExpandedExpression();
stats.resultType = resultInfo.getTestMacroName();
stats.m_content = oss.str();
stats.m_message = resultInfo.getExpandedExpression();
stats.m_resultType = resultInfo.getTestMacroName();
switch( resultInfo.getResultType() )
{
case ResultWas::ThrewException:
stats.element = "error";
m_currentStats->errorsCount++;
stats.m_element = "error";
m_currentStats->m_errorsCount++;
break;
case ResultWas::Info:
stats.element = "info"; // !TBD ?
stats.m_element = "info"; // !TBD ?
break;
case ResultWas::Warning:
stats.element = "warning"; // !TBD ?
stats.m_element = "warning"; // !TBD ?
break;
case ResultWas::ExplicitFailure:
stats.element = "failure";
m_currentStats->failuresCount++;
stats.m_element = "failure";
m_currentStats->m_failuresCount++;
break;
case ResultWas::ExpressionFailed:
stats.element = "failure";
m_currentStats->failuresCount++;
stats.m_element = "failure";
m_currentStats->m_failuresCount++;
break;
case ResultWas::Ok:
stats.element = "success";
stats.m_element = "success";
break;
default:
stats.element = "unknown";
stats.m_element = "unknown";
break;
}
testCaseStats.testStats.push_back( stats );
testCaseStats.m_testStats.push_back( stats );
}
}
@ -190,10 +190,10 @@ namespace Catch
for(; it != itEnd; ++it )
{
XmlWriter::ScopedElement e = xml.scopedElement( "testsuite" );
xml.writeAttribute( "name", it->name );
xml.writeAttribute( "errors", it->errorsCount );
xml.writeAttribute( "failures", it->failuresCount );
xml.writeAttribute( "tests", it->testsCount );
xml.writeAttribute( "name", it->m_name );
xml.writeAttribute( "errors", it->m_errorsCount );
xml.writeAttribute( "failures", it->m_failuresCount );
xml.writeAttribute( "tests", it->m_testsCount );
xml.writeAttribute( "hostname", "tbd" );
xml.writeAttribute( "time", "tbd" );
xml.writeAttribute( "timestamp", "tbd" );
@ -209,16 +209,16 @@ namespace Catch
///////////////////////////////////////////////////////////////////////////
void OutputTestCases( XmlWriter& xml, const Stats& stats )
{
std::vector<TestCaseStats>::const_iterator it = stats.testCaseStats.begin();
std::vector<TestCaseStats>::const_iterator itEnd = stats.testCaseStats.end();
std::vector<TestCaseStats>::const_iterator it = stats.m_testCaseStats.begin();
std::vector<TestCaseStats>::const_iterator itEnd = stats.m_testCaseStats.end();
for(; it != itEnd; ++it )
{
xml.writeBlankLine();
xml.writeComment( "Test case" );
XmlWriter::ScopedElement e = xml.scopedElement( "testcase" );
xml.writeAttribute( "classname", it->className );
xml.writeAttribute( "name", it->name );
xml.writeAttribute( "classname", it->m_className );
xml.writeAttribute( "name", it->m_name );
xml.writeAttribute( "time", "tbd" );
OutputTestResult( xml, *it );
@ -229,18 +229,18 @@ namespace Catch
///////////////////////////////////////////////////////////////////////////
void OutputTestResult( XmlWriter& xml, const TestCaseStats& stats )
{
std::vector<TestStats>::const_iterator it = stats.testStats.begin();
std::vector<TestStats>::const_iterator itEnd = stats.testStats.end();
std::vector<TestStats>::const_iterator it = stats.m_testStats.begin();
std::vector<TestStats>::const_iterator itEnd = stats.m_testStats.end();
for(; it != itEnd; ++it )
{
if( it->element != "success" )
if( it->m_element != "success" )
{
XmlWriter::ScopedElement e = xml.scopedElement( it->element );
XmlWriter::ScopedElement e = xml.scopedElement( it->m_element );
xml.writeAttribute( "message", it->message );
xml.writeAttribute( "type", it->resultType );
if( !it->content.empty() )
xml.writeText( it->content );
xml.writeAttribute( "message", it->m_message );
xml.writeAttribute( "type", it->m_resultType );
if( !it->m_content.empty() )
xml.writeText( it->m_content );
}
}
}

View File

@ -28,7 +28,7 @@ namespace Catch
inline int Main( int argc, char * const argv[] )
{
Config config;
ArgParser( argc, argv, config );
ArgParser( argc, argv, config );
if( !config.getMessage().empty() )
{

View File

@ -125,13 +125,13 @@ namespace Catch
if( m_args.size() >= 2 )
{
if( m_args[1] == "xml" )
listSpec = (Config::List::What)( listSpec | Config::List::AsXml );
listSpec = static_cast<Config::List::What>( listSpec | Config::List::AsXml );
else if( m_args[1] == "text" )
listSpec = (Config::List::What)( listSpec | Config::List::AsText );
listSpec = static_cast<Config::List::What>( listSpec | Config::List::AsText );
else
return setErrorMode( m_command + " expected [xml] or [text] but recieved: [" + m_args[1] + "]" );
}
m_config.setListSpec( (Config::List::What)( m_config.getListSpec() | listSpec ) );
m_config.setListSpec( static_cast<Config::List::What>( m_config.getListSpec() | listSpec ) );
}
break;
case modeTest:

View File

@ -150,13 +150,13 @@ namespace Catch
///////////////////////////////////////////////////////////////////////////
List::What listWhat() const
{
return (List::What)( m_listSpec & List::WhatMask );
return static_cast<List::What>( m_listSpec & List::WhatMask );
}
///////////////////////////////////////////////////////////////////////////
List::What listAs() const
{
return (List::What)( m_listSpec & List::AsMask );
return static_cast<List::What>( m_listSpec & List::AsMask );
}
///////////////////////////////////////////////////////////////////////////
@ -166,9 +166,9 @@ namespace Catch
}
///////////////////////////////////////////////////////////////////////////
void setShouldDebugBreak( bool shouldDebugBreak )
void setShouldDebugBreak( bool shouldDebugBreakFlag )
{
m_shouldDebugBreak = shouldDebugBreak;
m_shouldDebugBreak = shouldDebugBreakFlag;
}
///////////////////////////////////////////////////////////////////////////
@ -178,9 +178,9 @@ namespace Catch
}
///////////////////////////////////////////////////////////////////////////
void setShowHelp( bool showHelp )
void setShowHelp( bool showHelpFlag )
{
m_showHelp = showHelp;
m_showHelp = showHelpFlag;
}
///////////////////////////////////////////////////////////////////////////

View File

@ -67,7 +67,7 @@
// The following code snippet taken from:
// http://cocoawithlove.com/2008/03/break-into-debugger.html
#ifdef DEBUG
#if __ppc64__ || __ppc__
#if defined(__ppc64__) || defined(__ppc__)
#define DebugBreak() \
if( Catch::AmIBeingDebugged() ) \
{ \

View File

@ -24,6 +24,10 @@ namespace Catch
///////////////////////////////////////////////////////////////////////////
struct IReporterConfig
{
virtual ~IReporterConfig
()
{}
virtual std::ostream& stream
() const = 0;

View File

@ -18,6 +18,10 @@ namespace Catch
{
struct IRunner
{
virtual ~IRunner
()
{}
virtual void runAll
() = 0;

View File

@ -42,8 +42,16 @@ namespace Catch
struct ITestCaseRegistry
{
virtual void registerTest( const TestCaseInfo& testInfo ) = 0;
virtual const std::vector<TestCaseInfo>& getAllTests() const = 0;
virtual ~ITestCaseRegistry
()
{}
virtual void registerTest
( const TestCaseInfo& testInfo
) = 0;
virtual const std::vector<TestCaseInfo>& getAllTests
() const = 0;
};
}

View File

@ -41,7 +41,7 @@ namespace Catch
if( c != EOF )
{
if( pbase() == epptr() )
m_writer( std::string( 1, (char)c ) );
m_writer( std::string( 1, static_cast<char>( c ) ) );
else
sputc( c );
}

View File

@ -75,7 +75,7 @@ namespace Catch
(
TestFunction fun
)
: fun( fun )
: m_fun( fun )
{}
///////////////////////////////////////////////////////////////////////////
@ -83,7 +83,7 @@ namespace Catch
()
const
{
fun();
m_fun();
}
///////////////////////////////////////////////////////////////////////////
@ -91,7 +91,7 @@ namespace Catch
()
const
{
return new FreeFunctionTestCase( fun );
return new FreeFunctionTestCase( m_fun );
}
///////////////////////////////////////////////////////////////////////////
@ -102,7 +102,7 @@ namespace Catch
const
{
const FreeFunctionTestCase* ffOther = dynamic_cast<const FreeFunctionTestCase*> ( &other );
return ffOther && fun == ffOther->fun;
return ffOther && m_fun == ffOther->m_fun;
}
///////////////////////////////////////////////////////////////////////////
@ -113,11 +113,11 @@ namespace Catch
const
{
const FreeFunctionTestCase* ffOther = dynamic_cast<const FreeFunctionTestCase*> ( &other );
return ffOther && fun < ffOther->fun;
return ffOther && m_fun < ffOther->m_fun;
}
private:
TestFunction fun;
TestFunction m_fun;
};
///////////////////////////////////////////////////////////////////////////

View File

@ -22,34 +22,34 @@ template<typename C>
struct MethodTestCase : ITestCase
{
MethodTestCase( void (C::*method)() )
: method( method )
: m_method( method )
{}
virtual void invoke() const
{
C obj;
(obj.*method)();
(obj.*m_method)();
}
virtual ITestCase* clone() const
{
return new MethodTestCase<C>( method );
return new MethodTestCase<C>( m_method );
}
virtual bool operator == ( const ITestCase& other ) const
{
const MethodTestCase* mtOther = dynamic_cast<const MethodTestCase*>( &other );
return mtOther && method == mtOther->method;
return mtOther && m_method == mtOther->m_method;
}
virtual bool operator < ( const ITestCase& other ) const
{
const MethodTestCase* mtOther = dynamic_cast<const MethodTestCase*>( &other );
return mtOther && &method < &mtOther->method;
return mtOther && &m_method < &mtOther->m_method;
}
private:
void (C::*method)();
void (C::*m_method)();
};
typedef void(*TestFunction)();