Clean up various minor things

This commit is contained in:
Martin Hořeňovský 2017-08-29 14:02:14 +02:00
parent 5932576f53
commit bcb430b837
7 changed files with 12 additions and 16 deletions

View File

@ -9,6 +9,9 @@
#include "catch_assertionresult.h" #include "catch_assertionresult.h"
namespace Catch { namespace Catch {
AssertionResultData::AssertionResultData(ResultWas::OfType _resultType, LazyExpression const & _lazyExpression):
resultType(_resultType),
lazyExpression(_lazyExpression) {}
std::string AssertionResultData::reconstructExpression() const { std::string AssertionResultData::reconstructExpression() const {

View File

@ -21,10 +21,7 @@ namespace Catch {
{ {
AssertionResultData() = delete; AssertionResultData() = delete;
AssertionResultData( ResultWas::OfType _resultType, LazyExpression const& _lazyExpression ) AssertionResultData( ResultWas::OfType _resultType, LazyExpression const& _lazyExpression );
: resultType( _resultType ),
lazyExpression( _lazyExpression )
{}
ResultWas::OfType resultType = ResultWas::Unknown; ResultWas::OfType resultType = ResultWas::Unknown;
std::string message; std::string message;

View File

@ -47,9 +47,9 @@ namespace Catch {
}; };
LONG CALLBACK FatalConditionHandler::handleVectoredException(PEXCEPTION_POINTERS ExceptionInfo) { LONG CALLBACK FatalConditionHandler::handleVectoredException(PEXCEPTION_POINTERS ExceptionInfo) {
for (int i = 0; i < sizeof(signalDefs) / sizeof(SignalDefs); ++i) { for (auto const& def : signalDefs) {
if (ExceptionInfo->ExceptionRecord->ExceptionCode == signalDefs[i].id) { if (ExceptionInfo->ExceptionRecord->ExceptionCode == def.id) {
reportFatal(signalDefs[i].name); reportFatal(def.name);
} }
} }
// If its not an exception we care about, pass it along. // If its not an exception we care about, pass it along.
@ -123,8 +123,7 @@ namespace Catch {
void FatalConditionHandler::handleSignal( int sig ) { void FatalConditionHandler::handleSignal( int sig ) {
std::string name = "<unknown signal>"; std::string name = "<unknown signal>";
for (std::size_t i = 0; i < sizeof(signalDefs) / sizeof(SignalDefs); ++i) { for (auto const& def : signalDefs) {
SignalDefs &def = signalDefs[i];
if (sig == def.id) { if (sig == def.id) {
name = def.name; name = def.name;
break; break;

View File

@ -21,14 +21,14 @@ namespace Catch {
~ReporterRegistry() override {} ~ReporterRegistry() override {}
IStreamingReporterPtr create( std::string const& name, IConfigPtr const& config ) const override { IStreamingReporterPtr create( std::string const& name, IConfigPtr const& config ) const override {
FactoryMap::const_iterator it = m_factories.find( name ); auto it = m_factories.find( name );
if( it == m_factories.end() ) if( it == m_factories.end() )
return nullptr; return nullptr;
return it->second->create( ReporterConfig( config ) ); return it->second->create( ReporterConfig( config ) );
} }
void registerReporter( std::string const& name, IReporterFactoryPtr const& factory ) { void registerReporter( std::string const& name, IReporterFactoryPtr const& factory ) {
m_factories.insert( { name, factory } ); m_factories.emplace(name, factory);
} }
void registerListener( IReporterFactoryPtr const& factory ) { void registerListener( IReporterFactoryPtr const& factory ) {
m_listeners.push_back( factory ); m_listeners.push_back( factory );

View File

@ -57,8 +57,7 @@ namespace Catch {
std::vector<std::string> tags; std::vector<std::string> tags;
std::string desc, tag; std::string desc, tag;
bool inTag = false; bool inTag = false;
for( std::size_t i = 0; i < _descOrTags.size(); ++i ) { for (char c : _descOrTags) {
char c = _descOrTags[i];
if( !inTag ) { if( !inTag ) {
if( c == '[' ) if( c == '[' )
inTag = true; inTag = true;

View File

@ -10,8 +10,6 @@
#include "catch_common.h" #include "catch_common.h"
#include <stdexcept>
namespace Catch namespace Catch
{ {

View File

@ -174,7 +174,7 @@ namespace Catch {
} }
else { else {
SectionNode& parentNode = *m_sectionStack.back(); SectionNode& parentNode = *m_sectionStack.back();
typename SectionNode::ChildSections::const_iterator it = auto it =
std::find_if( parentNode.childSections.begin(), std::find_if( parentNode.childSections.begin(),
parentNode.childSections.end(), parentNode.childSections.end(),
BySectionInfo( sectionInfo ) ); BySectionInfo( sectionInfo ) );