diff --git a/tests/test_compact.cpp b/tests/test_compact.cpp index 7c90d07424e26110d0262ca8ec8f4935855bc325..f9560c9250429e26553694b617535ca0b5eead3e 100644 --- a/tests/test_compact.cpp +++ b/tests/test_compact.cpp @@ -11,15 +11,19 @@ static void overflow_hash_table(xml_document& doc) CHECK(n.prepend_child(node_element)); } -TEST_XML(compact_out_of_memory_string, "<n/>") +TEST_XML_FLAGS(compact_out_of_memory_string, "<n a='v'/><?n v?>", parse_pi) { test_runner::_memory_fail_threshold = 1; overflow_hash_table(doc); - xml_node n = doc.child(STR("n")); + xml_attribute a = doc.child(STR("n")).attribute(STR("a")); + xml_node pi = doc.last_child(); - CHECK_ALLOC_FAIL(CHECK(!n.set_name(STR("name")))); + CHECK_ALLOC_FAIL(CHECK(!pi.set_name(STR("name")))); + CHECK_ALLOC_FAIL(CHECK(!pi.set_value(STR("value")))); + CHECK_ALLOC_FAIL(CHECK(!a.set_name(STR("name")))); + CHECK_ALLOC_FAIL(CHECK(!a.set_value(STR("value")))); } TEST_XML(compact_out_of_memory_attribute, "<n a='v'/>") diff --git a/tests/test_dom_traverse.cpp b/tests/test_dom_traverse.cpp index 773f0f004d70d83a8b9c7b536ff73ce82c720725..3d30a82ef4cc4adbef8864df0408fe5a6e5a4658 100644 --- a/tests/test_dom_traverse.cpp +++ b/tests/test_dom_traverse.cpp @@ -137,6 +137,10 @@ TEST_XML(dom_attr_as_integer_space, "<node attr1=' \t1234' attr2='\t 0x123' attr CHECK(node.attribute(STR("attr2")).as_int() == 291); CHECK(node.attribute(STR("attr3")).as_int() == 0); CHECK(node.attribute(STR("attr4")).as_int() == 0); + +#ifdef PUGIXML_HAS_LONG_LONG + CHECK(node.attribute(STR("attr1")).as_llong() == 1234); +#endif } TEST_XML(dom_attr_as_float, "<node attr1='0' attr2='1' attr3='0.12' attr4='-5.1' attr5='3e-4' attr6='3.14159265358979323846'/>") diff --git a/tests/test_parse.cpp b/tests/test_parse.cpp index fa9555def7ceac36c917705284343df5f53cb22b..882ba3aee00686519871203dc52129bb8a24fd15 100644 --- a/tests/test_parse.cpp +++ b/tests/test_parse.cpp @@ -746,6 +746,36 @@ TEST(parse_attribute_quot_inside) } } +TEST(parse_attribute_wnorm_coverage) +{ + xml_document doc; + CHECK(doc.load_string(STR("<n a1='v' a2=' ' a3='x y' a4='x y' a5='x y' />"), parse_wnorm_attribute)); + CHECK_NODE(doc, STR("<n a1=\"v\" a2=\"\" a3=\"x y\" a4=\"x y\" a5=\"x y\"/>")); + + CHECK(doc.load_string(STR("<n a1='v' a2=' ' a3='x y' a4='x y' a5='x y' />"), parse_wnorm_attribute | parse_escapes)); + CHECK_NODE(doc, STR("<n a1=\"v\" a2=\"\" a3=\"x y\" a4=\"x y\" a5=\"x y\"/>")); +} + +TEST(parse_attribute_wconv_coverage) +{ + xml_document doc; + CHECK(doc.load_string(STR("<n a1='v' a2='\r' a3='\r\n\n' a4='\n' />"), parse_wconv_attribute)); + CHECK_NODE(doc, STR("<n a1=\"v\" a2=\" \" a3=\" \" a4=\" \"/>")); + + CHECK(doc.load_string(STR("<n a1='v' a2='\r' a3='\r\n\n' a4='\n' />"), parse_wconv_attribute | parse_escapes)); + CHECK_NODE(doc, STR("<n a1=\"v\" a2=\" \" a3=\" \" a4=\" \"/>")); +} + +TEST(parse_attribute_eol_coverage) +{ + xml_document doc; + CHECK(doc.load_string(STR("<n a1='v' a2='\r' a3='\r\n\n' a4='\n' />"), parse_eol)); + CHECK_NODE(doc, STR("<n a1=\"v\" a2=\" \" a3=\" \" a4=\" \"/>")); + + CHECK(doc.load_string(STR("<n a1='v' a2='\r' a3='\r\n\n' a4='\n' />"), parse_eol | parse_escapes)); + CHECK_NODE(doc, STR("<n a1=\"v\" a2=\" \" a3=\" \" a4=\" \"/>")); +} + TEST(parse_tag_single) { xml_document doc; diff --git a/tests/test_write.cpp b/tests/test_write.cpp index d5f3dad66aaf942a9cc03e4915f4a7f25afa8cb2..5cd92a552e07bee8b545c8aace5d16e335ae2951 100644 --- a/tests/test_write.cpp +++ b/tests/test_write.cpp @@ -69,6 +69,12 @@ TEST_XML_FLAGS(write_cdata_escape, "<![CDATA[value]]>", parse_cdata | parse_frag doc.first_child().set_value(STR("1]]>2]]>3")); CHECK_NODE(doc, STR("<![CDATA[1]]]]><![CDATA[>2]]]]><![CDATA[>3]]>")); + + doc.first_child().set_value(STR("1]")); + CHECK_NODE(doc, STR("<![CDATA[1]]]>")); + + doc.first_child().set_value(STR("1]]")); + CHECK_NODE(doc, STR("<![CDATA[1]]]]>")); } TEST_XML(write_cdata_inner, "<node><![CDATA[value]]></node>")