mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-22 13:26:10 +01:00
Add explicit test for serialization of boolean attributes in XML
This commit is contained in:
parent
0e2895934c
commit
5741de9ccd
@ -269,6 +269,7 @@ Message from section two
|
|||||||
:test-result: PASS X/level/1/a
|
:test-result: PASS X/level/1/a
|
||||||
:test-result: PASS X/level/1/b
|
:test-result: PASS X/level/1/b
|
||||||
:test-result: PASS XmlEncode
|
:test-result: PASS XmlEncode
|
||||||
|
:test-result: PASS XmlWriter writes boolean attributes as true/false
|
||||||
:test-result: PASS analyse no analysis
|
:test-result: PASS analyse no analysis
|
||||||
:test-result: PASS array<int, N> -> toString
|
:test-result: PASS array<int, N> -> toString
|
||||||
:test-result: PASS atomic if
|
:test-result: PASS atomic if
|
||||||
|
@ -1982,6 +1982,9 @@ Xml.tests.cpp:<line number>: passed: encode( stringWithQuotes, Catch::XmlEncode:
|
|||||||
"don't "quote" me on that"
|
"don't "quote" me on that"
|
||||||
Xml.tests.cpp:<line number>: passed: encode( "[\x01]" ) == "[\\x01]" for: "[\x01]" == "[\x01]"
|
Xml.tests.cpp:<line number>: passed: encode( "[\x01]" ) == "[\\x01]" for: "[\x01]" == "[\x01]"
|
||||||
Xml.tests.cpp:<line number>: passed: encode( "[\x7F]" ) == "[\\x7F]" for: "[\x7F]" == "[\x7F]"
|
Xml.tests.cpp:<line number>: passed: encode( "[\x7F]" ) == "[\\x7F]" for: "[\x7F]" == "[\x7F]"
|
||||||
|
Xml.tests.cpp:<line number>: passed: stream.str(), Contains(R"(attr1="true")") && Contains(R"(attr2="false")") for: "<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Element1 attr1="true" attr2="false"/>
|
||||||
|
" ( contains: "attr1="true"" and contains: "attr2="false"" )
|
||||||
InternalBenchmark.tests.cpp:<line number>: passed: analysis.mean.point.count() == 23 for: 23.0 == 23
|
InternalBenchmark.tests.cpp:<line number>: passed: analysis.mean.point.count() == 23 for: 23.0 == 23
|
||||||
InternalBenchmark.tests.cpp:<line number>: passed: analysis.mean.lower_bound.count() == 23 for: 23.0 == 23
|
InternalBenchmark.tests.cpp:<line number>: passed: analysis.mean.lower_bound.count() == 23 for: 23.0 == 23
|
||||||
InternalBenchmark.tests.cpp:<line number>: passed: analysis.mean.upper_bound.count() == 23 for: 23.0 == 23
|
InternalBenchmark.tests.cpp:<line number>: passed: analysis.mean.upper_bound.count() == 23 for: 23.0 == 23
|
||||||
|
@ -1386,6 +1386,6 @@ due to unexpected exception with message:
|
|||||||
Why would you throw a std::string?
|
Why would you throw a std::string?
|
||||||
|
|
||||||
===============================================================================
|
===============================================================================
|
||||||
test cases: 363 | 287 passed | 70 failed | 6 failed as expected
|
test cases: 364 | 288 passed | 70 failed | 6 failed as expected
|
||||||
assertions: 2090 | 1938 passed | 129 failed | 23 failed as expected
|
assertions: 2091 | 1939 passed | 129 failed | 23 failed as expected
|
||||||
|
|
||||||
|
@ -14068,6 +14068,19 @@ Xml.tests.cpp:<line number>: PASSED:
|
|||||||
with expansion:
|
with expansion:
|
||||||
"[\x7F]" == "[\x7F]"
|
"[\x7F]" == "[\x7F]"
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
XmlWriter writes boolean attributes as true/false
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Xml.tests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
Xml.tests.cpp:<line number>: PASSED:
|
||||||
|
REQUIRE_THAT( stream.str(), Contains(R"(attr1="true")") && Contains(R"(attr2="false")") )
|
||||||
|
with expansion:
|
||||||
|
"<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Element1 attr1="true" attr2="false"/>
|
||||||
|
" ( contains: "attr1="true"" and contains: "attr2="false"" )
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
analyse no analysis
|
analyse no analysis
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
@ -16830,6 +16843,6 @@ Misc.tests.cpp:<line number>
|
|||||||
Misc.tests.cpp:<line number>: PASSED:
|
Misc.tests.cpp:<line number>: PASSED:
|
||||||
|
|
||||||
===============================================================================
|
===============================================================================
|
||||||
test cases: 363 | 271 passed | 86 failed | 6 failed as expected
|
test cases: 364 | 272 passed | 86 failed | 6 failed as expected
|
||||||
assertions: 2107 | 1938 passed | 146 failed | 23 failed as expected
|
assertions: 2108 | 1939 passed | 146 failed | 23 failed as expected
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<testsuitesloose text artifact
|
<testsuitesloose text artifact
|
||||||
>
|
>
|
||||||
<testsuite name="<exe-name>" errors="17" failures="130" tests="2108" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
|
<testsuite name="<exe-name>" errors="17" failures="130" tests="2109" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
|
||||||
<properties>
|
<properties>
|
||||||
<property name="filters" value="~[!nonportable]~[!benchmark]~[approvals] *"/>
|
<property name="filters" value="~[!nonportable]~[!benchmark]~[approvals] *"/>
|
||||||
<property name="random-seed" value="1"/>
|
<property name="random-seed" value="1"/>
|
||||||
@ -1513,6 +1513,7 @@ Exception.tests.cpp:<line number>
|
|||||||
<testcase classname="<exe-name>.global" name="XmlEncode/string with quotes" time="{duration}" status="run"/>
|
<testcase classname="<exe-name>.global" name="XmlEncode/string with quotes" time="{duration}" status="run"/>
|
||||||
<testcase classname="<exe-name>.global" name="XmlEncode/string with control char (1)" time="{duration}" status="run"/>
|
<testcase classname="<exe-name>.global" name="XmlEncode/string with control char (1)" time="{duration}" status="run"/>
|
||||||
<testcase classname="<exe-name>.global" name="XmlEncode/string with control char (x7F)" time="{duration}" status="run"/>
|
<testcase classname="<exe-name>.global" name="XmlEncode/string with control char (x7F)" time="{duration}" status="run"/>
|
||||||
|
<testcase classname="<exe-name>.global" name="XmlWriter writes boolean attributes as true/false" time="{duration}" status="run"/>
|
||||||
<testcase classname="<exe-name>.global" name="analyse no analysis" time="{duration}" status="run"/>
|
<testcase classname="<exe-name>.global" name="analyse no analysis" time="{duration}" status="run"/>
|
||||||
<testcase classname="<exe-name>.global" name="array<int, N> -> toString" time="{duration}" status="run"/>
|
<testcase classname="<exe-name>.global" name="array<int, N> -> toString" time="{duration}" status="run"/>
|
||||||
<testcase classname="<exe-name>.global" name="atomic if" time="{duration}" status="run"/>
|
<testcase classname="<exe-name>.global" name="atomic if" time="{duration}" status="run"/>
|
||||||
|
@ -253,6 +253,7 @@
|
|||||||
<testCase name="XmlEncode/string with quotes" duration="{duration}"/>
|
<testCase name="XmlEncode/string with quotes" duration="{duration}"/>
|
||||||
<testCase name="XmlEncode/string with control char (1)" duration="{duration}"/>
|
<testCase name="XmlEncode/string with control char (1)" duration="{duration}"/>
|
||||||
<testCase name="XmlEncode/string with control char (x7F)" duration="{duration}"/>
|
<testCase name="XmlEncode/string with control char (x7F)" duration="{duration}"/>
|
||||||
|
<testCase name="XmlWriter writes boolean attributes as true/false" duration="{duration}"/>
|
||||||
</file>
|
</file>
|
||||||
<file path="tests/<exe-name>/UsageTests/Approx.tests.cpp">
|
<file path="tests/<exe-name>/UsageTests/Approx.tests.cpp">
|
||||||
<testCase name="A comparison that uses literals instead of the normal constructor" duration="{duration}"/>
|
<testCase name="A comparison that uses literals instead of the normal constructor" duration="{duration}"/>
|
||||||
|
@ -3541,6 +3541,8 @@ ok {test-number} - encode( stringWithQuotes, Catch::XmlEncode::ForAttributes ) =
|
|||||||
ok {test-number} - encode( "[\x01]" ) == "[\\x01]" for: "[\x01]" == "[\x01]"
|
ok {test-number} - encode( "[\x01]" ) == "[\\x01]" for: "[\x01]" == "[\x01]"
|
||||||
# XmlEncode
|
# XmlEncode
|
||||||
ok {test-number} - encode( "[\x7F]" ) == "[\\x7F]" for: "[\x7F]" == "[\x7F]"
|
ok {test-number} - encode( "[\x7F]" ) == "[\\x7F]" for: "[\x7F]" == "[\x7F]"
|
||||||
|
# XmlWriter writes boolean attributes as true/false
|
||||||
|
ok {test-number} - stream.str(), Contains(R"(attr1="true")") && Contains(R"(attr2="false")") for: "<?xml version="1.0" encoding="UTF-8"?> <Element1 attr1="true" attr2="false"/> " ( contains: "attr1="true"" and contains: "attr2="false"" )
|
||||||
# analyse no analysis
|
# analyse no analysis
|
||||||
ok {test-number} - analysis.mean.point.count() == 23 for: 23.0 == 23
|
ok {test-number} - analysis.mean.point.count() == 23 for: 23.0 == 23
|
||||||
# analyse no analysis
|
# analyse no analysis
|
||||||
@ -4216,5 +4218,5 @@ ok {test-number} - q3 == 23. for: 23.0 == 23.0
|
|||||||
ok {test-number} -
|
ok {test-number} -
|
||||||
# xmlentitycheck
|
# xmlentitycheck
|
||||||
ok {test-number} -
|
ok {test-number} -
|
||||||
1..2107
|
1..2108
|
||||||
|
|
||||||
|
@ -662,6 +662,8 @@ Exception.tests.cpp:<line number>|nunexpected exception with message:|n "unexpe
|
|||||||
##teamcity[testFinished name='X/level/1/b' duration="{duration}"]
|
##teamcity[testFinished name='X/level/1/b' duration="{duration}"]
|
||||||
##teamcity[testStarted name='XmlEncode']
|
##teamcity[testStarted name='XmlEncode']
|
||||||
##teamcity[testFinished name='XmlEncode' duration="{duration}"]
|
##teamcity[testFinished name='XmlEncode' duration="{duration}"]
|
||||||
|
##teamcity[testStarted name='XmlWriter writes boolean attributes as true/false']
|
||||||
|
##teamcity[testFinished name='XmlWriter writes boolean attributes as true/false' duration="{duration}"]
|
||||||
##teamcity[testStarted name='analyse no analysis']
|
##teamcity[testStarted name='analyse no analysis']
|
||||||
##teamcity[testFinished name='analyse no analysis' duration="{duration}"]
|
##teamcity[testFinished name='analyse no analysis' duration="{duration}"]
|
||||||
##teamcity[testStarted name='array<int, N> -> toString']
|
##teamcity[testStarted name='array<int, N> -> toString']
|
||||||
|
@ -16544,6 +16544,19 @@ There is no extra whitespace here
|
|||||||
</Section>
|
</Section>
|
||||||
<OverallResult success="true"/>
|
<OverallResult success="true"/>
|
||||||
</TestCase>
|
</TestCase>
|
||||||
|
<TestCase name="XmlWriter writes boolean attributes as true/false" tags="[XML][XmlWriter]" filename="tests/<exe-name>/IntrospectiveTests/Xml.tests.cpp" >
|
||||||
|
<Expression success="true" type="REQUIRE_THAT" filename="tests/<exe-name>/IntrospectiveTests/Xml.tests.cpp" >
|
||||||
|
<Original>
|
||||||
|
stream.str(), Contains(R"(attr1="true")") && Contains(R"(attr2="false")")
|
||||||
|
</Original>
|
||||||
|
<Expanded>
|
||||||
|
"<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Element1 attr1="true" attr2="false"/>
|
||||||
|
" ( contains: "attr1="true"" and contains: "attr2="false"" )
|
||||||
|
</Expanded>
|
||||||
|
</Expression>
|
||||||
|
<OverallResult success="true"/>
|
||||||
|
</TestCase>
|
||||||
<TestCase name="analyse no analysis" tags="[benchmark]" filename="tests/<exe-name>/IntrospectiveTests/InternalBenchmark.tests.cpp" >
|
<TestCase name="analyse no analysis" tags="[benchmark]" filename="tests/<exe-name>/IntrospectiveTests/InternalBenchmark.tests.cpp" >
|
||||||
<Expression success="true" type="CHECK" filename="tests/<exe-name>/IntrospectiveTests/InternalBenchmark.tests.cpp" >
|
<Expression success="true" type="CHECK" filename="tests/<exe-name>/IntrospectiveTests/InternalBenchmark.tests.cpp" >
|
||||||
<Original>
|
<Original>
|
||||||
@ -19802,9 +19815,9 @@ loose text artifact
|
|||||||
</Section>
|
</Section>
|
||||||
<OverallResult success="true"/>
|
<OverallResult success="true"/>
|
||||||
</TestCase>
|
</TestCase>
|
||||||
<OverallResults successes="1938" failures="147" expectedFailures="23"/>
|
<OverallResults successes="1939" failures="147" expectedFailures="23"/>
|
||||||
<OverallResultsCases successes="271" failures="86" expectedFailures="6"/>
|
<OverallResultsCases successes="272" failures="86" expectedFailures="6"/>
|
||||||
</Group>
|
</Group>
|
||||||
<OverallResults successes="1938" failures="146" expectedFailures="23"/>
|
<OverallResults successes="1939" failures="146" expectedFailures="23"/>
|
||||||
<OverallResultsCases successes="271" failures="86" expectedFailures="6"/>
|
<OverallResultsCases successes="272" failures="86" expectedFailures="6"/>
|
||||||
</Catch>
|
</Catch>
|
||||||
|
@ -2,6 +2,9 @@
|
|||||||
#include <catch2/internal/catch_xmlwriter.hpp>
|
#include <catch2/internal/catch_xmlwriter.hpp>
|
||||||
|
|
||||||
#include <catch2/internal/catch_stream.hpp>
|
#include <catch2/internal/catch_stream.hpp>
|
||||||
|
#include <catch2/matchers/catch_matchers_string.hpp>
|
||||||
|
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
static std::string encode( std::string const& str, Catch::XmlEncode::ForWhat forWhat = Catch::XmlEncode::ForTextNodes ) {
|
static std::string encode( std::string const& str, Catch::XmlEncode::ForWhat forWhat = Catch::XmlEncode::ForTextNodes ) {
|
||||||
Catch::ReusableStringStream oss;
|
Catch::ReusableStringStream oss;
|
||||||
@ -112,3 +115,19 @@ TEST_CASE("XmlEncode: UTF-8", "[XML][UTF-8][approvals]") {
|
|||||||
}
|
}
|
||||||
#undef ESC
|
#undef ESC
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE("XmlWriter writes boolean attributes as true/false", "[XML][XmlWriter]") {
|
||||||
|
using Catch::Matchers::Contains;
|
||||||
|
std::stringstream stream;
|
||||||
|
{
|
||||||
|
Catch::XmlWriter xml(stream);
|
||||||
|
|
||||||
|
xml.scopedElement("Element1")
|
||||||
|
.writeAttribute("attr1", true)
|
||||||
|
.writeAttribute("attr2", false);
|
||||||
|
}
|
||||||
|
|
||||||
|
REQUIRE_THAT( stream.str(),
|
||||||
|
Contains(R"(attr1="true")") &&
|
||||||
|
Contains(R"(attr2="false")") );
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user