Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorMartin Hořeňovský2021-05-30 20:02:02 +0200
committerMartin Hořeňovský2021-05-31 08:41:28 +0200
commit5741de9ccdca3f41131c377394b4e3db0f11686c (patch)
tree873a189a806b3bed71bc7ddfd60fc89d905b3051 /tests
parent0e2895934cf778f3bd7e84b3df10dac81d4ef7e3 (diff)
downloadcatch3-5741de9ccdca3f41131c377394b4e3db0f11686c.tar.gz
Add explicit test for serialization of boolean attributes in XML
Diffstat (limited to 'tests')
-rw-r--r--tests/SelfTest/Baselines/automake.sw.approved.txt1
-rw-r--r--tests/SelfTest/Baselines/compact.sw.approved.txt3
-rw-r--r--tests/SelfTest/Baselines/console.std.approved.txt4
-rw-r--r--tests/SelfTest/Baselines/console.sw.approved.txt17
-rw-r--r--tests/SelfTest/Baselines/junit.sw.approved.txt3
-rw-r--r--tests/SelfTest/Baselines/sonarqube.sw.approved.txt1
-rw-r--r--tests/SelfTest/Baselines/tap.sw.approved.txt4
-rw-r--r--tests/SelfTest/Baselines/teamcity.sw.approved.txt2
-rw-r--r--tests/SelfTest/Baselines/xml.sw.approved.txt21
-rw-r--r--tests/SelfTest/IntrospectiveTests/Xml.tests.cpp19
10 files changed, 65 insertions, 10 deletions
diff --git a/tests/SelfTest/Baselines/automake.sw.approved.txt b/tests/SelfTest/Baselines/automake.sw.approved.txt
index 7cf2f2c8..d6ffeee7 100644
--- a/tests/SelfTest/Baselines/automake.sw.approved.txt
+++ b/tests/SelfTest/Baselines/automake.sw.approved.txt
@@ -269,6 +269,7 @@ Message from section two
:test-result: PASS X/level/1/a
:test-result: PASS X/level/1/b
:test-result: PASS XmlEncode
+:test-result: PASS XmlWriter writes boolean attributes as true/false
:test-result: PASS analyse no analysis
:test-result: PASS array<int, N> -> toString
:test-result: PASS atomic if
diff --git a/tests/SelfTest/Baselines/compact.sw.approved.txt b/tests/SelfTest/Baselines/compact.sw.approved.txt
index 41e6dc96..c41b3b34 100644
--- a/tests/SelfTest/Baselines/compact.sw.approved.txt
+++ b/tests/SelfTest/Baselines/compact.sw.approved.txt
@@ -1982,6 +1982,9 @@ Xml.tests.cpp:<line number>: passed: encode( stringWithQuotes, Catch::XmlEncode:
"don't &quot;quote&quot; me on that"
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: 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.lower_bound.count() == 23 for: 23.0 == 23
InternalBenchmark.tests.cpp:<line number>: passed: analysis.mean.upper_bound.count() == 23 for: 23.0 == 23
diff --git a/tests/SelfTest/Baselines/console.std.approved.txt b/tests/SelfTest/Baselines/console.std.approved.txt
index 1d928cf9..a65f658c 100644
--- a/tests/SelfTest/Baselines/console.std.approved.txt
+++ b/tests/SelfTest/Baselines/console.std.approved.txt
@@ -1386,6 +1386,6 @@ due to unexpected exception with message:
Why would you throw a std::string?
===============================================================================
-test cases: 363 | 287 passed | 70 failed | 6 failed as expected
-assertions: 2090 | 1938 passed | 129 failed | 23 failed as expected
+test cases: 364 | 288 passed | 70 failed | 6 failed as expected
+assertions: 2091 | 1939 passed | 129 failed | 23 failed as expected
diff --git a/tests/SelfTest/Baselines/console.sw.approved.txt b/tests/SelfTest/Baselines/console.sw.approved.txt
index 98394d06..b5045fe1 100644
--- a/tests/SelfTest/Baselines/console.sw.approved.txt
+++ b/tests/SelfTest/Baselines/console.sw.approved.txt
@@ -14069,6 +14069,19 @@ with expansion:
"[\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
-------------------------------------------------------------------------------
InternalBenchmark.tests.cpp:<line number>
@@ -16830,6 +16843,6 @@ Misc.tests.cpp:<line number>
Misc.tests.cpp:<line number>: PASSED:
===============================================================================
-test cases: 363 | 271 passed | 86 failed | 6 failed as expected
-assertions: 2107 | 1938 passed | 146 failed | 23 failed as expected
+test cases: 364 | 272 passed | 86 failed | 6 failed as expected
+assertions: 2108 | 1939 passed | 146 failed | 23 failed as expected
diff --git a/tests/SelfTest/Baselines/junit.sw.approved.txt b/tests/SelfTest/Baselines/junit.sw.approved.txt
index 7c3e2f1f..811dab96 100644
--- a/tests/SelfTest/Baselines/junit.sw.approved.txt
+++ b/tests/SelfTest/Baselines/junit.sw.approved.txt
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<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>
<property name="filters" value="~[!nonportable]~[!benchmark]~[approvals] *"/>
<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 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="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="array&lt;int, N> -> toString" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="atomic if" time="{duration}" status="run"/>
diff --git a/tests/SelfTest/Baselines/sonarqube.sw.approved.txt b/tests/SelfTest/Baselines/sonarqube.sw.approved.txt
index 10d00b02..143ed10c 100644
--- a/tests/SelfTest/Baselines/sonarqube.sw.approved.txt
+++ b/tests/SelfTest/Baselines/sonarqube.sw.approved.txt
@@ -253,6 +253,7 @@
<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 (x7F)" duration="{duration}"/>
+ <testCase name="XmlWriter writes boolean attributes as true/false" duration="{duration}"/>
</file>
<file path="tests/<exe-name>/UsageTests/Approx.tests.cpp">
<testCase name="A comparison that uses literals instead of the normal constructor" duration="{duration}"/>
diff --git a/tests/SelfTest/Baselines/tap.sw.approved.txt b/tests/SelfTest/Baselines/tap.sw.approved.txt
index 1977fa8f..17ddd242 100644
--- a/tests/SelfTest/Baselines/tap.sw.approved.txt
+++ b/tests/SelfTest/Baselines/tap.sw.approved.txt
@@ -3541,6 +3541,8 @@ ok {test-number} - encode( stringWithQuotes, Catch::XmlEncode::ForAttributes ) =
ok {test-number} - encode( "[\x01]" ) == "[\\x01]" for: "[\x01]" == "[\x01]"
# XmlEncode
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
ok {test-number} - analysis.mean.point.count() == 23 for: 23.0 == 23
# analyse no analysis
@@ -4216,5 +4218,5 @@ ok {test-number} - q3 == 23. for: 23.0 == 23.0
ok {test-number} -
# xmlentitycheck
ok {test-number} -
-1..2107
+1..2108
diff --git a/tests/SelfTest/Baselines/teamcity.sw.approved.txt b/tests/SelfTest/Baselines/teamcity.sw.approved.txt
index e0794baf..1dee018b 100644
--- a/tests/SelfTest/Baselines/teamcity.sw.approved.txt
+++ b/tests/SelfTest/Baselines/teamcity.sw.approved.txt
@@ -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[testStarted name='XmlEncode']
##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[testFinished name='analyse no analysis' duration="{duration}"]
##teamcity[testStarted name='array<int, N> -> toString']
diff --git a/tests/SelfTest/Baselines/xml.sw.approved.txt b/tests/SelfTest/Baselines/xml.sw.approved.txt
index ebfca6dc..c8f413e5 100644
--- a/tests/SelfTest/Baselines/xml.sw.approved.txt
+++ b/tests/SelfTest/Baselines/xml.sw.approved.txt
@@ -16544,6 +16544,19 @@ There is no extra whitespace here
</Section>
<OverallResult success="true"/>
</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")") &amp;&amp; Contains(R"(attr2="false")")
+ </Original>
+ <Expanded>
+ "&lt;?xml version="1.0" encoding="UTF-8"?>
+&lt;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" >
<Expression success="true" type="CHECK" filename="tests/<exe-name>/IntrospectiveTests/InternalBenchmark.tests.cpp" >
<Original>
@@ -19802,9 +19815,9 @@ loose text artifact
</Section>
<OverallResult success="true"/>
</TestCase>
- <OverallResults successes="1938" failures="147" expectedFailures="23"/>
- <OverallResultsCases successes="271" failures="86" expectedFailures="6"/>
+ <OverallResults successes="1939" failures="147" expectedFailures="23"/>
+ <OverallResultsCases successes="272" failures="86" expectedFailures="6"/>
</Group>
- <OverallResults successes="1938" failures="146" expectedFailures="23"/>
- <OverallResultsCases successes="271" failures="86" expectedFailures="6"/>
+ <OverallResults successes="1939" failures="146" expectedFailures="23"/>
+ <OverallResultsCases successes="272" failures="86" expectedFailures="6"/>
</Catch>
diff --git a/tests/SelfTest/IntrospectiveTests/Xml.tests.cpp b/tests/SelfTest/IntrospectiveTests/Xml.tests.cpp
index 2d375a22..c98d66ef 100644
--- a/tests/SelfTest/IntrospectiveTests/Xml.tests.cpp
+++ b/tests/SelfTest/IntrospectiveTests/Xml.tests.cpp
@@ -2,6 +2,9 @@
#include <catch2/internal/catch_xmlwriter.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 ) {
Catch::ReusableStringStream oss;
@@ -112,3 +115,19 @@ TEST_CASE("XmlEncode: UTF-8", "[XML][UTF-8][approvals]") {
}
#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")") );
+}