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

Matchers macro uses Catch::Matchers namespace internally - so it doesn't have to be declared with "using" first

Commit
7035b558322c1ff6d41482758361cbc0dfabaa75
Author
Phil Nash ·
Parents
1c98fc98effe

Files · Download .tar.gz

Changes

 include/internal/catch_capture.hpp               |  2 +-
 include/internal/catch_config.hpp                |  1 -
 projects/SelfTest/MiscTests.cpp                  | 12 ++++++++++--
 projects/SelfTest/TestMain.cpp                   |  4 ++--
 projects/XCode4/OCTest/OCTest/CatchOCTestCase.mm |  1 -
 5 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/include/internal/catch_capture.hpp b/include/internal/catch_capture.hpp
index 0724b089..90cd1982 100644
--- a/include/internal/catch_capture.hpp
+++ b/include/internal/catch_capture.hpp
@@ -126,7 +126,7 @@ inline bool isTrue( bool value ){ return value; }
 ///////////////////////////////////////////////////////////////////////////////
 #define INTERNAL_CHECK_THAT( arg, matcher, stopOnFailure, macroName ) \
     do{ try{ \
-        INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::ExpressionBuilder( CATCH_INTERNAL_LINEINFO, macroName, #arg " " #matcher, false ).acceptMatcher( matcher, arg, #matcher ) ), stopOnFailure, false ); \
+        INTERNAL_CATCH_ACCEPT_EXPR( ( Catch::ExpressionBuilder( CATCH_INTERNAL_LINEINFO, macroName, #arg " " #matcher, false ).acceptMatcher( ::Catch::Matchers::matcher, arg, #matcher ) ), stopOnFailure, false ); \
     }catch( Catch::TestFailureException& ){ \
         throw; \
     } catch( ... ){ \
diff --git a/include/internal/catch_config.hpp b/include/internal/catch_config.hpp
index d6bd0819..374f2e9e 100644
--- a/include/internal/catch_config.hpp
+++ b/include/internal/catch_config.hpp
@@ -178,7 +178,6 @@ namespace Catch {
         mutable std::ostream m_os;
         Include::What m_includeWhat;
         std::string m_name;
-        
     };
     
 } // end namespace Catch
diff --git a/projects/SelfTest/MiscTests.cpp b/projects/SelfTest/MiscTests.cpp
index 95389f14..d8c45c70 100644
--- a/projects/SelfTest/MiscTests.cpp
+++ b/projects/SelfTest/MiscTests.cpp
@@ -247,8 +247,6 @@ inline const char* testStringForMatching()
     return "this string contains 'abc' as a substring";
 }
 
-using namespace Catch::Matchers;
-
 TEST_CASE("./succeeding/matchers", "") 
 {
     REQUIRE_THAT( testStringForMatching(), Contains( "string" ) );    
@@ -272,3 +270,13 @@ TEST_CASE("./failing/matchers/EndsWith", "")
 {
     CHECK_THAT( testStringForMatching(), EndsWith( "this" ) );
 }
+
+TEST_CASE("./failing/matchers/Equals", "")
+{
+    CHECK_THAT( testStringForMatching(), Equals( "something else" ) );
+}
+
+TEST_CASE("./succeeding/matchers/Equals", "")
+{
+    CHECK_THAT( testStringForMatching(), Equals( "this string contains 'abc' as a substring" ) );
+}
diff --git a/projects/SelfTest/TestMain.cpp b/projects/SelfTest/TestMain.cpp
index 530cc9ca..97a35886 100644
--- a/projects/SelfTest/TestMain.cpp
+++ b/projects/SelfTest/TestMain.cpp
@@ -33,7 +33,7 @@ TEST_CASE( "selftest/main", "Runs all Catch self tests and checks their results"
         SECTION(    "selftest/test counts/succeeding tests", 
                     "Number of 'succeeding' tests is fixed" ) {
             runner.runMatching( "./succeeding/*" );
-            CHECK( runner.getTotals().assertions.passed == 276 );
+            CHECK( runner.getTotals().assertions.passed == 277 );
             CHECK( runner.getTotals().assertions.failed == 0 );
         }
 
@@ -41,7 +41,7 @@ TEST_CASE( "selftest/main", "Runs all Catch self tests and checks their results"
                     "Number of 'failing' tests is fixed" ) {
             runner.runMatching( "./failing/*" );        
             CHECK( runner.getTotals().assertions.passed == 0 );
-            CHECK( runner.getTotals().assertions.failed == 71 );
+            CHECK( runner.getTotals().assertions.failed == 72 );
         }
     }
 }
diff --git a/projects/XCode4/OCTest/OCTest/CatchOCTestCase.mm b/projects/XCode4/OCTest/OCTest/CatchOCTestCase.mm
index ed84a5be..4b67efee 100644
--- a/projects/XCode4/OCTest/OCTest/CatchOCTestCase.mm
+++ b/projects/XCode4/OCTest/OCTest/CatchOCTestCase.mm
@@ -60,7 +60,6 @@ void useObject( const T& object ){}
 template<typename T>
 void useObject( const T* object ){}
 
-using namespace Catch::Matchers;
 OC_TEST_CASE( "OCTest/matchers", "Matches work with OC types (NSString so far)" )
 {
     REQUIRE_THAT( @"This is a string", Equals( @"This is a string" ) );