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
Fix for #179
- Commit
066a6388d6771bfdc71d28bf9158a23a6f7b23a4- Author
- Phil Nash ·
- Parents
ba9b2b5a377b
Changes
include/internal/catch_tostring.hpp | 3 ++- projects/SelfTest/TrickyTests.cpp | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/include/internal/catch_tostring.hpp b/include/internal/catch_tostring.hpp index fef7ad3a..a980504a 100644 --- a/include/internal/catch_tostring.hpp +++ b/include/internal/catch_tostring.hpp @@ -86,7 +86,8 @@ struct StringMaker : template<typename T> struct StringMaker<T*> { - static std::string convert( T const* p ) { + template<typename U> + static std::string convert( U* p ) { if( !p ) return INTERNAL_CATCH_STRINGIFY( NULL ); std::ostringstream oss; diff --git a/projects/SelfTest/TrickyTests.cpp b/projects/SelfTest/TrickyTests.cpp index 97386709..0a81ad83 100644 --- a/projects/SelfTest/TrickyTests.cpp +++ b/projects/SelfTest/TrickyTests.cpp @@ -342,6 +342,28 @@ TEST_CASE( "non streamable - with conv. op", "" ) REQUIRE( s == "7" ); } +inline void foo() {} + +typedef void (*fooptr_t)(); + +TEST_CASE( "Comparing function pointers", "[function pointer]" ) +{ + // This was giving a warning in VS2010 + // #179 + fooptr_t a = foo; + + REQUIRE( a ); + REQUIRE( a == &foo ); +} + +class ClassName {}; + +TEST_CASE( "pointer to class", "" ) +{ + ClassName *p = 0; + REQUIRE( p != 0 ); +} + #ifdef CATCH_CONFIG_CPP11_NULLPTR #include <memory>