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

summaryrefslogtreecommitdiffhomepage
path: root/tests/SelfTest/IntrospectiveTests
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/SelfTest/IntrospectiveTests
parent0e2895934cf778f3bd7e84b3df10dac81d4ef7e3 (diff)
downloadcatch3-5741de9ccdca3f41131c377394b4e3db0f11686c.tar.gz
Add explicit test for serialization of boolean attributes in XML
Diffstat (limited to 'tests/SelfTest/IntrospectiveTests')
-rw-r--r--tests/SelfTest/IntrospectiveTests/Xml.tests.cpp19
1 files changed, 19 insertions, 0 deletions
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")") );
+}