mirror of
https://github.com/catchorg/Catch2.git
synced 2025-08-01 12:55:40 +02:00
Refactored internal interfaces to use Totals instead of success/ fail
This commit is contained in:
@@ -57,7 +57,7 @@ namespace Catch
|
||||
{
|
||||
config.getReporter()->StartGroup( "" );
|
||||
runner.runAll();
|
||||
config.getReporter()->EndGroup( "", runner.getSuccessCount(), runner.getFailureCount() );
|
||||
config.getReporter()->EndGroup( "", runner.getTotals().assertions.passed, runner.getTotals().assertions.failed );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -67,19 +67,19 @@ namespace Catch
|
||||
std::vector<std::string>::const_iterator itEnd = config.getTestSpecs().end();
|
||||
for(; it != itEnd; ++it )
|
||||
{
|
||||
size_t prevSuccess = runner.getSuccessCount();
|
||||
size_t prevFail = runner.getFailureCount();
|
||||
Totals prevTotals = runner.getTotals();
|
||||
config.getReporter()->StartGroup( *it );
|
||||
if( runner.runMatching( *it ) == 0 )
|
||||
{
|
||||
// Use reporter?
|
||||
// std::cerr << "\n[Unable to match any test cases with: " << *it << "]" << std::endl;
|
||||
}
|
||||
config.getReporter()->EndGroup( *it, runner.getSuccessCount()-prevSuccess, runner.getFailureCount()-prevFail );
|
||||
Totals diffTotals = runner.getTotals() - prevTotals;
|
||||
config.getReporter()->EndGroup( *it, diffTotals.assertions.passed, diffTotals.assertions.failed );
|
||||
}
|
||||
}
|
||||
|
||||
return static_cast<int>( runner.getFailureCount() );
|
||||
return static_cast<int>( runner.getTotals().assertions.failed );
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
@@ -12,6 +12,8 @@
|
||||
#ifndef TWOBLUECUBES_INTERNAL_CATCH_INTERFACES_RUNNER_H_INCLUDED
|
||||
#define TWOBLUECUBES_INTERNAL_CATCH_INTERFACES_RUNNER_H_INCLUDED
|
||||
|
||||
#include "catch_totals.hpp"
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace Catch
|
||||
@@ -32,10 +34,7 @@ namespace Catch
|
||||
( const std::string& rawTestSpec
|
||||
) = 0;
|
||||
|
||||
virtual std::size_t getSuccessCount
|
||||
() const = 0;
|
||||
|
||||
virtual std:: size_t getFailureCount
|
||||
virtual Totals getTotals
|
||||
() const = 0;
|
||||
|
||||
};
|
||||
|
@@ -391,21 +391,13 @@ namespace Catch
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
virtual std::size_t getSuccessCount
|
||||
virtual Totals getTotals
|
||||
()
|
||||
const
|
||||
{
|
||||
return m_totals.assertions.passed;
|
||||
return m_totals;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
virtual std:: size_t getFailureCount
|
||||
()
|
||||
const
|
||||
{
|
||||
return m_totals.assertions.failed;
|
||||
}
|
||||
|
||||
private: // IResultCapture
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
@@ -21,6 +21,14 @@ namespace Catch
|
||||
: passed( 0 ),
|
||||
failed( 0 )
|
||||
{}
|
||||
|
||||
Counts operator - ( const Counts& other ) const
|
||||
{
|
||||
Counts diff;
|
||||
diff.passed = passed - other.passed;
|
||||
diff.failed = failed - other.failed;
|
||||
return diff;
|
||||
}
|
||||
|
||||
std::size_t passed;
|
||||
std::size_t failed;
|
||||
@@ -28,6 +36,14 @@ namespace Catch
|
||||
|
||||
struct Totals
|
||||
{
|
||||
Totals operator - ( const Totals& other ) const
|
||||
{
|
||||
Totals diff;
|
||||
diff.assertions = assertions - other.assertions;
|
||||
diff.testCases = testCases - other.testCases;
|
||||
return diff;
|
||||
}
|
||||
|
||||
Counts assertions;
|
||||
Counts testCases;
|
||||
};
|
||||
|
Reference in New Issue
Block a user