diff options
| author | YDBot <[email protected]> | 2026-06-02 06:19:31 +0000 |
|---|---|---|
| committer | YDBot <[email protected]> | 2026-06-02 06:19:31 +0000 |
| commit | 82c90fad71dec6bce037df4e7f33d205ff4f66a6 (patch) | |
| tree | 62f72672bb6efa0ccdd854dc8e12640b7ea0dde7 /library/cpp/xml/document/xml-document_ut.cpp | |
| parent | d568eb8afcecb4517a87464ccbfdd69e5d19259c (diff) | |
| parent | 1cbfbcaf068c0c3ad3c4a1ad80e720fdb0f2890f (diff) | |
Merge pull request #42159 from ydb-platform/merge-rightlib-260602-0132
Diffstat (limited to 'library/cpp/xml/document/xml-document_ut.cpp')
| -rw-r--r-- | library/cpp/xml/document/xml-document_ut.cpp | 26 |
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"); + } } |
