mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-26 07:16:10 +01:00
Added Totals class and started using it
This commit is contained in:
parent
2cc9b0dba1
commit
5ddf794fbc
@ -18,6 +18,7 @@
|
||||
#include "catch_test_registry.hpp"
|
||||
#include "catch_test_case_info.hpp"
|
||||
#include "catch_capture.hpp"
|
||||
#include "catch_totals.hpp"
|
||||
|
||||
#include <set>
|
||||
#include <string>
|
||||
@ -303,8 +304,6 @@ namespace Catch
|
||||
)
|
||||
: m_runningTest( NULL ),
|
||||
m_config( config ),
|
||||
m_successes( 0 ),
|
||||
m_failures( 0 ),
|
||||
m_reporter( m_config.getReporter() ),
|
||||
m_prevRunner( &Hub::getRunner() ),
|
||||
m_prevResultCapture( &Hub::getResultCapture() )
|
||||
@ -318,7 +317,7 @@ namespace Catch
|
||||
~Runner
|
||||
()
|
||||
{
|
||||
m_reporter->EndTesting( m_successes, m_failures );
|
||||
m_reporter->EndTesting( m_totals.assertions.passed, m_totals.assertions.failed );
|
||||
Hub::setRunner( m_prevRunner );
|
||||
Hub::setResultCapture( m_prevResultCapture );
|
||||
}
|
||||
@ -364,8 +363,7 @@ namespace Catch
|
||||
const TestCaseInfo& testInfo
|
||||
)
|
||||
{
|
||||
std::size_t prevSuccessCount = m_successes;
|
||||
std::size_t prevFailureCount = m_failures;
|
||||
Totals prevTotals = m_totals;
|
||||
|
||||
std::string redirectedCout;
|
||||
std::string redirectedCerr;
|
||||
@ -389,7 +387,7 @@ namespace Catch
|
||||
delete m_runningTest;
|
||||
m_runningTest = NULL;
|
||||
|
||||
m_reporter->EndTestCase( testInfo, m_successes - prevSuccessCount, m_failures - prevFailureCount, redirectedCout, redirectedCerr );
|
||||
m_reporter->EndTestCase( testInfo, m_totals.assertions.passed - prevTotals.assertions.passed, m_totals.assertions.failed - prevTotals.assertions.failed, redirectedCout, redirectedCerr );
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
@ -397,7 +395,7 @@ namespace Catch
|
||||
()
|
||||
const
|
||||
{
|
||||
return m_successes;
|
||||
return m_totals.assertions.passed;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
@ -405,7 +403,7 @@ namespace Catch
|
||||
()
|
||||
const
|
||||
{
|
||||
return m_failures;
|
||||
return m_totals.assertions.failed;
|
||||
}
|
||||
|
||||
private: // IResultCapture
|
||||
@ -456,11 +454,11 @@ namespace Catch
|
||||
{
|
||||
if( result.getResultType() == ResultWas::Ok )
|
||||
{
|
||||
m_successes++;
|
||||
m_totals.assertions.passed++;
|
||||
}
|
||||
else if( !result.ok() )
|
||||
{
|
||||
m_failures++;
|
||||
m_totals.assertions.failed++;
|
||||
|
||||
std::vector<ResultInfo>::const_iterator it = m_info.begin();
|
||||
std::vector<ResultInfo>::const_iterator itEnd = m_info.end();
|
||||
@ -494,8 +492,8 @@ namespace Catch
|
||||
|
||||
m_currentResult.setFileAndLine( filename, line );
|
||||
m_reporter->StartSection( name, description );
|
||||
successes = m_successes;
|
||||
failures = m_failures;
|
||||
successes = m_totals.assertions.passed;
|
||||
failures = m_totals.assertions.failed;
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -509,7 +507,7 @@ namespace Catch
|
||||
)
|
||||
{
|
||||
m_runningTest->endSection( name );
|
||||
m_reporter->EndSection( name, m_successes - prevSuccesses, m_failures - prevFailures );
|
||||
m_reporter->EndSection( name, m_totals.assertions.passed - prevSuccesses, m_totals.assertions.failed - prevFailures );
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
@ -615,8 +613,7 @@ namespace Catch
|
||||
ResultInfo m_lastResult;
|
||||
|
||||
const Config& m_config;
|
||||
std::size_t m_successes;
|
||||
std::size_t m_failures;
|
||||
Totals m_totals;
|
||||
IReporter* m_reporter;
|
||||
std::vector<ScopedInfo*> m_scopedInfos;
|
||||
std::vector<ResultInfo> m_info;
|
||||
|
36
include/internal/catch_totals.hpp
Normal file
36
include/internal/catch_totals.hpp
Normal file
@ -0,0 +1,36 @@
|
||||
//
|
||||
// catch_totals.hpp
|
||||
// Catch
|
||||
//
|
||||
// Created by Phil Nash on 23/02/2012.
|
||||
// Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#ifndef TWOBLUECUBES_CATCH_TOTALS_HPP_INCLUDED
|
||||
#define TWOBLUECUBES_CATCH_TOTALS_HPP_INCLUDED
|
||||
|
||||
namespace Catch
|
||||
{
|
||||
struct Counts
|
||||
{
|
||||
Counts
|
||||
()
|
||||
: passed( 0 ),
|
||||
failed( 0 )
|
||||
{}
|
||||
|
||||
std::size_t passed;
|
||||
std::size_t failed;
|
||||
};
|
||||
|
||||
struct Totals
|
||||
{
|
||||
Counts assertions;
|
||||
Counts testCases;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // TWOBLUECUBES_CATCH_TOTALS_HPP_INCLUDED
|
@ -83,6 +83,7 @@
|
||||
4A6D0C66149B3E3D00DB3EAA /* catch_reporter_basic.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_reporter_basic.hpp; sourceTree = "<group>"; };
|
||||
4A6D0C67149B3E3D00DB3EAA /* catch_reporter_junit.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_reporter_junit.hpp; sourceTree = "<group>"; };
|
||||
4A6D0C68149B3E3D00DB3EAA /* catch_reporter_xml.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_reporter_xml.hpp; sourceTree = "<group>"; };
|
||||
4A7ADB4314F631E10094FE10 /* catch_totals.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_totals.hpp; sourceTree = "<group>"; };
|
||||
4AE1840A14EE4F230066340D /* catch_self_test.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = catch_self_test.cpp; path = ../../../SelfTest/catch_self_test.cpp; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
@ -187,6 +188,7 @@
|
||||
4A6D0C62149B3E3D00DB3EAA /* catch_test_case_registry_impl.hpp */,
|
||||
4A6D0C63149B3E3D00DB3EAA /* catch_test_registry.hpp */,
|
||||
4A6D0C64149B3E3D00DB3EAA /* catch_xmlwriter.hpp */,
|
||||
4A7ADB4314F631E10094FE10 /* catch_totals.hpp */,
|
||||
);
|
||||
name = internal;
|
||||
path = ../../../../include/internal;
|
||||
|
Loading…
Reference in New Issue
Block a user