From d359402311ab89039316eb750d3d8ebca95d9b78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferenc=20G=C3=A9czi?= Date: Thu, 29 Sep 2022 00:00:00 +0000 Subject: [PATCH] Add xml_text::set test with size set to substring --- tests/test_dom_text.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/test_dom_text.cpp b/tests/test_dom_text.cpp index 6146f55..7d77c09 100644 --- a/tests/test_dom_text.cpp +++ b/tests/test_dom_text.cpp @@ -269,6 +269,26 @@ TEST_XML(dom_text_set_with_size, "") CHECK_NODE(node, STR("foobarfoobar")); } +TEST_XML(dom_text_set_partially_with_size, "") +{ + xml_node node = doc.child(STR("node")); + xml_text t = node.text(); + + t.set(STR("foo"), 0); + CHECK(node.first_child().type() == node_pcdata); + CHECK_NODE(node, STR("")); + + t.set(STR("boofoo"), 3); + CHECK(node.first_child().type() == node_pcdata); + CHECK(node.first_child() == node.last_child()); + CHECK_NODE(node, STR("boo")); + + t.set(STR("foobarfoobar"), 3); + CHECK(node.first_child().type() == node_pcdata); + CHECK(node.first_child() == node.last_child()); + CHECK_NODE(node, STR("foo")); +} + TEST_XML(dom_text_assign, "") { xml_node node = doc.child(STR("node"));