diff --git a/include/catch.hpp b/include/catch.hpp index 997f3ccc..5d009ee0 100644 --- a/include/catch.hpp +++ b/include/catch.hpp @@ -116,8 +116,8 @@ LeakDetector leakDetector; #define CATCH_INFO( msg ) INTERNAL_CATCH_INFO( msg, "CATCH_INFO" ) #define CATCH_WARN( msg ) INTERNAL_CATCH_MSG( Catch::ResultWas::Warning, Catch::ResultDisposition::ContinueOnFailure, "CATCH_WARN", msg ) #define CATCH_SCOPED_INFO( msg ) INTERNAL_CATCH_INFO( msg, "CATCH_INFO" ) -#define CATCH_CAPTURE( msg ) INTERNAL_CATCH_INFO( #msg " := " << msg, "CATCH_CAPTURE" ) -#define CATCH_SCOPED_CAPTURE( msg ) INTERNAL_CATCH_INFO( #msg " := " << msg, "CATCH_CAPTURE" ) +#define CATCH_CAPTURE( msg ) INTERNAL_CATCH_INFO( #msg " := " << Catch::toString(msg), "CATCH_CAPTURE" ) +#define CATCH_SCOPED_CAPTURE( msg ) INTERNAL_CATCH_INFO( #msg " := " << Catch::toString(msg), "CATCH_CAPTURE" ) #ifdef CATCH_CONFIG_VARIADIC_MACROS #define CATCH_TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE( __VA_ARGS__ ) @@ -185,8 +185,8 @@ LeakDetector leakDetector; #define INFO( msg ) INTERNAL_CATCH_INFO( msg, "INFO" ) #define WARN( msg ) INTERNAL_CATCH_MSG( Catch::ResultWas::Warning, Catch::ResultDisposition::ContinueOnFailure, "WARN", msg ) #define SCOPED_INFO( msg ) INTERNAL_CATCH_INFO( msg, "INFO" ) -#define CAPTURE( msg ) INTERNAL_CATCH_INFO( #msg " := " << msg, "CAPTURE" ) -#define SCOPED_CAPTURE( msg ) INTERNAL_CATCH_INFO( #msg " := " << msg, "CAPTURE" ) +#define CAPTURE( msg ) INTERNAL_CATCH_INFO( #msg " := " << Catch::toString(msg), "CAPTURE" ) +#define SCOPED_CAPTURE( msg ) INTERNAL_CATCH_INFO( #msg " := " << Catch::toString(msg), "CAPTURE" ) #ifdef CATCH_CONFIG_VARIADIC_MACROS #define TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE( __VA_ARGS__ ) diff --git a/projects/SelfTest/Baselines/console.std.approved.txt b/projects/SelfTest/Baselines/console.std.approved.txt index ecd074a5..e5dd3d31 100644 --- a/projects/SelfTest/Baselines/console.std.approved.txt +++ b/projects/SelfTest/Baselines/console.std.approved.txt @@ -890,6 +890,6 @@ with expansion: "first" == "second" =============================================================================== -test cases: 163 | 118 passed | 43 failed | 2 failed as expected -assertions: 953 | 849 passed | 86 failed | 18 failed as expected +test cases: 164 | 119 passed | 43 failed | 2 failed as expected +assertions: 955 | 851 passed | 86 failed | 18 failed as expected diff --git a/projects/SelfTest/Baselines/console.sw.approved.txt b/projects/SelfTest/Baselines/console.sw.approved.txt index 55137b31..72d5dc07 100644 --- a/projects/SelfTest/Baselines/console.sw.approved.txt +++ b/projects/SelfTest/Baselines/console.sw.approved.txt @@ -603,6 +603,32 @@ PASSED: with expansion: true +------------------------------------------------------------------------------- +Capture and info messages + Capture should stringify like assertions +------------------------------------------------------------------------------- +ToStringGeneralTests.cpp: +............................................................................... + +ToStringGeneralTests.cpp:: +PASSED: + REQUIRE( true ) +with message: + i := 2 + +------------------------------------------------------------------------------- +Capture and info messages + Info should NOT stringify the way assertions do +------------------------------------------------------------------------------- +ToStringGeneralTests.cpp: +............................................................................... + +ToStringGeneralTests.cpp:: +PASSED: + REQUIRE( true ) +with message: + 3 + ------------------------------------------------------------------------------- Character pretty printing Specifically escaped @@ -3292,7 +3318,7 @@ with expansion: re>" ------------------------------------------------------------------------------- -Long text is truncted +Long text is truncated ------------------------------------------------------------------------------- TestMain.cpp: ............................................................................... @@ -9324,6 +9350,6 @@ MiscTests.cpp:: PASSED: =============================================================================== -test cases: 163 | 117 passed | 44 failed | 2 failed as expected -assertions: 955 | 849 passed | 88 failed | 18 failed as expected +test cases: 164 | 118 passed | 44 failed | 2 failed as expected +assertions: 957 | 851 passed | 88 failed | 18 failed as expected diff --git a/projects/SelfTest/Baselines/junit.sw.approved.txt b/projects/SelfTest/Baselines/junit.sw.approved.txt index 400b1c8b..41cfb464 100644 --- a/projects/SelfTest/Baselines/junit.sw.approved.txt +++ b/projects/SelfTest/Baselines/junit.sw.approved.txt @@ -1,6 +1,6 @@ - + @@ -83,6 +83,8 @@ ExceptionTests.cpp: + + @@ -250,7 +252,7 @@ ConditionTests.cpp: - + diff --git a/projects/SelfTest/Baselines/xml.sw.approved.txt b/projects/SelfTest/Baselines/xml.sw.approved.txt index 62e3abaf..f242568b 100644 --- a/projects/SelfTest/Baselines/xml.sw.approved.txt +++ b/projects/SelfTest/Baselines/xml.sw.approved.txt @@ -643,6 +643,31 @@ + +
+ + + true + + + true + + + +
+
+ + + true + + + true + + + +
+ +
@@ -3409,7 +3434,7 @@ re>"
- + t.toString(), EndsWith( "... message truncated due to excessive size" ) @@ -9885,7 +9910,7 @@ spanner - + - + diff --git a/projects/SelfTest/ToStringGeneralTests.cpp b/projects/SelfTest/ToStringGeneralTests.cpp index a9fa4b83..bca913fb 100644 --- a/projects/SelfTest/ToStringGeneralTests.cpp +++ b/projects/SelfTest/ToStringGeneralTests.cpp @@ -38,3 +38,17 @@ TEST_CASE( "Character pretty printing" ){ } } } + + +TEST_CASE( "Capture and info messages" ) { + SECTION("Capture should stringify like assertions") { + int i = 2; + CAPTURE(i); + REQUIRE(true); + } + SECTION("Info should NOT stringify the way assertions do") { + int i = 3; + INFO(i); + REQUIRE(true); + } +}