Progmasoft Git

catch3

Progmasoft Catch3: an independently maintained C++17 test framework with a parallel runner, property checks, snapshots and structured results.

Clonegit clone https://git.progmasoft.com/catch3

Removed use of std::copy_if (as it's limited to c++11)

Commit
8a05f46a3710ae063ecbdc680061a37e81468f9b
Author
Phil Nash ·
Parents
e73583d556fc

Files · Download .tar.gz

Changes

 include/internal/catch_test_case_registry_impl.hpp | 16 ++++++----------
 single_include/catch.hpp                           | 18 +++++++-----------
 2 files changed, 13 insertions(+), 21 deletions(-)

diff --git a/include/internal/catch_test_case_registry_impl.hpp b/include/internal/catch_test_case_registry_impl.hpp
index ac789a38..fda70aae 100644
--- a/include/internal/catch_test_case_registry_impl.hpp
+++ b/include/internal/catch_test_case_registry_impl.hpp
@@ -53,15 +53,6 @@ namespace Catch {
     bool matchTest( TestCase const& testCase, TestSpec const& testSpec, IConfig const& config ) {
         return testSpec.matches( testCase ) && ( config.allowThrows() || !testCase.throws() );
     }
-    struct TestMatcher {
-        TestMatcher( TestSpec const& testSpec, bool allowThrows ) : m_testSpec( testSpec ), m_allowThrows( allowThrows ) {}
-
-        bool operator()( TestCase const& testCase ) const {
-            return m_testSpec.matches( testCase ) && ( m_allowThrows || !testCase.throws() );
-        }
-        TestSpec m_testSpec;
-        bool m_allowThrows;
-    };
 
     void enforceNoDuplicateTestCases( std::vector<TestCase> const& functions ) {
         std::set<TestCase> seenFunctions;
@@ -82,7 +73,12 @@ namespace Catch {
     
     std::vector<TestCase> filterTests( std::vector<TestCase> const& testCases, TestSpec const& testSpec, IConfig const& config ) {
         std::vector<TestCase> filtered;
-        std::copy_if( testCases.begin(), testCases.end(), std::back_inserter( filtered ), TestMatcher( testSpec, config.allowThrows() ) );
+        filtered.reserve( testCases.size() );
+        for( std::vector<TestCase>::const_iterator it = testCases.begin(), itEnd = testCases.end();
+                it != itEnd;
+                ++it )
+            if( matchTest( *it, testSpec, config ) )
+                filtered.push_back( *it );
         return filtered;
     }
     std::vector<TestCase> const& getAllTestCasesSorted( IConfig const& config ) {
diff --git a/single_include/catch.hpp b/single_include/catch.hpp
index 7724e49e..fcffca19 100644
--- a/single_include/catch.hpp
+++ b/single_include/catch.hpp
@@ -1,6 +1,6 @@
 /*
  *  Catch v1.2.1-develop.12
- *  Generated: 2015-08-07 17:29:52.878958
+ *  Generated: 2015-08-07 17:51:37.651202
  *  ----------------------------------------------------------
  *  This file has been merged from multiple headers. Please don't edit it directly
  *  Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved.
@@ -5920,15 +5920,6 @@ namespace Catch {
     bool matchTest( TestCase const& testCase, TestSpec const& testSpec, IConfig const& config ) {
         return testSpec.matches( testCase ) && ( config.allowThrows() || !testCase.throws() );
     }
-    struct TestMatcher {
-        TestMatcher( TestSpec const& testSpec, bool allowThrows ) : m_testSpec( testSpec ), m_allowThrows( allowThrows ) {}
-
-        bool operator()( TestCase const& testCase ) const {
-            return m_testSpec.matches( testCase ) && ( m_allowThrows || !testCase.throws() );
-        }
-        TestSpec m_testSpec;
-        bool m_allowThrows;
-    };
 
     void enforceNoDuplicateTestCases( std::vector<TestCase> const& functions ) {
         std::set<TestCase> seenFunctions;
@@ -5949,7 +5940,12 @@ namespace Catch {
 
     std::vector<TestCase> filterTests( std::vector<TestCase> const& testCases, TestSpec const& testSpec, IConfig const& config ) {
         std::vector<TestCase> filtered;
-        std::copy_if( testCases.begin(), testCases.end(), std::back_inserter( filtered ), TestMatcher( testSpec, config.allowThrows() ) );
+        filtered.reserve( testCases.size() );
+        for( std::vector<TestCase>::const_iterator it = testCases.begin(), itEnd = testCases.end();
+                it != itEnd;
+                ++it )
+            if( matchTest( *it, testSpec, config ) )
+                filtered.push_back( *it );
         return filtered;
     }
     std::vector<TestCase> const& getAllTestCasesSorted( IConfig const& config ) {