From bcb430b8372eacb2c091a93327724eb8221e8c33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ho=C5=99e=C5=88ovsk=C3=BD?= Date: Tue, 29 Aug 2017 14:02:14 +0200 Subject: [PATCH] Clean up various minor things --- include/internal/catch_assertionresult.cpp | 3 +++ include/internal/catch_assertionresult.h | 5 +---- include/internal/catch_fatal_condition.cpp | 9 ++++----- include/internal/catch_reporter_registry.hpp | 4 ++-- include/internal/catch_test_case_info.cpp | 3 +-- include/internal/catch_wildcard_pattern.hpp | 2 -- include/reporters/catch_reporter_bases.hpp | 2 +- 7 files changed, 12 insertions(+), 16 deletions(-) diff --git a/include/internal/catch_assertionresult.cpp b/include/internal/catch_assertionresult.cpp index 776fdc72..ea416856 100644 --- a/include/internal/catch_assertionresult.cpp +++ b/include/internal/catch_assertionresult.cpp @@ -9,6 +9,9 @@ #include "catch_assertionresult.h" namespace Catch { + AssertionResultData::AssertionResultData(ResultWas::OfType _resultType, LazyExpression const & _lazyExpression): + resultType(_resultType), + lazyExpression(_lazyExpression) {} std::string AssertionResultData::reconstructExpression() const { diff --git a/include/internal/catch_assertionresult.h b/include/internal/catch_assertionresult.h index b1177fa4..dfa2fab0 100644 --- a/include/internal/catch_assertionresult.h +++ b/include/internal/catch_assertionresult.h @@ -21,10 +21,7 @@ namespace Catch { { AssertionResultData() = delete; - AssertionResultData( ResultWas::OfType _resultType, LazyExpression const& _lazyExpression ) - : resultType( _resultType ), - lazyExpression( _lazyExpression ) - {} + AssertionResultData( ResultWas::OfType _resultType, LazyExpression const& _lazyExpression ); ResultWas::OfType resultType = ResultWas::Unknown; std::string message; diff --git a/include/internal/catch_fatal_condition.cpp b/include/internal/catch_fatal_condition.cpp index 51773f42..3de65f73 100644 --- a/include/internal/catch_fatal_condition.cpp +++ b/include/internal/catch_fatal_condition.cpp @@ -47,9 +47,9 @@ namespace Catch { }; LONG CALLBACK FatalConditionHandler::handleVectoredException(PEXCEPTION_POINTERS ExceptionInfo) { - for (int i = 0; i < sizeof(signalDefs) / sizeof(SignalDefs); ++i) { - if (ExceptionInfo->ExceptionRecord->ExceptionCode == signalDefs[i].id) { - reportFatal(signalDefs[i].name); + for (auto const& def : signalDefs) { + if (ExceptionInfo->ExceptionRecord->ExceptionCode == def.id) { + reportFatal(def.name); } } // If its not an exception we care about, pass it along. @@ -123,8 +123,7 @@ namespace Catch { void FatalConditionHandler::handleSignal( int sig ) { std::string name = ""; - for (std::size_t i = 0; i < sizeof(signalDefs) / sizeof(SignalDefs); ++i) { - SignalDefs &def = signalDefs[i]; + for (auto const& def : signalDefs) { if (sig == def.id) { name = def.name; break; diff --git a/include/internal/catch_reporter_registry.hpp b/include/internal/catch_reporter_registry.hpp index 0c015fb9..c3bf3b61 100644 --- a/include/internal/catch_reporter_registry.hpp +++ b/include/internal/catch_reporter_registry.hpp @@ -21,14 +21,14 @@ namespace Catch { ~ReporterRegistry() 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() ) return nullptr; return it->second->create( ReporterConfig( config ) ); } void registerReporter( std::string const& name, IReporterFactoryPtr const& factory ) { - m_factories.insert( { name, factory } ); + m_factories.emplace(name, factory); } void registerListener( IReporterFactoryPtr const& factory ) { m_listeners.push_back( factory ); diff --git a/include/internal/catch_test_case_info.cpp b/include/internal/catch_test_case_info.cpp index d97b5996..54ecc2b6 100644 --- a/include/internal/catch_test_case_info.cpp +++ b/include/internal/catch_test_case_info.cpp @@ -57,8 +57,7 @@ namespace Catch { std::vector tags; std::string desc, tag; bool inTag = false; - for( std::size_t i = 0; i < _descOrTags.size(); ++i ) { - char c = _descOrTags[i]; + for (char c : _descOrTags) { if( !inTag ) { if( c == '[' ) inTag = true; diff --git a/include/internal/catch_wildcard_pattern.hpp b/include/internal/catch_wildcard_pattern.hpp index e163650c..4dae7171 100644 --- a/include/internal/catch_wildcard_pattern.hpp +++ b/include/internal/catch_wildcard_pattern.hpp @@ -10,8 +10,6 @@ #include "catch_common.h" -#include - namespace Catch { diff --git a/include/reporters/catch_reporter_bases.hpp b/include/reporters/catch_reporter_bases.hpp index cfba9415..1c7efb64 100644 --- a/include/reporters/catch_reporter_bases.hpp +++ b/include/reporters/catch_reporter_bases.hpp @@ -174,7 +174,7 @@ namespace Catch { } else { SectionNode& parentNode = *m_sectionStack.back(); - typename SectionNode::ChildSections::const_iterator it = + auto it = std::find_if( parentNode.childSections.begin(), parentNode.childSections.end(), BySectionInfo( sectionInfo ) );