From 7035b558322c1ff6d41482758361cbc0dfabaa75 Mon Sep 17 00:00:00 2001 From: Phil Nash Date: Thu, 24 May 2012 08:29:03 +0100 Subject: [PATCH] Matchers macro uses Catch::Matchers namespace internally - so it doesn't have to be declared with "using" first --- 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 0724b08..90cd198 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 d6bd081..374f2e9 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 95389f1..d8c45c7 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 530cc9c..97a3588 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 ed84a5b..4b67efe 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 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" ) );