From 6817bb099db44744cc32da193cbe710ffcead8b8 Mon Sep 17 00:00:00 2001 From: Phil Nash Date: Tue, 30 Dec 2014 18:24:31 +0000 Subject: [PATCH] Fixed up xml reporter and rebased --- include/internal/catch_totals.hpp | 3 + include/reporters/catch_reporter_xml.hpp | 11 ++-- .../Baselines/console.std.approved.txt | 2 +- .../Baselines/console.sw.approved.txt | 21 ++++++- .../SelfTest/Baselines/junit.sw.approved.txt | 3 +- .../SelfTest/Baselines/xml.sw.approved.txt | 55 +++++++++++++------ projects/SelfTest/TestMain.cpp | 5 ++ 7 files changed, 73 insertions(+), 27 deletions(-) diff --git a/include/internal/catch_totals.hpp b/include/internal/catch_totals.hpp index 75386ae8..551e2947 100644 --- a/include/internal/catch_totals.hpp +++ b/include/internal/catch_totals.hpp @@ -35,6 +35,9 @@ namespace Catch { bool allPassed() const { return failed == 0 && failedButOk == 0; } + bool allOk() const { + return failed == 0; + } std::size_t passed; std::size_t failed; diff --git a/include/reporters/catch_reporter_xml.hpp b/include/reporters/catch_reporter_xml.hpp index 1b7c0199..08971d1f 100644 --- a/include/reporters/catch_reporter_xml.hpp +++ b/include/reporters/catch_reporter_xml.hpp @@ -99,7 +99,7 @@ namespace Catch { if( assertionResult.hasExpression() ) { m_xml.startElement( "Expression" ) .writeAttribute( "success", assertionResult.succeeded() ) - .writeAttribute( "type", assertionResult.getTestMacroName() ) +// .writeAttribute( "type", assertionResult.getTestMacroName() ) .writeAttribute( "filename", assertionResult.getSourceInfo().file ) .writeAttribute( "line", assertionResult.getSourceInfo().line ); @@ -111,8 +111,6 @@ namespace Catch { // And... Print a result applicable to each result type. switch( assertionResult.getResultType() ) { - default: - break; case ResultWas::ThrewException: m_xml.scopedElement( "Exception" ) .writeAttribute( "filename", assertionResult.getSourceInfo().file ) @@ -130,13 +128,14 @@ namespace Catch { .writeText( assertionResult.getMessage() ); break; case ResultWas::Warning: - m_xml.scopedElement( "Warning" ) - .writeText( assertionResult.getMessage() ); + // Warning will already have been written break; case ResultWas::ExplicitFailure: m_xml.scopedElement( "Failure" ) .writeText( assertionResult.getMessage() ); break; + default: + break; } if( assertionResult.hasExpression() ) @@ -163,7 +162,7 @@ namespace Catch { virtual void testCaseEnded( TestCaseStats const& testCaseStats ) { StreamingReporterBase::testCaseEnded( testCaseStats ); XmlWriter::ScopedElement e = m_xml.scopedElement( "OverallResult" ); - e.writeAttribute( "success", testCaseStats.totals.assertions.allPassed() ); + e.writeAttribute( "success", testCaseStats.totals.assertions.allOk() ); if ( m_config->showDurations() == ShowDurations::Always ) e.writeAttribute( "durationInSeconds", m_testCaseTimer.getElapsedSeconds() ); diff --git a/projects/SelfTest/Baselines/console.std.approved.txt b/projects/SelfTest/Baselines/console.std.approved.txt index 76e28c32..87319a67 100644 --- a/projects/SelfTest/Baselines/console.std.approved.txt +++ b/projects/SelfTest/Baselines/console.std.approved.txt @@ -787,5 +787,5 @@ with expansion: =============================================================================== test cases: 149 | 110 passed | 38 failed | 1 failed as expected -assertions: 751 | 659 passed | 79 failed | 13 failed as expected +assertions: 753 | 661 passed | 79 failed | 13 failed as expected diff --git a/projects/SelfTest/Baselines/console.sw.approved.txt b/projects/SelfTest/Baselines/console.sw.approved.txt index cf360ece..0c9a8ac9 100644 --- a/projects/SelfTest/Baselines/console.sw.approved.txt +++ b/projects/SelfTest/Baselines/console.sw.approved.txt @@ -4632,6 +4632,25 @@ PASSED: with expansion: "abcdefcg" == "abcdefcg" +------------------------------------------------------------------------------- +replaceInPlace + escape ' +------------------------------------------------------------------------------- +TestMain.cpp: +............................................................................... + +TestMain.cpp:: +PASSED: + CHECK( replaceInPlace( s, "'", "|'" ) ) +with expansion: + true + +TestMain.cpp:: +PASSED: + CHECK( s == "didn|'t" ) +with expansion: + "didn|'t" == "didn|'t" + hello hello ------------------------------------------------------------------------------- @@ -7798,5 +7817,5 @@ with expansion: =============================================================================== test cases: 149 | 94 passed | 54 failed | 1 failed as expected -assertions: 771 | 659 passed | 99 failed | 13 failed as expected +assertions: 773 | 661 passed | 99 failed | 13 failed as expected diff --git a/projects/SelfTest/Baselines/junit.sw.approved.txt b/projects/SelfTest/Baselines/junit.sw.approved.txt index 8579d908..ba3f1799 100644 --- a/projects/SelfTest/Baselines/junit.sw.approved.txt +++ b/projects/SelfTest/Baselines/junit.sw.approved.txt @@ -1,5 +1,5 @@ - + @@ -491,6 +491,7 @@ MiscTests.cpp: + hello diff --git a/projects/SelfTest/Baselines/xml.sw.approved.txt b/projects/SelfTest/Baselines/xml.sw.approved.txt index 87c48b13..f05a2726 100644 --- a/projects/SelfTest/Baselines/xml.sw.approved.txt +++ b/projects/SelfTest/Baselines/xml.sw.approved.txt @@ -531,7 +531,7 @@ 1.3 == Approx( 1.301 ) - + @@ -1541,7 +1541,7 @@ - + @@ -2775,7 +2775,7 @@ this is a warning - + @@ -2873,7 +2873,7 @@
- +
@@ -2984,7 +2984,7 @@ - + @@ -3016,7 +3016,7 @@ toString(p): 0x - +
@@ -3117,7 +3117,7 @@
- +
@@ -3219,7 +3219,7 @@ - + @@ -3323,7 +3323,7 @@
- +
@@ -3525,19 +3525,19 @@ - + This one ran - + - + - + @@ -4829,10 +4829,29 @@ four"
+
+ + + replaceInPlace( s, "'", "|'" ) + + + true + + + + + s == "didn|'t" + + + "didn|'t" == "didn|'t" + + + +
- + @@ -5883,13 +5902,13 @@ there" Uncomment the code in this test to check that it gives a sensible compiler error - + Uncomment the code in this test to check that it gives a sensible compiler error - + @@ -8067,7 +8086,7 @@ there"
- + - + diff --git a/projects/SelfTest/TestMain.cpp b/projects/SelfTest/TestMain.cpp index 154a2994..4b60a4f5 100644 --- a/projects/SelfTest/TestMain.cpp +++ b/projects/SelfTest/TestMain.cpp @@ -374,6 +374,11 @@ TEST_CASE( "replaceInPlace", "" ) { CHECK_FALSE( replaceInPlace( letters, "x", "z" ) ); CHECK( letters == letters ); } + SECTION( "escape '" ) { + std::string s = "didn't"; + CHECK( replaceInPlace( s, "'", "|'" ) ); + CHECK( s == "didn|'t" ); + } } // !TBD: This will be folded into Text class