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
Fixed Xml encoding
- Commit
d6e59cd56f196eb40cbec3223531ee8d98e8ac8f- Author
- Phil Nash ·
- Parents
6de135c63aad
Changes
include/internal/catch_xmlwriter.hpp | 95 ++- .../SelfTest/Baselines/console.std.approved.txt | 4 +- .../SelfTest/Baselines/console.sw.approved.txt | 126 ++- projects/SelfTest/Baselines/junit.sw.approved.txt | 10 +- projects/SelfTest/Baselines/xml.sw.approved.txt | 943 ++++++++++++--------- projects/SelfTest/MiscTests.cpp | 37 + 6 files changed, 762 insertions(+), 453 deletions(-) diff --git a/include/internal/catch_xmlwriter.hpp b/include/internal/catch_xmlwriter.hpp index 3355f4d3..5f2e87e5 100644 --- a/include/internal/catch_xmlwriter.hpp +++ b/include/internal/catch_xmlwriter.hpp @@ -14,9 +14,65 @@ #include <sstream> #include <string> #include <vector> +#include <iomanip> namespace Catch { + class XmlEncode { + public: + enum ForWhat { ForTextNodes, ForAttributes }; + + XmlEncode( std::string const& str, ForWhat forWhat = ForTextNodes ) + : m_str( str ), + m_forWhat( forWhat ) + {} + + void encodeTo( std::ostream& os ) const { + + // Apostrophe escaping not necessary if we always use " to write attributes + // (see: http://www.w3.org/TR/xml/#syntax) + + for( std::size_t i = 0; i < m_str.size(); ++ i ) { + char c = m_str[i]; + switch( c ) { + case '<': os << "<"; break; + case '&': os << "&"; break; + + case '>': + // See: http://www.w3.org/TR/xml/#syntax + if( i > 2 && m_str[i-1] == ']' && m_str[i-2] == ']' ) + os << ">"; + else + os << c; + break; + + case '\"': + if( m_forWhat == ForAttributes ) + os << """; + else + os << c; + break; + + default: + // Escape control chars - based on contribution by @espenalb in PR #465 + if ( ( c < '\x09' ) || ( c > '\x0D' && c < '\x20') || c=='\x7F' ) + os << "&#x" << std::uppercase << std::hex << static_cast<int>( c ); + else + os << c; + } + } + } + + friend std::ostream& operator << ( std::ostream& os, XmlEncode const& xmlEncode ) { + xmlEncode.encodeTo( os ); + return os; + } + + private: + std::string m_str; + ForWhat m_forWhat; + }; + class XmlWriter { public: @@ -99,11 +155,8 @@ namespace Catch { } XmlWriter& writeAttribute( std::string const& name, std::string const& attribute ) { - if( !name.empty() && !attribute.empty() ) { - stream() << " " << name << "=\""; - writeEncodedText( attribute ); - stream() << "\""; - } + if( !name.empty() && !attribute.empty() ) + stream() << " " << name << "=\"" << XmlEncode( attribute, XmlEncode::ForAttributes ) << "\""; return *this; } @@ -114,9 +167,9 @@ namespace Catch { template<typename T> XmlWriter& writeAttribute( std::string const& name, T const& attribute ) { - if( !name.empty() ) - stream() << " " << name << "=\"" << attribute << "\""; - return *this; + std::ostringstream oss; + oss << attribute; + return writeAttribute( name, oss.str() ); } XmlWriter& writeText( std::string const& text, bool indent = true ) { @@ -125,7 +178,7 @@ namespace Catch { ensureTagClosed(); if( tagWasOpen && indent ) stream() << m_indent; - writeEncodedText( text ); + stream() << XmlEncode( text ); m_needsNewline = true; } return *this; @@ -170,30 +223,6 @@ namespace Catch { } } - void writeEncodedText( std::string const& text ) { - static const char* charsToEncode = "<&\""; - std::string mtext = text; - std::string::size_type pos = mtext.find_first_of( charsToEncode ); - while( pos != std::string::npos ) { - stream() << mtext.substr( 0, pos ); - - switch( mtext[pos] ) { - case '<': - stream() << "<"; - break; - case '&': - stream() << "&"; - break; - case '\"': - stream() << """; - break; - } - mtext = mtext.substr( pos+1 ); - pos = mtext.find_first_of( charsToEncode ); - } - stream() << mtext; - } - bool m_tagIsOpen; bool m_needsNewline; std::vector<std::string> m_tags; diff --git a/projects/SelfTest/Baselines/console.std.approved.txt b/projects/SelfTest/Baselines/console.std.approved.txt index 67fb8437..3aa3ae86 100644 --- a/projects/SelfTest/Baselines/console.std.approved.txt +++ b/projects/SelfTest/Baselines/console.std.approved.txt @@ -797,6 +797,6 @@ with expansion: "first" == "second" =============================================================================== -test cases: 157 | 117 passed | 39 failed | 1 failed as expected -assertions: 773 | 680 passed | 80 failed | 13 failed as expected +test cases: 158 | 118 passed | 39 failed | 1 failed as expected +assertions: 783 | 690 passed | 80 failed | 13 failed as expected diff --git a/projects/SelfTest/Baselines/console.sw.approved.txt b/projects/SelfTest/Baselines/console.sw.approved.txt index 7d41c5a7..238450b0 100644 --- a/projects/SelfTest/Baselines/console.sw.approved.txt +++ b/projects/SelfTest/Baselines/console.sw.approved.txt @@ -3762,6 +3762,128 @@ PASSED: with expansion: ""wide load"" == ""wide load"" +------------------------------------------------------------------------------- +XmlEncode + normal string +------------------------------------------------------------------------------- +MiscTests.cpp:<line number> +............................................................................... + +MiscTests.cpp:<line number>: +PASSED: + REQUIRE( encode( "normal string" ) == "normal string" ) +with expansion: + "normal string" == "normal string" + +------------------------------------------------------------------------------- +XmlEncode + empty string +------------------------------------------------------------------------------- +MiscTests.cpp:<line number> +............................................................................... + +MiscTests.cpp:<line number>: +PASSED: + REQUIRE( encode( "" ) == "" ) +with expansion: + "" == "" + +------------------------------------------------------------------------------- +XmlEncode + string with ampersand +------------------------------------------------------------------------------- +MiscTests.cpp:<line number> +............................................................................... + +MiscTests.cpp:<line number>: +PASSED: + REQUIRE( encode( "smith & jones" ) == "smith & jones" ) +with expansion: + "smith & jones" == "smith & jones" + +------------------------------------------------------------------------------- +XmlEncode + string with less-than +------------------------------------------------------------------------------- +MiscTests.cpp:<line number> +............................................................................... + +MiscTests.cpp:<line number>: +PASSED: + REQUIRE( encode( "smith < jones" ) == "smith < jones" ) +with expansion: + "smith < jones" == "smith < jones" + +------------------------------------------------------------------------------- +XmlEncode + string with greater-than +------------------------------------------------------------------------------- +MiscTests.cpp:<line number> +............................................................................... + +MiscTests.cpp:<line number>: +PASSED: + REQUIRE( encode( "smith > jones" ) == "smith > jones" ) +with expansion: + "smith > jones" == "smith > jones" + +MiscTests.cpp:<line number>: +PASSED: + REQUIRE( encode( "smith ]]> jones" ) == "smith ]]> jones" ) +with expansion: + "smith ]]> jones" + == + "smith ]]> jones" + +------------------------------------------------------------------------------- +XmlEncode + string with quotes +------------------------------------------------------------------------------- +MiscTests.cpp:<line number> +............................................................................... + +MiscTests.cpp:<line number>: +PASSED: + REQUIRE( encode( stringWithQuotes ) == stringWithQuotes ) +with expansion: + "don't "quote" me on that" + == + "don't "quote" me on that" + +MiscTests.cpp:<line number>: +PASSED: + REQUIRE( encode( stringWithQuotes, Catch::XmlEncode::ForAttributes ) == "don't "quote" me on that" ) +with expansion: + "don't "quote" me on that" + == + "don't "quote" me on that" + +------------------------------------------------------------------------------- +XmlEncode + string with control char (1) +------------------------------------------------------------------------------- +MiscTests.cpp:<line number> +............................................................................... + +MiscTests.cpp:<line number>: +PASSED: + REQUIRE( encode( "[\x01]" ) == "[]" ) +with expansion: + "[]" == "[]" + +------------------------------------------------------------------------------- +XmlEncode + string with control char (x7F) +------------------------------------------------------------------------------- +MiscTests.cpp:<line number> +............................................................................... + +MiscTests.cpp:<line number>: +PASSED: + REQUIRE( encode( "[\x7F]" ) == "[]" ) +with expansion: + "[]" == "[]" + ------------------------------------------------------------------------------- Process can be configured on command line default - no arguments @@ -8004,6 +8126,6 @@ with expansion: true =============================================================================== -test cases: 157 | 101 passed | 55 failed | 1 failed as expected -assertions: 793 | 680 passed | 100 failed | 13 failed as expected +test cases: 158 | 102 passed | 55 failed | 1 failed as expected +assertions: 803 | 690 passed | 100 failed | 13 failed as expected diff --git a/projects/SelfTest/Baselines/junit.sw.approved.txt b/projects/SelfTest/Baselines/junit.sw.approved.txt index cd978bfb..deae7529 100644 --- a/projects/SelfTest/Baselines/junit.sw.approved.txt +++ b/projects/SelfTest/Baselines/junit.sw.approved.txt @@ -1,5 +1,5 @@ <testsuites> - <testsuite name="all tests" errors="12" failures="88" tests="793" hostname="tbd" time="{duration}" timestamp="tbd"> + <testsuite name="all tests" errors="12" failures="88" tests="803" hostname="tbd" time="{duration}" timestamp="tbd"> <testcase classname="global" name="toString(enum)" time="{duration}"/> <testcase classname="global" name="toString(enum w/operator<<)" time="{duration}"/> <testcase classname="global" name="toString(enum class)" time="{duration}"/> @@ -463,6 +463,14 @@ MiscTests.cpp:<line number> <testcase classname="global" name="toString on const wchar_t pointer returns the string contents" time="{duration}"/> <testcase classname="global" name="toString on wchar_t const pointer returns the string contents" time="{duration}"/> <testcase classname="global" name="toString on wchar_t returns the string contents" time="{duration}"/> + <testcase classname="XmlEncode" name="normal string" time="{duration}"/> + <testcase classname="XmlEncode" name="empty string" time="{duration}"/> + <testcase classname="XmlEncode" name="string with ampersand" time="{duration}"/> + <testcase classname="XmlEncode" name="string with less-than" time="{duration}"/> + <testcase classname="XmlEncode" name="string with greater-than" time="{duration}"/> + <testcase classname="XmlEncode" name="string with quotes" time="{duration}"/> + <testcase classname="XmlEncode" name="string with control char (1)" time="{duration}"/> + <testcase classname="XmlEncode" name="string with control char (x7F)" time="{duration}"/> <testcase classname="Process can be configured on command line" name="default - no arguments" time="{duration}"/> <testcase classname="Process can be configured on command line" name="test lists/1 test" time="{duration}"/> <testcase classname="Process can be configured on command line" name="test lists/Specify one test case exclusion using exclude:" time="{duration}"/> diff --git a/projects/SelfTest/Baselines/xml.sw.approved.txt b/projects/SelfTest/Baselines/xml.sw.approved.txt index 654061f2..10b826c2 100644 --- a/projects/SelfTest/Baselines/xml.sw.approved.txt +++ b/projects/SelfTest/Baselines/xml.sw.approved.txt @@ -3,18 +3,18 @@ <TestCase name="toString(enum)"> <Expression success="true" type="CHECK" filename="projects/SelfTest/EnumToString.cpp" > <Original> - Catch::toString(e0) == "0" + Catch::toString(e0) == "0" </Original> <Expanded> - "0" == "0" + "0" == "0" </Expanded> </Expression> <Expression success="true" type="CHECK" filename="projects/SelfTest/EnumToString.cpp" > <Original> - Catch::toString(e1) == "1" + Catch::toString(e1) == "1" </Original> <Expanded> - "1" == "1" + "1" == "1" </Expanded> </Expression> <OverallResult success="true"/> @@ -22,18 +22,18 @@ <TestCase name="toString(enum w/operator<<)"> <Expression success="true" type="CHECK" filename="projects/SelfTest/EnumToString.cpp" > <Original> - Catch::toString(e0) == "E2{0}" + Catch::toString(e0) == "E2{0}" </Original> <Expanded> - "E2{0}" == "E2{0}" + "E2{0}" == "E2{0}" </Expanded> </Expression> <Expression success="true" type="CHECK" filename="projects/SelfTest/EnumToString.cpp" > <Original> - Catch::toString(e1) == "E2{1}" + Catch::toString(e1) == "E2{1}" </Original> <Expanded> - "E2{1}" == "E2{1}" + "E2{1}" == "E2{1}" </Expanded> </Expression> <OverallResult success="true"/> @@ -41,18 +41,18 @@ <TestCase name="toString(enum class)"> <Expression success="true" type="CHECK" filename="projects/SelfTest/EnumToString.cpp" > <Original> - Catch::toString(e0) == "0" + Catch::toString(e0) == "0" </Original> <Expanded> - "0" == "0" + "0" == "0" </Expanded> </Expression> <Expression success="true" type="CHECK" filename="projects/SelfTest/EnumToString.cpp" > <Original> - Catch::toString(e1) == "1" + Catch::toString(e1) == "1" </Original> <Expanded> - "1" == "1" + "1" == "1" </Expanded> </Expression> <OverallResult success="true"/> @@ -60,28 +60,28 @@ <TestCase name="toString(enum class w/operator<<)"> <Expression success="true" type="CHECK" filename="projects/SelfTest/EnumToString.cpp" > <Original> - Catch::toString(e0) == "E2/V0" + Catch::toString(e0) == "E2/V0" </Original> <Expanded> - "E2/V0" == "E2/V0" + "E2/V0" == "E2/V0" </Expanded> </Expression> <Expression success="true" type="CHECK" filename="projects/SelfTest/EnumToString.cpp" > <Original> - Catch::toString(e1) == "E2/V1" + Catch::toString(e1) == "E2/V1" </Original> <Expanded> - "E2/V1" == "E2/V1" + "E2/V1" == "E2/V1" </Expanded> </Expression> <Expression success="true" type="CHECK" filename="projects/SelfTest/EnumToString.cpp" > <Original> - Catch::toString(e3) == "Unknown enum value 10" + Catch::toString(e3) == "Unknown enum value 10" </Original> <Expanded> - "Unknown enum value 10" + "Unknown enum value 10" == -"Unknown enum value 10" +"Unknown enum value 10" </Expanded> </Expression> <OverallResult success="true"/> @@ -326,10 +326,10 @@ <TestCase name="A METHOD_AS_TEST_CASE based test run that succeeds"> <Expression success="true" type="REQUIRE" filename="projects/SelfTest/ClassTests.cpp" > <Original> - s == "hello" + s == "hello" </Original> <Expanded> - "hello" == "hello" + "hello" == "hello" </Expanded> </Expression> <OverallResult success="true"/> @@ -337,10 +337,10 @@ <TestCase name="A METHOD_AS_TEST_CASE based test run that fails"> <Expression success="false" type="REQUIRE" filename="projects/SelfTest/ClassTests.cpp" > <Original> - s == "world" + s == "world" </Original> <Expanded> - "hello" == "world" + "hello" == "world" </Expanded> </Expression> <OverallResult success="false"/> @@ -394,18 +394,18 @@ </Expression> <Expression success="true" type="REQUIRE" filename="projects/SelfTest/ConditionTests.cpp" > <Original> - data.str_hello == "hello" + data.str_hello == "hello" </Original> <Expanded> - "hello" == "hello" + "hello" == "hello" </Expanded> </Expression> <Expression success="true" type="REQUIRE" filename="projects/SelfTest/ConditionTests.cpp" > <Original> - "hello" == data.str_hello + "hello" == data.str_hello </Original> <Expanded> - "hello" == "hello" + "hello" == "hello" </Expanded> </Expression> <Expression success="true" type="REQUIRE" filename="projects/SelfTest/ConditionTests.cpp" > @@ -493,26 +493,26 @@ </Expression> <Expression success="false" type="CHECK" filename="projects/SelfTest/ConditionTests.cpp" > <Original> - data.str_hello == "goodbye" + data.str_hello == "goodbye" </Original> <Expanded> - "hello" == "goodbye" + "hello" == "goodbye" </Expanded> </Expression> <Expression success="false" type="CHECK" filename="projects/SelfTest/ConditionTests.cpp" > <Original> - data.str_hello == "hell" + data.str_hello == "hell" </Original> <Expanded> - "hello" == "hell" + "hello" == "hell" </Expanded> </Expression> <Expression success="false" type="CHECK" filename="projects/SelfTest/ConditionTests.cpp" > <Original> - data.str_hello == "hello1" + data.str_hello == "hello1" </Original> <Expanded> - "hello" == "hello1" + "hello" == "hello1" </Expanded> </Expression> <Expression success="false" type="CHECK" filename="projects/SelfTest/ConditionTests.cpp" > @@ -592,26 +592,26 @@ </Expression> <Expression success="true" type="REQUIRE" filename="projects/SelfTest/ConditionTests.cpp" > <Original> - data.str_hello != "goodbye" + data.str_hello != "goodbye" </Original> <Expanded> - "hello" != "goodbye" + "hello" != "goodbye" </Expanded> </Expression> <Expression success="true" type="REQUIRE" filename="projects/SelfTest/ConditionTests.cpp" > <Original> - data.str_hello != "hell" + data.str_hello != "hell" </Original> <Expanded> - "hello" != "hell" + "hello" != "hell" </Expanded> </Expression> <Expression success="true" type="REQUIRE" filename="projects/SelfTest/ConditionTests.cpp" > <Original> - data.str_hello != "hello1" + data.str_hello != "hello1" </Original> <Expanded> - "hello" != "hello1" + "hello" != "hello1" </Expanded> </Expression> <Expression success="true" type="REQUIRE" filename="projects/SelfTest/ConditionTests.cpp" > @@ -651,10 +651,10 @@ </Expression> <Expression success="false" type="CHECK" filename="projects/SelfTest/ConditionTests.cpp" > <Original> - data.str_hello != "hello" + data.str_hello != "hello" </Original> <Expanded> - "hello" != "hello" + "hello" != "hello" </Expanded> </Expression> <Expression success="false" type="CHECK" filename="projects/SelfTest/ConditionTests.cpp" > @@ -758,50 +758,50 @@ </Expression> <Expression success="true" type="REQUIRE" filename="projects/SelfTest/ConditionTests.cpp" > <Original> - data.str_hello <= "hello" + data.str_hello <= "hello" </Original> <Expanded> - "hello" <= "hello" + "hello" <= "hello" </Expanded> </Expression> <Expression success="true" type="REQUIRE" filename="projects/SelfTest/ConditionTests.cpp" > <Original> - data.str_hello >= "hello" + data.str_hello >= "hello" </Original> <Expanded> - "hello" >= "hello" + "hello" >= "hello" </Expanded> </Expression> <Expression success="true" type="REQUIRE" filename="projects/SelfTest/ConditionTests.cpp" > <Original> - data.str_hello < "hellp" + data.str_hello < "hellp" </Original> <Expanded> - "hello" < "hellp" + "hello" < "hellp" </Expanded> </Expression> <Expression success="true" type="REQUIRE" filename="projects/SelfTest/ConditionTests.cpp" > <Original> - data.str_hello < "zebra" + data.str_hello < "zebra" </Original> <Expanded> - "hello" < "zebra" + "hello" < "zebra" </Expanded> </Expression> <Expression success="true" type="REQUIRE" filename="projects/SelfTest/ConditionTests.cpp" > <Original> - data.str_hello > "hellm" + data.str_hello > "hellm" </Original> <Expanded> - "hello" > "hellm" + "hello" > "hellm" </Expanded> </Expression> <Expression success="true" type="REQUIRE" filename="projects/SelfTest/ConditionTests.cpp" > <Original> - data.str_hello > "a" + data.str_hello > "a" </Original> <Expanded> - "hello" > "a" + "hello" > "a" </Expanded> </Expression> <OverallResult success="true"/> @@ -897,66 +897,66 @@ </Expression> <Expression success="false" type="CHECK" filename="projects/SelfTest/ConditionTests.cpp" > <Original> - data.str_hello > "hello" + data.str_hello > "hello" </Original> <Expanded> - "hello" > "hello" + "hello" > "hello" </Expanded> </Expression> <Expression success="false" type="CHECK" filename="projects/SelfTest/ConditionTests.cpp" > <Original> - data.str_hello < "hello" + data.str_hello < "hello" </Original> <Expanded> - "hello" < "hello" + "hello" < "hello" </Expanded> </Expression> <Expression success="false" type="CHECK" filename="projects/SelfTest/ConditionTests.cpp" > <Original> - data.str_hello > "hellp" + data.str_hello > "hellp" </Original> <Expanded> - "hello" > "hellp" + "hello" > "hellp" </Expanded> </Expression> <Expression success="false" type="CHECK" filename="projects/SelfTest/ConditionTests.cpp" > <Original> - data.str_hello > "z" + data.str_hello > "z" </Original> <Expanded> - "hello" > "z" + "hello" > "z" </Expanded> </Expression> <Expression success="false" type="CHECK" filename="projects/SelfTest/ConditionTests.cpp" > <Original> - data.str_hello < "hellm" + data.str_hello < "hellm" </Original> <Expanded> - "hello" < "hellm" + "hello" < "hellm" </Expanded> </Expression> <Expression success="false" type="CHECK" filename="projects/SelfTest/ConditionTests.cpp" > <Original> - data.str_hello < "a" + data.str_hello < "a" </Original> <Expanded> - "hello" < "a" + "hello" < "a" </Expanded> </Expression> <Expression success="false" type="CHECK" filename="projects/SelfTest/ConditionTests.cpp" > <Original> - data.str_hello >= "z" + data.str_hello >= "z" </Original> <Expanded> - "hello" >= "z" + "hello" >= "z" </Expanded> </Expression> <Expression success="false" type="CHECK" filename="projects/SelfTest/ConditionTests.cpp" > <Original> - data.str_hello <= "a" + data.str_hello <= "a" </Original> <Expanded> - "hello" <= "a" + "hello" <= "a" </Expanded> </Expression> <OverallResult success="false"/> @@ -1600,10 +1600,10 @@ <Section name="exact match"> <Expression success="true" type="REQUIRE_THROWS_WITH" filename="projects/SelfTest/ExceptionTests.cpp" > <Original> - thisThrows(), "expected exception" + thisThrows(), "expected exception" </Original> <Expanded> - thisThrows(), "expected exception" + thisThrows(), "expected exception" </Expanded> </Expression> <OverallResults successes="1" failures="0" expectedFailures="0"/> @@ -1611,10 +1611,10 @@ <Section name="different case"> <Expression success="true" type="REQUIRE_THROWS_WITH" filename="projects/SelfTest/ExceptionTests.cpp" > <Original> - thisThrows(), Equals( "expecteD Exception", Catch::CaseSensitive::No ) + thisThrows(), Equals( "expecteD Exception", Catch::CaseSensitive::No ) </Original> <Expanded> - thisThrows(), Equals( "expecteD Exception", Catch::CaseSensitive::No ) + thisThrows(), Equals( "expecteD Exception", Catch::CaseSensitive::No ) </Expanded> </Expression> <OverallResults successes="1" failures="0" expectedFailures="0"/> @@ -1622,34 +1622,34 @@ <Section name="wildcarded"> <Expression success="true" type="REQUIRE_THROWS_WITH" filename="projects/SelfTest/ExceptionTests.cpp" > <Original> - thisThrows(), StartsWith( "expected" ) + thisThrows(), StartsWith( "expected" ) </Original> <Expanded> - thisThrows(), StartsWith( "expected" ) + thisThrows(), StartsWith( "expected" ) </Expanded> </Expression> <Expression success="true" type="REQUIRE_THROWS_WITH" filename="projects/SelfTest/ExceptionTests.cpp" > <Original> - thisThrows(), EndsWith( "exception" ) + thisThrows(), EndsWith( "exception" ) </Original> <Expanded> - thisThrows(), EndsWith( "exception" ) + thisThrows(), EndsWith( "exception" ) </Expanded> </Expression> <Expression success="true" type="REQUIRE_THROWS_WITH" filename="projects/SelfTest/ExceptionTests.cpp" > <Original> - thisThrows(), Contains( "except" ) + thisThrows(), Contains( "except" ) </Original> <Expanded> - thisThrows(), Contains( "except" ) + thisThrows(), Contains( "except" ) </Expanded> </Expression> <Expression success="true" type="REQUIRE_THROWS_WITH" filename="projects/SelfTest/ExceptionTests.cpp" > <Original> - thisThrows(), Contains( "exCept", Catch::CaseSensitive::No ) + thisThrows(), Contains( "exCept", Catch::CaseSensitive::No ) </Original> <Expanded> - thisThrows(), Contains( "exCept", Catch::CaseSensitive::No ) + thisThrows(), Contains( "exCept", Catch::CaseSensitive::No ) </Expanded> </Expression> <OverallResults successes="4" failures="0" expectedFailures="0"/> @@ -1659,15 +1659,15 @@ <TestCase name="Mismatching exception messages failing the test"> <Expression success="true" type="REQUIRE_THROWS_WITH" filename="projects/SelfTest/ExceptionTests.cpp" > <Original> - thisThrows(), "expected exception" + thisThrows(), "expected exception" </Original> <Expanded> - thisThrows(), "expected exception" + thisThrows(), "expected exception" </Expanded> </Expression> <Expression success="false" type="REQUIRE_THROWS_WITH" filename="projects/SelfTest/ExceptionTests.cpp" > <Original> - thisThrows(), "should fail" + thisThrows(), "should fail" </Original> <Expanded> expected exception @@ -3308,7 +3308,7 @@ makeString( false ) != static_cast<char*>(nullptr) </Original> <Expanded> - "valid string" != {null string} + "valid string" != {null string} </Expanded> </Expression> <Expression success="true" type="REQUIRE" filename="projects/SelfTest/MiscTests.cpp" > @@ -3434,34 +3434,34 @@ <TestCase name="String matchers"> <Expression success="true" type="REQUIRE_THAT" filename="projects/SelfTest/MiscTests.cpp" > <Original> - testStringForMatching() Contains( "string" ) + testStringForMatching() Contains( "string" ) </Original> <Expanded> - "this string contains 'abc' as a substring" contains: "string" + "this string contains 'abc' as a substring" contains: "string" </Expanded> </Expression> <Expression success="true" type="CHECK_THAT" filename="projects/SelfTest/MiscTests.cpp" > <Original> - testStringForMatching() Contains( "abc" ) + testStringForMatching() Contains( "abc" ) </Original> <Expanded> - "this string contains 'abc' as a substring" contains: "abc" + "this string contains 'abc' as a substring" contains: "abc" </Expanded> </Expression> <Expression success="true" type="CHECK_THAT" filename="projects/SelfTest/MiscTests.cpp" > <Original> - testStringForMatching() StartsWith( "this" ) + testStringForMatching() StartsWith( "this" ) </Original> <Expanded> - "this string contains 'abc' as a substring" starts with: "this" + "this string contains 'abc' as a substring" starts with: "this" </Expanded> </Expression> <Expression success="true" type="CHECK_THAT" filename="projects/SelfTest/MiscTests.cpp" > <Original> - testStringForMatching() EndsWith( "substring" ) + testStringForMatching() EndsWith( "substring" ) </Original> <Expanded> - "this string contains 'abc' as a substring" ends with: "substring" + "this string contains 'abc' as a substring" ends with: "substring" </Expanded> </Expression> <OverallResult success="true"/> @@ -3469,10 +3469,10 @@ <TestCase name="Contains string matcher"> <Expression success="false" type="CHECK_THAT" filename="projects/SelfTest/MiscTests.cpp" > <Original> - testStringForMatching() Contains( "not there" ) + testStringForMatching() Contains( "not there" ) </Original> <Expanded> - "this string contains 'abc' as a substring" contains: "not there" + "this string contains 'abc' as a substring" contains: "not there" </Expanded> </Expression> <OverallResult success="false"/> @@ -3480,10 +3480,10 @@ <TestCase name="StartsWith string matcher"> <Expression success="false" type="CHECK_THAT" filename="projects/SelfTest/MiscTests.cpp" > <Original> - testStringForMatching() StartsWith( "string" ) + testStringForMatching() StartsWith( "string" ) </Original> <Expanded> - "this string contains 'abc' as a substring" starts with: "string" + "this string contains 'abc' as a substring" starts with: "string" </Expanded> </Expression> <OverallResult success="false"/> @@ -3491,10 +3491,10 @@ <TestCase name="EndsWith string matcher"> <Expression success="false" type="CHECK_THAT" filename="projects/SelfTest/MiscTests.cpp" > <Original> - testStringForMatching() EndsWith( "this" ) + testStringForMatching() EndsWith( "this" ) </Original> <Expanded> - "this string contains 'abc' as a substring" ends with: "this" + "this string contains 'abc' as a substring" ends with: "this" </Expanded> </Expression> <OverallResult success="false"/> @@ -3502,10 +3502,10 @@ <TestCase name="Equals string matcher"> <Expression success="false" type="CHECK_THAT" filename="projects/SelfTest/MiscTests.cpp" > <Original> - testStringForMatching() Equals( "something else" ) + testStringForMatching() Equals( "something else" ) </Original> <Expanded> - "this string contains 'abc' as a substring" equals: "something else" + "this string contains 'abc' as a substring" equals: "something else" </Expanded> </Expression> <OverallResult success="false"/> @@ -3513,10 +3513,10 @@ <TestCase name="Equals string matcher, with NULL"> <Expression success="true" type="REQUIRE_THAT" filename="projects/SelfTest/MiscTests.cpp" > <Original> - "" Equals(nullptr) + "" Equals(nullptr) </Original> <Expanded> - "" equals: "" + "" equals: "" </Expanded> </Expression> <OverallResult success="true"/> @@ -3524,10 +3524,10 @@ <TestCase name="AllOf matcher"> <Expression success="true" type="CHECK_THAT" filename="projects/SelfTest/MiscTests.cpp" > <Original> - testStringForMatching() AllOf( Catch::Contains( "string" ), Catch::Contains( "abc" ) ) + testStringForMatching() AllOf( Catch::Contains( "string" ), Catch::Contains( "abc" ) ) </Original> <Expanded> - "this string contains 'abc' as a substring" ( contains: "string" and contains: "abc" ) + "this string contains 'abc' as a substring" ( contains: "string" and contains: "abc" ) </Expanded> </Expression> <OverallResult success="true"/> @@ -3535,18 +3535,18 @@ <TestCase name="AnyOf matcher"> <Expression success="true" type="CHECK_THAT" filename="projects/SelfTest/MiscTests.cpp" > <Original> - testStringForMatching() AnyOf( Catch::Contains( "string" ), Catch::Contains( "not there" ) ) + testStringForMatching() AnyOf( Catch::Contains( "string" ), Catch::Contains( "not there" ) ) </Original> <Expanded> - "this string contains 'abc' as a substring" ( contains: "string" or contains: "not there" ) + "this string contains 'abc' as a substring" ( contains: "string" or contains: "not there" ) </Expanded> </Expression> <Expression success="true" type="CHECK_THAT" filename="projects/SelfTest/MiscTests.cpp" > <Original> - testStringForMatching() AnyOf( Catch::Contains( "not there" ), Catch::Contains( "string" ) ) + testStringForMatching() AnyOf( Catch::Contains( "not there" ), Catch::Contains( "string" ) ) </Original> <Expanded> - "this string contains 'abc' as a substring" ( contains: "not there" or contains: "string" ) + "this string contains 'abc' as a substring" ( contains: "not there" or contains: "string" ) </Expanded> </Expression> <OverallResult success="true"/> @@ -3554,10 +3554,10 @@ <TestCase name="Equals"> <Expression success="true" type="CHECK_THAT" filename="projects/SelfTest/MiscTests.cpp" > <Original> - testStringForMatching() Equals( "this string contains 'abc' as a substring" ) + testStringForMatching() Equals( "this string contains 'abc' as a substring" ) </Original> <Expanded> - "this string contains 'abc' as a substring" equals: "this string contains 'abc' as a substring" + "this string contains 'abc' as a substring" equals: "this string contains 'abc' as a substring" </Expanded> </Expression> <OverallResult success="true"/> @@ -3795,14 +3795,14 @@ s1 == s2 </Original> <Expanded> - "if ($b == 10) { + "if ($b == 10) { $a = 20; -}" +}" == -"if ($b == 10) { +"if ($b == 10) { $a = 20; } -" +" </Expanded> </Expression> <OverallResult success="false"/> @@ -3810,10 +3810,10 @@ <TestCase name="toString on const wchar_t const pointer returns the string contents"> <Expression success="true" type="CHECK" filename="projects/SelfTest/MiscTests.cpp" > <Original> - result == "\"wide load\"" + result == "\"wide load\"" </Original> <Expanded> - ""wide load"" == ""wide load"" + ""wide load"" == ""wide load"" </Expanded> </Expression> <OverallResult success="true"/> @@ -3821,10 +3821,10 @@ <TestCase name="toString on const wchar_t pointer returns the string contents"> <Expression success="true" type="CHECK" filename="projects/SelfTest/MiscTests.cpp" > <Original> - result == "\"wide load\"" + result == "\"wide load\"" </Original> <Expanded> - ""wide load"" == ""wide load"" + ""wide load"" == ""wide load"" </Expanded> </Expression> <OverallResult success="true"/> @@ -3832,10 +3832,10 @@ <TestCase name="toString on wchar_t const pointer returns the string contents"> <Expression success="true" type="CHECK" filename="projects/SelfTest/MiscTests.cpp" > <Original> - result == "\"wide load\"" + result == "\"wide load\"" </Original> <Expanded> - ""wide load"" == ""wide load"" + ""wide load"" == ""wide load"" </Expanded> </Expression> <OverallResult success="true"/> @@ -3843,14 +3843,127 @@ <TestCase name="toString on wchar_t returns the string contents"> <Expression success="true" type="CHECK" filename="projects/SelfTest/MiscTests.cpp" > <Original> - result == "\"wide load\"" + result == "\"wide load\"" </Original> <Expanded> - ""wide load"" == ""wide load"" + ""wide load"" == ""wide load"" </Expanded> </Expression> <OverallResult success="true"/> </TestCase> + <TestCase name="XmlEncode"> + <Section name="normal string"> + <Expression success="true" type="REQUIRE" filename="projects/SelfTest/MiscTests.cpp" > + <Original> + encode( "normal string" ) == "normal string" + </Original> + <Expanded> + "normal string" == "normal string" + </Expanded> + </Expression> + <OverallResults successes="1" failures="0" expectedFailures="0"/> + </Section> + <Section name="empty string"> + <Expression success="true" type="REQUIRE" filename="projects/SelfTest/MiscTests.cpp" > + <Original> + encode( "" ) == "" + </Original> + <Expanded> + "" == "" + </Expanded> + </Expression> + <OverallResults successes="1" failures="0" expectedFailures="0"/> + </Section> + <Section name="string with ampersand"> + <Expression success="true" type="REQUIRE" filename="projects/SelfTest/MiscTests.cpp" > + <Original> + encode( "smith & jones" ) == "smith &amp; jones" + </Original> + <Expanded> + "smith &amp; jones" == "smith &amp; jones" + </Expanded> + </Expression> + <OverallResults successes="1" failures="0" expectedFailures="0"/> + </Section> + <Section name="string with less-than"> + <Expression success="true" type="REQUIRE" filename="projects/SelfTest/MiscTests.cpp" > + <Original> + encode( "smith < jones" ) == "smith &lt; jones" + </Original> + <Expanded> + "smith &lt; jones" == "smith &lt; jones" + </Expanded> + </Expression> + <OverallResults successes="1" failures="0" expectedFailures="0"/> + </Section> + <Section name="string with greater-than"> + <Expression success="true" type="REQUIRE" filename="projects/SelfTest/MiscTests.cpp" > + <Original> + encode( "smith > jones" ) == "smith > jones" + </Original> + <Expanded> + "smith > jones" == "smith > jones" + </Expanded> + </Expression> + <Expression success="true" type="REQUIRE" filename="projects/SelfTest/MiscTests.cpp" > + <Original> + encode( "smith ]]> jones" ) == "smith ]]&gt; jones" + </Original> + <Expanded> + "smith ]]&gt; jones" +== +"smith ]]&gt; jones" + </Expanded> + </Expression> + <OverallResults successes="2" failures="0" expectedFailures="0"/> + </Section> + <Section name="string with quotes"> + <Expression success="true" type="REQUIRE" filename="projects/SelfTest/MiscTests.cpp" > + <Original> + encode( stringWithQuotes ) == stringWithQuotes + </Original> + <Expanded> + "don't "quote" me on that" +== +"don't "quote" me on that" + </Expanded> + </Expression> + <Expression success="true" type="REQUIRE" filename="projects/SelfTest/MiscTests.cpp" > + <Original> + encode( stringWithQuotes, Catch::XmlEncode::ForAttributes ) == "don't &quot;quote&quot; me on that" + </Original> + <Expanded> + "don't &quot;quote&quot; me on that" +== +"don't &quot;quote&quot; me on that" + </Expanded> + </Expression> + <OverallResults successes="2" failures="0" expectedFailures="0"/> + </Section> + <Section name="string with control char (1)"> + <Expression success="true" type="REQUIRE" filename="projects/SelfTest/MiscTests.cpp" > + <Original> + encode( "[\x01]" ) == "[&#x1]" + </Original> + <Expanded> + "[&#x1]" == "[&#x1]" + </Expanded> + </Expression> + <OverallResults successes="1" failures="0" expectedFailures="0"/> + </Section> + <Section name="string with control char (x7F)"> + <Expression success="true" type="REQUIRE" filename="projects/SelfTest/MiscTests.cpp" > + <Original> + encode( "[\x7F]" ) == "[&#x7F]" + </Original> + <Expanded> + "[&#x7F]" == "[&#x7F]" + </Expanded> + </Expression> + <OverallResults successes="1" failures="0" expectedFailures="0"/> + </Section> + <OverallResult success="true"/> + </TestCase> <TestCase name="Process can be configured on command line"> <Section name="default - no arguments"> <Expression success="true" type="CHECK_NOTHROW" filename="projects/SelfTest/TestMain.cpp" > @@ -3907,7 +4020,7 @@ </Expression> <Expression success="true" type="REQUIRE" filename="projects/SelfTest/TestMain.cpp" > <Original> - cfg.testSpec().matches( fakeTestCase( "notIncluded" ) ) == false + cfg.testSpec().matches( fakeTestCase( "notIncluded" ) ) == false </Original> <Expanded> false == false @@ -3915,7 +4028,7 @@ </Expression> <Expression success="true" type="REQUIRE" filename="projects/SelfTest/TestMain.cpp" > <Original> - cfg.testSpec().matches( fakeTestCase( "test1" ) ) + cfg.testSpec().matches( fakeTestCase( "test1" ) ) </Original> <Expanded> true @@ -3937,7 +4050,7 @@ </Expression> <Expression success="true" type="REQUIRE" filename="projects/SelfTest/TestMain.cpp" > <Original> - cfg.testSpec().matches( fakeTestCase( "test1" ) ) == false + cfg.testSpec().matches( fakeTestCase( "test1" ) ) == false </Original> <Expanded> false == false @@ -3945,7 +4058,7 @@ </Expression> <Expression success="true" type="REQUIRE" filename="projects/SelfTest/TestMain.cpp" > <Original> - cfg.testSpec().matches( fakeTestCase( "alwaysIncluded" ) ) + cfg.testSpec().matches( fakeTestCase( "alwaysIncluded" ) ) </Original> <Expanded> true @@ -3967,7 +4080,7 @@ </Expression> <Expression success="true" type="REQUIRE" filename="projects/SelfTest/TestMain.cpp" > <Original> - cfg.testSpec().matches( fakeTestCase( "test1" ) ) == false + cfg.testSpec().matches( fakeTestCase( "test1" ) ) == false </Original> <Expanded> false == false @@ -3975,7 +4088,7 @@ </Expression> <Expression success="true" type="REQUIRE" filename="projects/SelfTest/TestMain.cpp" > <Original> - cfg.testSpec().matches( fakeTestCase( "alwaysIncluded" ) ) + cfg.testSpec().matches( fakeTestCase( "alwaysIncluded" ) ) </Original> <Expanded> true @@ -3997,10 +4110,10 @@ </Expression> <Expression success="true" type="REQUIRE" filename="projects/SelfTest/TestMain.cpp" > <Original> - config.reporterName == "console" + config.reporterName == "console" </Original> <Expanded> - "console" == "console" + "console" == "console" </Expanded> </Expression> <OverallResults successes="2" failures="0" expectedFailures="0"/> @@ -4019,10 +4132,10 @@ </Expression> <Expression success="true" type="REQUIRE" filename="projects/SelfTest/TestMain.cpp" > <Original> - config.reporterName == "xml" + config.reporterName == "xml" </Original> <Expanded> - "xml" == "xml" + "xml" == "xml" </Expanded> </Expression> <OverallResults successes="2" failures="0" expectedFailures="0"/> @@ -4041,10 +4154,10 @@ </Expression> <Expression success="true" type="REQUIRE" filename="projects/SelfTest/TestMain.cpp" > <Original> - config.reporterName == "junit" + config.reporterName == "junit" </Original> <Expanded> - "junit" == "junit" + "junit" == "junit" </Expanded> </Expression> <OverallResults successes="2" failures="0" expectedFailures="0"/> @@ -4143,11 +4256,11 @@ <Section name="-x must be greater than zero"> <Expression success="true" type="REQUIRE_THAT" filename="projects/SelfTest/TestMain.cpp" > <Original> - parseIntoConfigAndReturnError( argv, config ) Contains( "greater than zero" ) + parseIntoConfigAndReturnError( argv, config ) Contains( "greater than zero" ) </Original> <Expanded> - "Value after -x or --abortAfter must be greater than zero -- while parsing: (-x, --abortx <no. failures>)" contains: "greater than zero" + "Value after -x or --abortAfter must be greater than zero +- while parsing: (-x, --abortx <no. failures>)" contains: "greater than zero" </Expanded> </Expression> <OverallResults successes="1" failures="0" expectedFailures="0"/> @@ -4158,11 +4271,11 @@ <Section name="-x must be numeric"> <Expression success="true" type="REQUIRE_THAT" filename="projects/SelfTest/TestMain.cpp" > <Original> - parseIntoConfigAndReturnError( argv, config ) Contains( "-x" ) + parseIntoConfigAndReturnError( argv, config ) Contains( "-x" ) </Original> <Expanded> - "Unable to convert oops to destination type -- while parsing: (-x, --abortx <no. failures>)" contains: "-x" + "Unable to convert oops to destination type +- while parsing: (-x, --abortx <no. failures>)" contains: "-x" </Expanded> </Expression> <OverallResults successes="1" failures="0" expectedFailures="0"/> @@ -4225,10 +4338,10 @@ </Expression> <Expression success="true" type="REQUIRE" filename="projects/SelfTest/TestMain.cpp" > <Original> - config.outputFilename == "filename.ext" + config.outputFilename == "filename.ext" </Original> <Expanded> - "filename.ext" == "filename.ext" + "filename.ext" == "filename.ext" </Expanded> </Expression> <OverallResults successes="2" failures="0" expectedFailures="0"/> @@ -4247,10 +4360,10 @@ </Expression> <Expression success="true" type="REQUIRE" filename="projects/SelfTest/TestMain.cpp" > <Original> - config.outputFilename == "filename.ext" + config.outputFilename == "filename.ext" </Original> <Expanded> - "filename.ext" == "filename.ext" + "filename.ext" == "filename.ext" </Expanded> </Expression> <OverallResults successes="2" failures="0" expectedFailures="0"/> @@ -4349,9 +4462,9 @@ Text( testString, TextAttributes().setWidth( 80 ) ).toString() == testString </Original> <Expanded> - "one two three four" + "one two three four" == -"one two three four" +"one two three four" </Expanded> </Expression> <Expression success="true" type="CHECK" filename="projects/SelfTest/TestMain.cpp" > @@ -4359,9 +4472,9 @@ Text( testString, TextAttributes().setWidth( 18 ) ).toString() == testString </Original> <Expanded> - "one two three four" + "one two three four" == -"one two three four" +"one two three four" </Expanded> </Expression> <OverallResults successes="2" failures="0" expectedFailures="0"/> @@ -4372,62 +4485,62 @@ <Section name="Wrapped once"> <Expression success="true" type="CHECK" filename="projects/SelfTest/TestMain.cpp" > <Original> - Text( testString, TextAttributes().setWidth( 17 ) ).toString() == "one two three\nfour" + Text( testString, TextAttributes().setWidth( 17 ) ).toString() == "one two three\nfour" </Original> <Expanded> - "one two three -four" + "one two three +four" == -"one two three -four" +"one two three +four" </Expanded> </Expression> <Expression success="true" type="CHECK" filename="projects/SelfTest/TestMain.cpp" > <Original> - Text( testString, TextAttributes().setWidth( 16 ) ).toString() == "one two three\nfour" + Text( testString, TextAttributes().setWidth( 16 ) ).toString() == "one two three\nfour" </Original> <Expanded> - "one two three -four" + "one two three +four" == -"one two three -four" +"one two three +four" </Expanded> </Expression> <Expression success="true" type="CHECK" filename="projects/SelfTest/TestMain.cpp" > <Original> - Text( testString, TextAttributes().setWidth( 14 ) ).toString() == "one two three\nfour" + Text( testString, TextAttributes().setWidth( 14 ) ).toString() == "one two three\nfour" </Original> <Expanded> - "one two three -four" + "one two three +four" == -"one two three -four" +"one two three +four" </Expanded> </Expression> <Expression success="true" type="CHECK" filename="projects/SelfTest/TestMain.cpp" > <Original> - Text( testString, TextAttributes().setWidth( 13 ) ).toString() == "one two three\nfour" + Text( testString, TextAttributes().setWidth( 13 ) ).toString() == "one two three\nfour" </Original> <Expanded> - "one two three -four" + "one two three +four" == -"one two three -four" +"one two three +four" </Expanded> </Expression> <Expression success="true" type="CHECK" filename="projects/SelfTest/TestMain.cpp" > <Original> - Text( testString, TextAttributes().setWidth( 12 ) ).toString() == "one two\nthree four" + Text( testString, TextAttributes().setWidth( 12 ) ).toString() == "one two\nthree four" </Original> <Expanded> - "one two -three four" + "one two +three four" == -"one two -three four" +"one two +three four" </Expanded> </Expression> <OverallResults successes="5" failures="0" expectedFailures="0"/> @@ -4438,44 +4551,44 @@ three four" <Section name="Wrapped twice"> <Expression success="true" type="CHECK" filename="projects/SelfTest/TestMain.cpp" > <Original> - Text( testString, TextAttributes().setWidth( 9 ) ).toString() == "one two\nthree\nfour" + Text( testString, TextAttributes().setWidth( 9 ) ).toString() == "one two\nthree\nfour" </Original> <Expanded> - "one two + "one two three -four" +four" == -"one two +"one two three -four" +four" </Expanded> </Expression> <Expression success="true" type="CHECK" filename="projects/SelfTest/TestMain.cpp" > <Original> - Text( testString, TextAttributes().setWidth( 8 ) ).toString() == "one two\nthree\nfour" + Text( testString, TextAttributes().setWidth( 8 ) ).toString() == "one two\nthree\nfour" </Original> <Expanded> - "one two + "one two three -four" +four" == -"one two +"one two three -four" +four" </Expanded> </Expression> <Expression success="true" type="CHECK" filename="projects/SelfTest/TestMain.cpp" > <Original> - Text( testString, TextAttributes().setWidth( 7 ) ).toString() == "one two\nthree\nfour" + Text( testString, TextAttributes().setWidth( 7 ) ).toString() == "one two\nthree\nfour" </Original> <Expanded> - "one two + "one two three -four" +four" == -"one two +"one two three -four" +four" </Expanded> </Expression> <OverallResults successes="3" failures="0" expectedFailures="0"/> @@ -4486,34 +4599,34 @@ four" <Section name="Wrapped three times"> <Expression success="true" type="CHECK" filename="projects/SelfTest/TestMain.cpp" > <Original> - Text( testString, TextAttributes().setWidth( 6 ) ).toString() == "one\ntwo\nthree\nfour" + Text( testString, TextAttributes().setWidth( 6 ) ).toString() == "one\ntwo\nthree\nfour" </Original> <Expanded> - "one + "one two three -four" +four" == -"one +"one two three -four" +four" </Expanded> </Expression> <Expression success="true" type="CHECK" filename="projects/SelfTest/TestMain.cpp" > <Original> - Text( testString, TextAttributes().setWidth( 5 ) ).toString() == "one\ntwo\nthree\nfour" + Text( testString, TextAttributes().setWidth( 5 ) ).toString() == "one\ntwo\nthree\nfour" </Original> <Expanded> - "one + "one two three -four" +four" == -"one +"one two three -four" +four" </Expanded> </Expression> <OverallResults successes="2" failures="0" expectedFailures="0"/> @@ -4524,78 +4637,78 @@ four" <Section name="Short wrap"> <Expression success="true" type="CHECK" filename="projects/SelfTest/TestMain.cpp" > <Original> - Text( "abcdef", TextAttributes().setWidth( 4 ) ).toString() == "abc-\ndef" + Text( "abcdef", TextAttributes().setWidth( 4 ) ).toString() == "abc-\ndef" </Original> <Expanded> - "abc- -def" + "abc- +def" == -"abc- -def" +"abc- +def" </Expanded> </Expression> <Expression success="true" type="CHECK" filename="projects/SelfTest/TestMain.cpp" > <Original> - Text( "abcdefg", TextAttributes().setWidth( 4 ) ).toString() == "abc-\ndefg" + Text( "abcdefg", TextAttributes().setWidth( 4 ) ).toString() == "abc-\ndefg" </Original> <Expanded> - "abc- -defg" + "abc- +defg" == -"abc- -defg" +"abc- +defg" </Expanded> </Expression> <Expression success="true" type="CHECK" filename="projects/SelfTest/TestMain.cpp" > <Original> - Text( "abcdefgh", TextAttributes().setWidth( 4 ) ).toString() == "abc-\ndef-\ngh" + Text( "abcdefgh", TextAttributes().setWidth( 4 ) ).toString() == "abc-\ndef-\ngh" </Original> <Expanded> - "abc- + "abc- def- -gh" +gh" == -"abc- +"abc- def- -gh" +gh" </Expanded> </Expression> <Expression success="true" type="CHECK" filename="projects/SelfTest/TestMain.cpp" > <Original> - Text( testString, TextAttributes().setWidth( 4 ) ).toString() == "one\ntwo\nthr-\nee\nfour" + Text( testString, TextAttributes().setWidth( 4 ) ).toString() == "one\ntwo\nthr-\nee\nfour" </Original> <Expanded> - "one + "one two thr- ee -four" +four" == -"one +"one two thr- ee -four" +four" </Expanded> </Expression> <Expression success="true" type="CHECK" filename="projects/SelfTest/TestMain.cpp" > <Original> - Text( testString, TextAttributes().setWidth( 3 ) ).toString() == "one\ntwo\nth-\nree\nfo-\nur" + Text( testString, TextAttributes().setWidth( 3 ) ).toString() == "one\ntwo\nth-\nree\nfo-\nur" </Original> <Expanded> - "one + "one two th- ree fo- -ur" +ur" == -"one +"one two th- ree fo- -ur" +ur" </Expanded> </Expression> <OverallResults successes="5" failures="0" expectedFailures="0"/> @@ -4614,34 +4727,34 @@ ur" </Expression> <Expression success="true" type="CHECK" filename="projects/SelfTest/TestMain.cpp" > <Original> - text[0] == "one" + text[0] == "one" </Original> <Expanded> - "one" == "one" + "one" == "one" </Expanded> </Expression> <Expression success="true" type="CHECK" filename="projects/SelfTest/TestMain.cpp" > <Original> - text[1] == "two" + text[1] == "two" </Original> <Expanded> - "two" == "two" + "two" == "two" </Expanded> </Expression> <Expression success="true" type="CHECK" filename="projects/SelfTest/TestMain.cpp" > <Original> - text[2] == "three" + text[2] == "three" </Original> <Expanded> - "three" == "three" + "three" == "three" </Expanded> </Expression> <Expression success="true" type="CHECK" filename="projects/SelfTest/TestMain.cpp" > <Original> - text[3] == "four" + text[3] == "four" </Original> <Expanded> - "four" == "four" + "four" == "four" </Expanded> </Expression> <OverallResults successes="5" failures="0" expectedFailures="0"/> @@ -4652,16 +4765,16 @@ ur" <Section name="Indent first line differently"> <Expression success="true" type="CHECK" filename="projects/SelfTest/TestMain.cpp" > <Original> - text.toString() == " one two\n three\n four" + text.toString() == " one two\n three\n four" </Original> <Expanded> - " one two + " one two three - four" + four" == -" one two +" one two three - four" + four" </Expanded> </Expression> <OverallResults successes="1" failures="0" expectedFailures="0"/> @@ -4675,11 +4788,11 @@ ur" Text( testString, TextAttributes().setWidth( 80 ) ).toString() == testString </Original> <Expanded> - "one two -three four" + "one two +three four" == -"one two -three four" +"one two +three four" </Expanded> </Expression> <Expression success="true" type="CHECK" filename="projects/SelfTest/TestMain.cpp" > @@ -4687,11 +4800,11 @@ three four" Text( testString, TextAttributes().setWidth( 18 ) ).toString() == testString </Original> <Expanded> - "one two -three four" + "one two +three four" == -"one two -three four" +"one two +three four" </Expanded> </Expression> <Expression success="true" type="CHECK" filename="projects/SelfTest/TestMain.cpp" > @@ -4699,11 +4812,11 @@ three four" Text( testString, TextAttributes().setWidth( 10 ) ).toString() == testString </Original> <Expanded> - "one two -three four" + "one two +three four" == -"one two -three four" +"one two +three four" </Expanded> </Expression> <OverallResults successes="3" failures="0" expectedFailures="0"/> @@ -4714,34 +4827,34 @@ three four" <Section name="Trailing newline"> <Expression success="true" type="CHECK" filename="projects/SelfTest/TestMain.cpp" > <Original> - Text( "abcdef\n", TextAttributes().setWidth( 10 ) ).toString() == "abcdef\n" + Text( "abcdef\n", TextAttributes().setWidth( 10 ) ).toString() == "abcdef\n" </Original> <Expanded> - "abcdef -" + "abcdef +" == -"abcdef -" +"abcdef +" </Expanded> </Expression> <Expression success="true" type="CHECK" filename="projects/SelfTest/TestMain.cpp" > <Original> - Text( "abcdef", TextAttributes().setWidth( 6 ) ).toString() == "abcdef" + Text( "abcdef", TextAttributes().setWidth( 6 ) ).toString() == "abcdef" </Original> <Expanded> - "abcdef" == "abcdef" + "abcdef" == "abcdef" </Expanded> </Expression> <Expression success="true" type="CHECK" filename="projects/SelfTest/TestMain.cpp" > <Original> - Text( "abcdef\n", TextAttributes().setWidth( 6 ) ).toString() == "abcdef\n" + Text( "abcdef\n", TextAttributes().setWidth( 6 ) ).toString() == "abcdef\n" </Original> <Expanded> - "abcdef -" + "abcdef +" == -"abcdef -" +"abcdef +" </Expanded> </Expression> <OverallResults successes="3" failures="0" expectedFailures="0"/> @@ -4752,44 +4865,44 @@ three four" <Section name="Wrapped once"> <Expression success="true" type="CHECK" filename="projects/SelfTest/TestMain.cpp" > <Original> - Text( testString, TextAttributes().setWidth( 9 ) ).toString() == "one two\nthree\nfour" + Text( testString, TextAttributes().setWidth( 9 ) ).toString() == "one two\nthree\nfour" </Original> <Expanded> - "one two + "one two three -four" +four" == -"one two +"one two three -four" +four" </Expanded> </Expression> <Expression success="true" type="CHECK" filename="projects/SelfTest/TestMain.cpp" > <Original> - Text( testString, TextAttributes().setWidth( 8 ) ).toString() == "one two\nthree\nfour" + Text( testString, TextAttributes().setWidth( 8 ) ).toString() == "one two\nthree\nfour" </Original> <Expanded> - "one two + "one two three -four" +four" == -"one two +"one two three -four" +four" </Expanded> </Expression> <Expression success="true" type="CHECK" filename="projects/SelfTest/TestMain.cpp" > <Original> - Text( testString, TextAttributes().setWidth( 7 ) ).toString() == "one two\nthree\nfour" + Text( testString, TextAttributes().setWidth( 7 ) ).toString() == "one two\nthree\nfour" </Original> <Expanded> - "one two + "one two three -four" +four" == -"one two +"one two three -four" +four" </Expanded> </Expression> <OverallResults successes="3" failures="0" expectedFailures="0"/> @@ -4800,18 +4913,18 @@ four" <Section name="Wrapped twice"> <Expression success="true" type="CHECK" filename="projects/SelfTest/TestMain.cpp" > <Original> - Text( testString, TextAttributes().setWidth( 6 ) ).toString() == "one\ntwo\nthree\nfour" + Text( testString, TextAttributes().setWidth( 6 ) ).toString() == "one\ntwo\nthree\nfour" </Original> <Expanded> - "one + "one two three -four" +four" == -"one +"one two three -four" +four" </Expanded> </Expression> <OverallResults successes="1" failures="0" expectedFailures="0"/> @@ -4821,18 +4934,18 @@ four" <Section name="With tabs"> <Expression success="true" type="CHECK" filename="projects/SelfTest/TestMain.cpp" > <Original> - Text( testString, TextAttributes().setWidth( 15 ) ).toString() == "one two three\n four\n five\n six" + Text( testString, TextAttributes().setWidth( 15 ) ).toString() == "one two three\n four\n five\n six" </Original> <Expanded> - "one two three + "one two three four five - six" + six" == -"one two three +"one two three four five - six" + six" </Expanded> </Expression> <OverallResults successes="1" failures="0" expectedFailures="0"/> @@ -4843,7 +4956,7 @@ four" <Section name="replace single char"> <Expression success="true" type="CHECK" filename="projects/SelfTest/TestMain.cpp" > <Original> - replaceInPlace( letters, "b", "z" ) + replaceInPlace( letters, "b", "z" ) </Original> <Expanded> true @@ -4851,10 +4964,10 @@ four" </Expression> <Expression success="true" type="CHECK" filename="projects/SelfTest/TestMain.cpp" > <Original> - letters == "azcdefcg" + letters == "azcdefcg" </Original> <Expanded> - "azcdefcg" == "azcdefcg" + "azcdefcg" == "azcdefcg" </Expanded> </Expression> <OverallResults successes="2" failures="0" expectedFailures="0"/> @@ -4862,7 +4975,7 @@ four" <Section name="replace two chars"> <Expression success="true" type="CHECK" filename="projects/SelfTest/TestMain.cpp" > <Original> - replaceInPlace( letters, "c", "z" ) + replaceInPlace( letters, "c", "z" ) </Original> <Expanded> true @@ -4870,10 +4983,10 @@ four" </Expression> <Expression success="true" type="CHECK" filename="projects/SelfTest/TestMain.cpp" > <Original> - letters == "abzdefzg" + letters == "abzdefzg" </Original> <Expanded> - "abzdefzg" == "abzdefzg" + "abzdefzg" == "abzdefzg" </Expanded> </Expression> <OverallResults successes="2" failures="0" expectedFailures="0"/> @@ -4881,7 +4994,7 @@ four" <Section name="replace first char"> <Expression success="true" type="CHECK" filename="projects/SelfTest/TestMain.cpp" > <Original> - replaceInPlace( letters, "a", "z" ) + replaceInPlace( letters, "a", "z" ) </Original> <Expanded> true @@ -4889,10 +5002,10 @@ four" </Expression> <Expression success="true" type="CHECK" filename="projects/SelfTest/TestMain.cpp" > <Original> - letters == "zbcdefcg" + letters == "zbcdefcg" </Original> <Expanded> - "zbcdefcg" == "zbcdefcg" + "zbcdefcg" == "zbcdefcg" </Expanded> </Expression> <OverallResults successes="2" failures="0" expectedFailures="0"/> @@ -4900,7 +5013,7 @@ four" <Section name="replace last char"> <Expression success="true" type="CHECK" filename="projects/SelfTest/TestMain.cpp" > <Original> - replaceInPlace( letters, "g", "z" ) + replaceInPlace( letters, "g", "z" ) </Original> <Expanded> true @@ -4908,10 +5021,10 @@ four" </Expression> <Expression success="true" type="CHECK" filename="projects/SelfTest/TestMain.cpp" > <Original> - letters == "abcdefcz" + letters == "abcdefcz" </Original> <Expanded> - "abcdefcz" == "abcdefcz" + "abcdefcz" == "abcdefcz" </Expanded> </Expression> <OverallResults successes="2" failures="0" expectedFailures="0"/> @@ -4919,7 +5032,7 @@ four" <Section name="replace all chars"> <Expression success="true" type="CHECK" filename="projects/SelfTest/TestMain.cpp" > <Original> - replaceInPlace( letters, letters, "replaced" ) + replaceInPlace( letters, letters, "replaced" ) </Original> <Expanded> true @@ -4927,10 +5040,10 @@ four" </Expression> <Expression success="true" type="CHECK" filename="projects/SelfTest/TestMain.cpp" > <Original> - letters == "replaced" + letters == "replaced" </Original> <Expanded> - "replaced" == "replaced" + "replaced" == "replaced" </Expanded> </Expression> <OverallResults successes="2" failures="0" expectedFailures="0"/> @@ -4938,7 +5051,7 @@ four" <Section name="replace no chars"> <Expression success="true" type="CHECK_FALSE" filename="projects/SelfTest/TestMain.cpp" > <Original> - !replaceInPlace( letters, "x", "z" ) + !replaceInPlace( letters, "x", "z" ) </Original> <Expanded> !false @@ -4949,7 +5062,7 @@ four" letters == letters </Original> <Expanded> - "abcdefcg" == "abcdefcg" + "abcdefcg" == "abcdefcg" </Expanded> </Expression> <OverallResults successes="2" failures="0" expectedFailures="0"/> @@ -4957,7 +5070,7 @@ four" <Section name="escape '"> <Expression success="true" type="CHECK" filename="projects/SelfTest/TestMain.cpp" > <Original> - replaceInPlace( s, "'", "|'" ) + replaceInPlace( s, "'", "|'" ) </Original> <Expanded> true @@ -4965,10 +5078,10 @@ four" </Expression> <Expression success="true" type="CHECK" filename="projects/SelfTest/TestMain.cpp" > <Original> - s == "didn|'t" + s == "didn|'t" </Original> <Expanded> - "didn|'t" == "didn|'t" + "didn|'t" == "didn|'t" </Expanded> </Expression> <OverallResults successes="2" failures="0" expectedFailures="0"/> @@ -4981,22 +5094,22 @@ four" <TestCase name="Text can be formatted using the Text class"> <Expression success="true" type="CHECK" filename="projects/SelfTest/TestMain.cpp" > <Original> - Text( "hi there" ).toString() == "hi there" + Text( "hi there" ).toString() == "hi there" </Original> <Expanded> - "hi there" == "hi there" + "hi there" == "hi there" </Expanded> </Expression> <Expression success="true" type="CHECK" filename="projects/SelfTest/TestMain.cpp" > <Original> - Text( "hi there", narrow ).toString() == "hi\nthere" + Text( "hi there", narrow ).toString() == "hi\nthere" </Original> <Expanded> - "hi -there" + "hi +there" == -"hi -there" +"hi +there" </Expanded> </Expression> <OverallResult success="true"/> @@ -5004,10 +5117,10 @@ there" <TestCase name="Long text is truncted"> <Expression success="true" type="CHECK_THAT" filename="projects/SelfTest/TestMain.cpp" > <Original> - t.toString() EndsWith( "... message truncated due to excessive size" ) + t.toString() EndsWith( "... message truncated due to excessive size" ) </Original> <Expanded> - "******************************************************************************- + "******************************************************************************- ******************************************************************************- ************************ ******************************************************************************- @@ -6007,7 +6120,7 @@ there" ******************************************************************************- ************************ ******************************************************************************- -... message truncated due to excessive size" ends with: "... message truncated due to excessive size" +... message truncated due to excessive size" ends with: "... message truncated due to excessive size" </Expanded> </Expression> <OverallResult success="true"/> @@ -6057,10 +6170,10 @@ there" <TestCase name="string literals of different sizes can be compared"> <Expression success="false" type="REQUIRE" filename="projects/SelfTest/TrickyTests.cpp" > <Original> - std::string( "first" ) == "second" + std::string( "first" ) == "second" </Original> <Expanded> - "first" == "second" + "first" == "second" </Expanded> </Expression> <OverallResult success="false"/> @@ -6303,10 +6416,10 @@ there" <TestCase name="non streamable - with conv. op"> <Expression success="true" type="REQUIRE" filename="projects/SelfTest/TrickyTests.cpp" > <Original> - s == "7" + s == "7" </Original> <Expanded> - "7" == "7" + "7" == "7" </Expanded> </Expression> <OverallResult success="true"/> @@ -6380,12 +6493,12 @@ there" <TestCase name="toString( has_toString )"> <Expression success="true" type="REQUIRE" filename="projects/SelfTest/ToStringWhich.cpp" > <Original> - Catch::toString( item ) == "toString( has_toString )" + Catch::toString( item ) == "toString( has_toString )" </Original> <Expanded> - "toString( has_toString )" + "toString( has_toString )" == -"toString( has_toString )" +"toString( has_toString )" </Expanded> </Expression> <OverallResult success="true"/> @@ -6393,12 +6506,12 @@ there" <TestCase name="toString( has_maker )"> <Expression success="true" type="REQUIRE" filename="projects/SelfTest/ToStringWhich.cpp" > <Original> - Catch::toString( item ) == "StringMaker<has_maker>" + Catch::toString( item ) == "StringMaker<has_maker>" </Original> <Expanded> - "StringMaker<has_maker>" + "StringMaker<has_maker>" == -"StringMaker<has_maker>" +"StringMaker<has_maker>" </Expanded> </Expression> <OverallResult success="true"/> @@ -6406,12 +6519,12 @@ there" <TestCase name="toString( has_maker_and_toString )"> <Expression success="true" type="REQUIRE" filename="projects/SelfTest/ToStringWhich.cpp" > <Original> - Catch::toString( item ) == "toString( has_maker_and_toString )" + Catch::toString( item ) == "toString( has_maker_and_toString )" </Original> <Expanded> - "toString( has_maker_and_toString )" + "toString( has_maker_and_toString )" == -"toString( has_maker_and_toString )" +"toString( has_maker_and_toString )" </Expanded> </Expression> <OverallResult success="true"/> @@ -6419,10 +6532,10 @@ there" <TestCase name="toString( vectors<has_toString )"> <Expression success="true" type="REQUIRE" filename="projects/SelfTest/ToStringWhich.cpp" > <Original> - Catch::toString( v ) == "{ {?} }" + Catch::toString( v ) == "{ {?} }" </Original> <Expanded> - "{ {?} }" == "{ {?} }" + "{ {?} }" == "{ {?} }" </Expanded> </Expression> <OverallResult success="true"/> @@ -6430,12 +6543,12 @@ there" <TestCase name="toString( vectors<has_maker )"> <Expression success="true" type="REQUIRE" filename="projects/SelfTest/ToStringWhich.cpp" > <Original> - Catch::toString( v ) == "{ StringMaker<has_maker> }" + Catch::toString( v ) == "{ StringMaker<has_maker> }" </Original> <Expanded> - "{ StringMaker<has_maker> }" + "{ StringMaker<has_maker> }" == -"{ StringMaker<has_maker> }" +"{ StringMaker<has_maker> }" </Expanded> </Expression> <OverallResult success="true"/> @@ -6443,12 +6556,12 @@ there" <TestCase name="toString( vectors<has_maker_and_toString )"> <Expression success="true" type="REQUIRE" filename="projects/SelfTest/ToStringWhich.cpp" > <Original> - Catch::toString( v ) == "{ StringMaker<has_maker_and_toString> }" + Catch::toString( v ) == "{ StringMaker<has_maker_and_toString> }" </Original> <Expanded> - "{ StringMaker<has_maker_and_toString> }" + "{ StringMaker<has_maker_and_toString> }" == -"{ StringMaker<has_maker_and_toString> }" +"{ StringMaker<has_maker_and_toString> }" </Expanded> </Expression> <OverallResult success="true"/> @@ -6456,10 +6569,10 @@ there" <TestCase name="std::pair<int,std::string> -> toString"> <Expression success="true" type="REQUIRE" filename="projects/SelfTest/ToStringPair.cpp" > <Original> - Catch::toString( value ) == "{ 34, \"xyzzy\" }" + Catch::toString( value ) == "{ 34, \"xyzzy\" }" </Original> <Expanded> - "{ 34, "xyzzy" }" == "{ 34, "xyzzy" }" + "{ 34, "xyzzy" }" == "{ 34, "xyzzy" }" </Expanded> </Expression> <OverallResult success="true"/> @@ -6467,10 +6580,10 @@ there" <TestCase name="std::pair<int,const std::string> -> toString"> <Expression success="true" type="REQUIRE" filename="projects/SelfTest/ToStringPair.cpp" > <Original> - Catch::toString(value) == "{ 34, \"xyzzy\" }" + Catch::toString(value) == "{ 34, \"xyzzy\" }" </Original> <Expanded> - "{ 34, "xyzzy" }" == "{ 34, "xyzzy" }" + "{ 34, "xyzzy" }" == "{ 34, "xyzzy" }" </Expanded> </Expression> <OverallResult success="true"/> @@ -6478,12 +6591,12 @@ there" <TestCase name="std::vector<std::pair<std::string,int> > -> toString"> <Expression success="true" type="REQUIRE" filename="projects/SelfTest/ToStringPair.cpp" > <Original> - Catch::toString( pr ) == "{ { \"green\", 55 } }" + Catch::toString( pr ) == "{ { \"green\", 55 } }" </Original> <Expanded> - "{ { "green", 55 } }" + "{ { "green", 55 } }" == -"{ { "green", 55 } }" +"{ { "green", 55 } }" </Expanded> </Expression> <OverallResult success="true"/> @@ -6491,12 +6604,12 @@ there" <TestCase name="pair<pair<int,const char *,pair<std::string,int> > -> toString"> <Expression success="true" type="REQUIRE" filename="projects/SelfTest/ToStringPair.cpp" > <Original> - Catch::toString( pair ) == "{ { 42, \"Arthur\" }, { \"Ford\", 24 } }" + Catch::toString( pair ) == "{ { 42, \"Arthur\" }, { \"Ford\", 24 } }" </Original> <Expanded> - "{ { 42, "Arthur" }, { "Ford", 24 } }" + "{ { 42, "Arthur" }, { "Ford", 24 } }" == -"{ { 42, "Arthur" }, { "Ford", 24 } }" +"{ { 42, "Arthur" }, { "Ford", 24 } }" </Expanded> </Expression> <OverallResult success="true"/> @@ -6504,26 +6617,26 @@ there" <TestCase name="vector<int> -> toString"> <Expression success="true" type="REQUIRE" filename="projects/SelfTest/ToStringVector.cpp" > <Original> - Catch::toString(vv) == "{ }" + Catch::toString(vv) == "{ }" </Original> <Expanded> - "{ }" == "{ }" + "{ }" == "{ }" </Expanded> </Expression> <Expression success="true" type="REQUIRE" filename="projects/SelfTest/ToStringVector.cpp" > <Original> - Catch::toString(vv) == "{ 42 }" + Catch::toString(vv) == "{ 42 }" </Original> <Expanded> - "{ 42 }" == "{ 42 }" + "{ 42 }" == "{ 42 }" </Expanded> </Expression> <Expression success="true" type="REQUIRE" filename="projects/SelfTest/ToStringVector.cpp" > <Original> - Catch::toString(vv) == "{ 42, 250 }" + Catch::toString(vv) == "{ 42, 250 }" </Original> <Expanded> - "{ 42, 250 }" == "{ 42, 250 }" + "{ 42, 250 }" == "{ 42, 250 }" </Expanded> </Expression> <OverallResult success="true"/> @@ -6531,28 +6644,28 @@ there" <TestCase name="vector<string> -> toString"> <Expression success="true" type="REQUIRE" filename="projects/SelfTest/ToStringVector.cpp" > <Original> - Catch::toString(vv) == "{ }" + Catch::toString(vv) == "{ }" </Original> <Expanded> - "{ }" == "{ }" + "{ }" == "{ }" </Expanded> </Expression> <Expression success="true" type="REQUIRE" filename="projects/SelfTest/ToStringVector.cpp" > <Original> - Catch::toString(vv) == "{ \"hello\" }" + Catch::toString(vv) == "{ \"hello\" }" </Original> <Expanded> - "{ "hello" }" == "{ "hello" }" + "{ "hello" }" == "{ "hello" }" </Expanded> </Expression> <Expression success="true" type="REQUIRE" filename="projects/SelfTest/ToStringVector.cpp" > <Original> - Catch::toString(vv) == "{ \"hello\", \"world\" }" + Catch::toString(vv) == "{ \"hello\", \"world\" }" </Original> <Expanded> - "{ "hello", "world" }" + "{ "hello", "world" }" == -"{ "hello", "world" }" +"{ "hello", "world" }" </Expanded> </Expression> <OverallResult success="true"/> @@ -6560,26 +6673,26 @@ there" <TestCase name="vector<int,allocator> -> toString"> <Expression success="true" type="REQUIRE" filename="projects/SelfTest/ToStringVector.cpp" > <Original> - Catch::toString(vv) == "{ }" + Catch::toString(vv) == "{ }" </Original> <Expanded> - "{ }" == "{ }" + "{ }" == "{ }" </Expanded> </Expression> <Expression success="true" type="REQUIRE" filename="projects/SelfTest/ToStringVector.cpp" > <Original> - Catch::toString(vv) == "{ 42 }" + Catch::toString(vv) == "{ 42 }" </Original> <Expanded> - "{ 42 }" == "{ 42 }" + "{ 42 }" == "{ 42 }" </Expanded> </Expression> <Expression success="true" type="REQUIRE" filename="projects/SelfTest/ToStringVector.cpp" > <Original> - Catch::toString(vv) == "{ 42, 250 }" + Catch::toString(vv) == "{ 42, 250 }" </Original> <Expanded> - "{ 42, 250 }" == "{ 42, 250 }" + "{ 42, 250 }" == "{ 42, 250 }" </Expanded> </Expression> <OverallResult success="true"/> @@ -6587,20 +6700,20 @@ there" <TestCase name="vec<vec<string,alloc>> -> toString"> <Expression success="true" type="REQUIRE" filename="projects/SelfTest/ToStringVector.cpp" > <Original> - Catch::toString(v) == "{ }" + Catch::toString(v) == "{ }" </Original> <Expanded> - "{ }" == "{ }" + "{ }" == "{ }" </Expanded> </Expression> <Expression success="true" type="REQUIRE" filename="projects/SelfTest/ToStringVector.cpp" > <Original> - Catch::toString(v) == "{ { \"hello\" }, { \"world\" } }" + Catch::toString(v) == "{ { \"hello\" }, { \"world\" } }" </Original> <Expanded> - "{ { "hello" }, { "world" } }" + "{ { "hello" }, { "world" } }" == -"{ { "hello" }, { "world" } }" +"{ { "hello" }, { "world" } }" </Expanded> </Expression> <OverallResult success="true"/> @@ -6819,7 +6932,7 @@ there" </Expression> <Expression success="true" type="CHECK" filename="projects/SelfTest/CmdLineTests.cpp" > <Original> - parseTestSpec( "*a" ).matches( tcA ) == true + parseTestSpec( "*a" ).matches( tcA ) == true </Original> <Expanded> true == true @@ -6870,7 +6983,7 @@ there" </Expression> <Expression success="true" type="CHECK" filename="projects/SelfTest/CmdLineTests.cpp" > <Original> - parseTestSpec( "a*" ).matches( tcA ) == true + parseTestSpec( "a*" ).matches( tcA ) == true </Original> <Expanded> true == true @@ -6921,7 +7034,7 @@ there" </Expression> <Expression success="true" type="CHECK" filename="projects/SelfTest/CmdLineTests.cpp" > <Original> - parseTestSpec( "*a*" ).matches( tcA ) == true + parseTestSpec( "*a*" ).matches( tcA ) == true </Original> <Expanded> true == true @@ -7784,18 +7897,18 @@ there" <TestCase name="tuple<>"> <Expression success="true" type="CHECK" filename="projects/SelfTest/ToStringTuple.cpp" > <Original> - "{ }" == Catch::toString(type{}) + "{ }" == Catch::toString(type{}) </Original> <Expanded> - "{ }" == "{ }" + "{ }" == "{ }" </Expanded> </Expression> <Expression success="true" type="CHECK" filename="projects/SelfTest/ToStringTuple.cpp" > <Original> - "{ }" == Catch::toString(value) + "{ }" == Catch::toString(value) </Original> <Expanded> - "{ }" == "{ }" + "{ }" == "{ }" </Expanded> </Expression> <OverallResult success="true"/> @@ -7803,10 +7916,10 @@ there" <TestCase name="tuple<int>"> <Expression success="true" type="CHECK" filename="projects/SelfTest/ToStringTuple.cpp" > <Original> - "{ 0 }" == Catch::toString(type{0}) + "{ 0 }" == Catch::toString(type{0}) </Original> <Expanded> - "{ 0 }" == "{ 0 }" + "{ 0 }" == "{ 0 }" </Expanded> </Expression> <OverallResult success="true"/> @@ -7814,18 +7927,18 @@ there" <TestCase name="tuple<float,int>"> <Expression success="true" type="CHECK" filename="projects/SelfTest/ToStringTuple.cpp" > <Original> - "1.2f" == Catch::toString(float(1.2)) + "1.2f" == Catch::toString(float(1.2)) </Original> <Expanded> - "1.2f" == "1.2f" + "1.2f" == "1.2f" </Expanded> </Expression> <Expression success="true" type="CHECK" filename="projects/SelfTest/ToStringTuple.cpp" > <Original> - "{ 1.2f, 0 }" == Catch::toString(type{1.2,0}) + "{ 1.2f, 0 }" == Catch::toString(type{1.2,0}) </Original> <Expanded> - "{ 1.2f, 0 }" == "{ 1.2f, 0 }" + "{ 1.2f, 0 }" == "{ 1.2f, 0 }" </Expanded> </Expression> <OverallResult success="true"/> @@ -7833,12 +7946,12 @@ there" <TestCase name="tuple<string,string>"> <Expression success="true" type="CHECK" filename="projects/SelfTest/ToStringTuple.cpp" > <Original> - "{ \"hello\", \"world\" }" == Catch::toString(type{"hello","world"}) + "{ \"hello\", \"world\" }" == Catch::toString(type{"hello","world"}) </Original> <Expanded> - "{ "hello", "world" }" + "{ "hello", "world" }" == -"{ "hello", "world" }" +"{ "hello", "world" }" </Expanded> </Expression> <OverallResult success="true"/> @@ -7846,12 +7959,12 @@ there" <TestCase name="tuple<tuple<int>,tuple<>,float>"> <Expression success="true" type="CHECK" filename="projects/SelfTest/ToStringTuple.cpp" > <Original> - "{ { 42 }, { }, 1.2f }" == Catch::toString(value) + "{ { 42 }, { }, 1.2f }" == Catch::toString(value) </Original> <Expanded> - "{ { 42 }, { }, 1.2f }" + "{ { 42 }, { }, 1.2f }" == -"{ { 42 }, { }, 1.2f }" +"{ { 42 }, { }, 1.2f }" </Expanded> </Expression> <OverallResult success="true"/> @@ -7859,12 +7972,12 @@ there" <TestCase name="tuple<nullptr,int,const char *>"> <Expression success="true" type="CHECK" filename="projects/SelfTest/ToStringTuple.cpp" > <Original> - "{ nullptr, 42, \"Catch me\" }" == Catch::toString(value) + "{ nullptr, 42, \"Catch me\" }" == Catch::toString(value) </Original> <Expanded> - "{ nullptr, 42, "Catch me" }" + "{ nullptr, 42, "Catch me" }" == -"{ nullptr, 42, "Catch me" }" +"{ nullptr, 42, "Catch me" }" </Expanded> </Expression> <OverallResult success="true"/> @@ -7873,42 +7986,42 @@ there" <Section name="The same tag alias can only be registered once"> <Expression success="true" type="CHECK_THAT" filename="projects/SelfTest/TagAliasTests.cpp" > <Original> - what Contains( "[@zzz]" ) + what Contains( "[@zzz]" ) </Original> <Expanded> - "error: tag alias, "[@zzz]" already registered. + "error: tag alias, "[@zzz]" already registered. First seen at file:2 - Redefined at file:10" contains: "[@zzz]" + Redefined at file:10" contains: "[@zzz]" </Expanded> </Expression> <Expression success="true" type="CHECK_THAT" filename="projects/SelfTest/TagAliasTests.cpp" > <Original> - what Contains( "file" ) + what Contains( "file" ) </Original> <Expanded> - "error: tag alias, "[@zzz]" already registered. + "error: tag alias, "[@zzz]" already registered. First seen at file:2 - Redefined at file:10" contains: "file" + Redefined at file:10" contains: "file" </Expanded> </Expression> <Expression success="true" type="CHECK_THAT" filename="projects/SelfTest/TagAliasTests.cpp" > <Original> - what Contains( "2" ) + what Contains( "2" ) </Original> <Expanded> - "error: tag alias, "[@zzz]" already registered. + "error: tag alias, "[@zzz]" already registered. First seen at file:2 - Redefined at file:10" contains: "2" + Redefined at file:10" contains: "2" </Expanded> </Expression> <Expression success="true" type="CHECK_THAT" filename="projects/SelfTest/TagAliasTests.cpp" > <Original> - what Contains( "10" ) + what Contains( "10" ) </Original> <Expanded> - "error: tag alias, "[@zzz]" already registered. + "error: tag alias, "[@zzz]" already registered. First seen at file:2 - Redefined at file:10" contains: "10" + Redefined at file:10" contains: "10" </Expanded> </Expression> <OverallResults successes="4" failures="0" expectedFailures="0"/> @@ -7916,34 +8029,34 @@ there" <Section name="Tag aliases must be of the form [@name]"> <Expression success="true" type="CHECK_THROWS" filename="projects/SelfTest/TagAliasTests.cpp" > <Original> - registry.add( "[no ampersat]", "", Catch::SourceLineInfo( "file", 3 ) ) + registry.add( "[no ampersat]", "", Catch::SourceLineInfo( "file", 3 ) ) </Original> <Expanded> - registry.add( "[no ampersat]", "", Catch::SourceLineInfo( "file", 3 ) ) + registry.add( "[no ampersat]", "", Catch::SourceLineInfo( "file", 3 ) ) </Expanded> </Expression> <Expression success="true" type="CHECK_THROWS" filename="projects/SelfTest/TagAliasTests.cpp" > <Original> - registry.add( "[the @ is not at the start]", "", Catch::SourceLineInfo( "file", 3 ) ) + registry.add( "[the @ is not at the start]", "", Catch::SourceLineInfo( "file", 3 ) ) </Original> <Expanded> - registry.add( "[the @ is not at the start]", "", Catch::SourceLineInfo( "file", 3 ) ) + registry.add( "[the @ is not at the start]", "", Catch::SourceLineInfo( "file", 3 ) ) </Expanded> </Expression> <Expression success="true" type="CHECK_THROWS" filename="projects/SelfTest/TagAliasTests.cpp" > <Original> - registry.add( "@no square bracket at start]", "", Catch::SourceLineInfo( "file", 3 ) ) + registry.add( "@no square bracket at start]", "", Catch::SourceLineInfo( "file", 3 ) ) </Original> <Expanded> - registry.add( "@no square bracket at start]", "", Catch::SourceLineInfo( "file", 3 ) ) + registry.add( "@no square bracket at start]", "", Catch::SourceLineInfo( "file", 3 ) ) </Expanded> </Expression> <Expression success="true" type="CHECK_THROWS" filename="projects/SelfTest/TagAliasTests.cpp" > <Original> - registry.add( "[@no square bracket at end", "", Catch::SourceLineInfo( "file", 3 ) ) + registry.add( "[@no square bracket at end", "", Catch::SourceLineInfo( "file", 3 ) ) </Original> <Expanded> - registry.add( "[@no square bracket at end", "", Catch::SourceLineInfo( "file", 3 ) ) + registry.add( "[@no square bracket at end", "", Catch::SourceLineInfo( "file", 3 ) ) </Expanded> </Expression> <OverallResults successes="4" failures="0" expectedFailures="0"/> @@ -8299,7 +8412,7 @@ there" </Section> <OverallResult success="true"/> </TestCase> - <OverallResults successes="680" failures="100" expectedFailures="13"/> + <OverallResults successes="690" failures="100" expectedFailures="13"/> </Group> - <OverallResults successes="680" failures="100" expectedFailures="13"/> + <OverallResults successes="690" failures="100" expectedFailures="13"/> </Catch> diff --git a/projects/SelfTest/MiscTests.cpp b/projects/SelfTest/MiscTests.cpp index d91db944..04b86c81 100644 --- a/projects/SelfTest/MiscTests.cpp +++ b/projects/SelfTest/MiscTests.cpp @@ -7,6 +7,7 @@ */ #include "catch.hpp" +#include "catch_xmlwriter.hpp" #include <iostream> @@ -381,6 +382,42 @@ TEST_CASE( "toString on wchar_t returns the string contents", "[toString]" ) { CHECK( result == "\"wide load\"" ); } +inline std::string encode( std::string const& str, Catch::XmlEncode::ForWhat forWhat = Catch::XmlEncode::ForTextNodes ) { + std::ostringstream oss; + oss << Catch::XmlEncode( str, forWhat ); + return oss.str(); +} + +TEST_CASE( "XmlEncode" ) { + SECTION( "normal string" ) { + REQUIRE( encode( "normal string" ) == "normal string" ); + } + SECTION( "empty string" ) { + REQUIRE( encode( "" ) == "" ); + } + SECTION( "string with ampersand" ) { + REQUIRE( encode( "smith & jones" ) == "smith & jones" ); + } + SECTION( "string with less-than" ) { + REQUIRE( encode( "smith < jones" ) == "smith < jones" ); + } + SECTION( "string with greater-than" ) { + REQUIRE( encode( "smith > jones" ) == "smith > jones" ); + REQUIRE( encode( "smith ]]> jones" ) == "smith ]]> jones" ); + } + SECTION( "string with quotes" ) { + std::string stringWithQuotes = "don't \"quote\" me on that"; + REQUIRE( encode( stringWithQuotes ) == stringWithQuotes ); + REQUIRE( encode( stringWithQuotes, Catch::XmlEncode::ForAttributes ) == "don't "quote" me on that" ); + } + SECTION( "string with control char (1)" ) { + REQUIRE( encode( "[\x01]" ) == "[]" ); + } + SECTION( "string with control char (x7F)" ) { + REQUIRE( encode( "[\x7F]" ) == "[]" ); + } +} + //TEST_CASE( "Divide by Zero signal handler", "[.][sig]" ) { // int i = 0; // int x = 10/i; // This should cause the signal to fire