summaryrefslogtreecommitdiffstats
path: root/library/cpp/xml/document/xml-document_ut.cpp
diff options
context:
space:
mode:
authorgbrun <[email protected]>2026-06-01 13:14:33 +0300
committergbrun <[email protected]>2026-06-01 13:53:34 +0300
commitecf443683811f2f5190606456b8480ece7c9b7e4 (patch)
tree7fd56800c53e233b286d0679dc9ccee8857ac9be /library/cpp/xml/document/xml-document_ut.cpp
parenta1c68c4a458ae7628abe488ca712a6b0dae2ff8e (diff)
[libxml] add parseOptions
Added the ability to explicitly specify parsing options. commit_hash:1bd7947cfc298f0c3edc895a77c64f70504b78d5
Diffstat (limited to 'library/cpp/xml/document/xml-document_ut.cpp')
-rw-r--r--library/cpp/xml/document/xml-document_ut.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/library/cpp/xml/document/xml-document_ut.cpp b/library/cpp/xml/document/xml-document_ut.cpp
index 0ec1fc60838..b4af2cdccf3 100644
--- a/library/cpp/xml/document/xml-document_ut.cpp
+++ b/library/cpp/xml/document/xml-document_ut.cpp
@@ -338,4 +338,30 @@ Y_UNIT_TEST_SUITE(TestXmlDocument) {
root.SetAttr("quux", "literal");
root.SetAttr("frob", 500);
}
+
+ Y_UNIT_TEST(Cdata) {
+ using namespace NXml;
+ const TString xml = "<?xml version=\"1.0\"?>\n"
+ "<example><![CDATA[Some & data]]> test</example>\n";
+
+ TDocument docDefault(xml, TDocument::String);
+ UNIT_ASSERT(docDefault.Root().FirstChild().IsText());
+
+ TDocument docWithCdata(xml, TDocument::String, XML_PARSE_NOCDATA);
+ UNIT_ASSERT(docWithCdata.Root().FirstChild().IsText());
+
+ TDocument docWithoutCdata(xml, TDocument::String, 0);
+ UNIT_ASSERT(!docWithoutCdata.Root().FirstChild().IsText());
+ }
+
+ Y_UNIT_TEST(InvalidXml) {
+ using namespace NXml;
+ const TString xml = "<?xml version=\"1.0\"?>\n"
+ "<root><item>value</root>\n";
+
+ UNIT_CHECK_GENERATED_EXCEPTION(TDocument(xml, TDocument::String), yexception);
+
+ TDocument doc(xml, TDocument::String, XML_PARSE_RECOVER);
+ UNIT_ASSERT_EQUAL(doc.Root().FirstChild().Value<TString>(), "value");
+ }
}