Change reporting of CAPTURE'd variables
Info is not changed, intentionally.
Closes #639
diff --git a/include/catch.hpp b/include/catch.hpp
index 997f3cc..5d009ee 100644
--- a/include/catch.hpp
+++ b/include/catch.hpp
@@ -116,8 +116,8 @@
#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 @@
#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 ecd074a..e5dd3d3 100644
--- a/projects/SelfTest/Baselines/console.std.approved.txt
+++ b/projects/SelfTest/Baselines/console.std.approved.txt
@@ -890,6 +890,6 @@
"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 55137b3..72d5dc0 100644
--- a/projects/SelfTest/Baselines/console.sw.approved.txt
+++ b/projects/SelfTest/Baselines/console.sw.approved.txt
@@ -604,6 +604,32 @@
true
-------------------------------------------------------------------------------
+Capture and info messages
+ Capture should stringify like assertions
+-------------------------------------------------------------------------------
+ToStringGeneralTests.cpp:<line number>
+...............................................................................
+
+ToStringGeneralTests.cpp:<line number>:
+PASSED:
+ REQUIRE( true )
+with message:
+ i := 2
+
+-------------------------------------------------------------------------------
+Capture and info messages
+ Info should NOT stringify the way assertions do
+-------------------------------------------------------------------------------
+ToStringGeneralTests.cpp:<line number>
+...............................................................................
+
+ToStringGeneralTests.cpp:<line number>:
+PASSED:
+ REQUIRE( true )
+with message:
+ 3
+
+-------------------------------------------------------------------------------
Character pretty printing
Specifically escaped
-------------------------------------------------------------------------------
@@ -3292,7 +3318,7 @@
re>"
-------------------------------------------------------------------------------
-Long text is truncted
+Long text is truncated
-------------------------------------------------------------------------------
TestMain.cpp:<line number>
...............................................................................
@@ -9324,6 +9350,6 @@
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 400b1c8..41cfb46 100644
--- a/projects/SelfTest/Baselines/junit.sw.approved.txt
+++ b/projects/SelfTest/Baselines/junit.sw.approved.txt
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuitesspanner>
- <testsuite name="<exe-name>" errors="13" failures="76" tests="956" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
+ <testsuite name="<exe-name>" errors="13" failures="76" tests="958" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
<testcase classname="global" name="# A test name that starts with a #" time="{duration}"/>
<testcase classname="global" name="#542" time="{duration}"/>
<testcase classname="global" name="#809" time="{duration}"/>
@@ -83,6 +83,8 @@
<testcase classname="Assertions then sections" name="A section" time="{duration}"/>
<testcase classname="Assertions then sections" name="A section/Another section" time="{duration}"/>
<testcase classname="Assertions then sections" name="A section/Another other section" time="{duration}"/>
+ <testcase classname="Capture and info messages" name="Capture should stringify like assertions" time="{duration}"/>
+ <testcase classname="Capture and info messages" name="Info should NOT stringify the way assertions do" time="{duration}"/>
<testcase classname="Character pretty printing" name="Specifically escaped" time="{duration}"/>
<testcase classname="Character pretty printing" name="General chars" time="{duration}"/>
<testcase classname="Character pretty printing" name="Low ASCII" time="{duration}"/>
@@ -250,7 +252,7 @@
<testcase classname="Long strings can be wrapped" name="With wrap-before/ after characters/No wrapping" time="{duration}"/>
<testcase classname="Long strings can be wrapped" name="With wrap-before/ after characters/Wrap before" time="{duration}"/>
<testcase classname="Long strings can be wrapped" name="With wrap-before/ after characters/Wrap after" time="{duration}"/>
- <testcase classname="global" name="Long text is truncted" time="{duration}"/>
+ <testcase classname="global" name="Long text is truncated" time="{duration}"/>
<testcase classname="global" name="ManuallyRegistered" time="{duration}"/>
<testcase classname="global" name="Matchers can be (AllOf) composed with the && operator" time="{duration}"/>
<testcase classname="global" name="Matchers can be (AnyOf) composed with the || operator" time="{duration}"/>
diff --git a/projects/SelfTest/Baselines/xml.sw.approved.txt b/projects/SelfTest/Baselines/xml.sw.approved.txt
index 62e3aba..f242568 100644
--- a/projects/SelfTest/Baselines/xml.sw.approved.txt
+++ b/projects/SelfTest/Baselines/xml.sw.approved.txt
@@ -643,6 +643,31 @@
</Section>
<OverallResult success="true"/>
</TestCase>
+ <TestCase name="Capture and info messages" filename="projects/<exe-name>/ToStringGeneralTests.cpp" >
+ <Section name="Capture should stringify like assertions" filename="projects/<exe-name>/ToStringGeneralTests.cpp" >
+ <Expression success="true" type="REQUIRE" filename="projects/<exe-name>/ToStringGeneralTests.cpp" >
+ <Original>
+ true
+ </Original>
+ <Expanded>
+ true
+ </Expanded>
+ </Expression>
+ <OverallResults successes="1" failures="0" expectedFailures="0"/>
+ </Section>
+ <Section name="Info should NOT stringify the way assertions do" filename="projects/<exe-name>/ToStringGeneralTests.cpp" >
+ <Expression success="true" type="REQUIRE" filename="projects/<exe-name>/ToStringGeneralTests.cpp" >
+ <Original>
+ true
+ </Original>
+ <Expanded>
+ true
+ </Expanded>
+ </Expression>
+ <OverallResults successes="1" failures="0" expectedFailures="0"/>
+ </Section>
+ <OverallResult success="true"/>
+ </TestCase>
<TestCase name="Character pretty printing" filename="projects/<exe-name>/ToStringGeneralTests.cpp" >
<Section name="Specifically escaped" filename="projects/<exe-name>/ToStringGeneralTests.cpp" >
<Expression success="true" type="CHECK" filename="projects/<exe-name>/ToStringGeneralTests.cpp" >
@@ -3409,7 +3434,7 @@
</Section>
<OverallResult success="true"/>
</TestCase>
- <TestCase name="Long text is truncted" tags="[Text][Truncated]" filename="projects/<exe-name>/TestMain.cpp" >
+ <TestCase name="Long text is truncated" tags="[Text][Truncated]" filename="projects/<exe-name>/TestMain.cpp" >
<Expression success="true" type="CHECK_THAT" filename="projects/<exe-name>/TestMain.cpp" >
<Original>
t.toString(), EndsWith( "... message truncated due to excessive size" )
@@ -9885,7 +9910,7 @@
</Section>
<OverallResult success="true"/>
</TestCase>
- <OverallResults successes="849" failures="89" expectedFailures="18"/>
+ <OverallResults successes="851" failures="89" expectedFailures="18"/>
</Group>
- <OverallResults successes="849" failures="88" expectedFailures="18"/>
+ <OverallResults successes="851" failures="88" expectedFailures="18"/>
</Catch>
diff --git a/projects/SelfTest/ToStringGeneralTests.cpp b/projects/SelfTest/ToStringGeneralTests.cpp
index a9fa4b8..bca913f 100644
--- a/projects/SelfTest/ToStringGeneralTests.cpp
+++ b/projects/SelfTest/ToStringGeneralTests.cpp
@@ -38,3 +38,17 @@
}
}
}
+
+
+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);
+ }
+}