diff options
author | Arseny Kapoulkine <arseny.kapoulkine@gmail.com> | 2014-11-20 23:47:00 -0800 |
---|---|---|
committer | Arseny Kapoulkine <arseny.kapoulkine@gmail.com> | 2014-11-20 23:47:16 -0800 |
commit | db8df4a5665cfb24c1c18be438d10b2e310a234e (patch) | |
tree | 16d251ba91d88fd99343e9628348f912e0170f1a /tests | |
parent | cca23e636354dc73429a19e14e32cc9a5e632735 (diff) | |
parent | 125aa55061ccde4ae7351a9a6c7270a15c9e0204 (diff) |
Merge branch 'master' into compact
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test.hpp | 2 | ||||
-rw-r--r-- | tests/test_document.cpp | 27 | ||||
-rw-r--r-- | tests/test_dom_modify.cpp | 16 | ||||
-rw-r--r-- | tests/test_memory.cpp | 2 | ||||
-rw-r--r-- | tests/test_parse.cpp | 328 | ||||
-rw-r--r-- | tests/test_parse_doctype.cpp | 20 | ||||
-rw-r--r-- | tests/test_version.cpp | 2 | ||||
-rw-r--r-- | tests/test_write.cpp | 2 | ||||
-rw-r--r-- | tests/test_xpath.cpp | 8 | ||||
-rw-r--r-- | tests/test_xpath_operators.cpp | 4 | ||||
-rw-r--r-- | tests/test_xpath_paths.cpp | 6 |
11 files changed, 222 insertions, 195 deletions
diff --git a/tests/test.hpp b/tests/test.hpp index 509b0cd..4222638 100644 --- a/tests/test.hpp +++ b/tests/test.hpp @@ -95,7 +95,7 @@ struct dummy_fixture {}; \ test_fixture_##name() \ { \ - CHECK(doc.load(PUGIXML_TEXT(xml), flags)); \ + CHECK(doc.load_string(PUGIXML_TEXT(xml), flags)); \ } \ \ private: \ diff --git a/tests/test_document.cpp b/tests/test_document.cpp index 2774a07..4228602 100644 --- a/tests/test_document.cpp +++ b/tests/test_document.cpp @@ -158,7 +158,7 @@ TEST(document_load_stream_exceptions) TEST(document_load_stream_error_previous) { pugi::xml_document doc; - CHECK(doc.load(STR("<node/>"))); + CHECK(doc.load_string(STR("<node/>"))); CHECK(doc.first_child()); std::ifstream fs1("filedoesnotexist"); @@ -169,7 +169,7 @@ TEST(document_load_stream_error_previous) TEST(document_load_stream_wide_error_previous) { pugi::xml_document doc; - CHECK(doc.load(STR("<node/>"))); + CHECK(doc.load_string(STR("<node/>"))); CHECK(doc.first_child()); std::basic_ifstream<wchar_t> fs1("filedoesnotexist"); @@ -261,7 +261,7 @@ TEST(document_load_string) { pugi::xml_document doc; - CHECK(doc.load(STR("<node/>"))); + CHECK(doc.load_string(STR("<node/>"))); CHECK_NODE(doc, STR("<node />")); } @@ -301,10 +301,6 @@ TEST(document_load_file_error) CHECK(doc.load_file("filedoesnotexist").status == status_file_not_found); -#ifndef _WIN32 - CHECK(doc.load_file("/dev/tty").status == status_io_error); -#endif - test_runner::_memory_fail_threshold = 1; CHECK(doc.load_file("tests/data/small.xml").status == status_out_of_memory); } @@ -312,7 +308,7 @@ TEST(document_load_file_error) TEST(document_load_file_error_previous) { pugi::xml_document doc; - CHECK(doc.load(STR("<node/>"))); + CHECK(doc.load_string(STR("<node/>"))); CHECK(doc.first_child()); CHECK(doc.load_file("filedoesnotexist").status == status_file_not_found); @@ -594,7 +590,7 @@ TEST(document_parse_result_description) TEST(document_load_fail) { xml_document doc; - CHECK(!doc.load(STR("<foo><bar/>"))); + CHECK(!doc.load_string(STR("<foo><bar/>"))); CHECK(doc.child(STR("foo")).child(STR("bar"))); } @@ -1083,7 +1079,7 @@ TEST(document_load_exceptions) try { pugi::xml_document doc; - if (!doc.load(STR("<node attribute='value"))) throw std::bad_alloc(); + if (!doc.load_string(STR("<node attribute='value"))) throw std::bad_alloc(); CHECK_FORCE_FAIL("Expected parsing failure"); } @@ -1118,7 +1114,7 @@ TEST_XML(document_reset, "<node><child/></node>") CHECK(!doc.first_child()); CHECK_NODE(doc, STR("")); - CHECK(doc.load(STR("<node/>"))); + CHECK(doc.load_string(STR("<node/>"))); CHECK(doc.first_child()); CHECK_NODE(doc, STR("<node />")); @@ -1272,7 +1268,7 @@ TEST(document_alignment) { xml_document* doc = new (buf + offset) xml_document; - CHECK(doc->load(STR("<node />"))); + CHECK(doc->load_string(STR("<node />"))); CHECK_NODE(*doc, STR("<node />")); doc->~xml_document(); @@ -1312,3 +1308,10 @@ TEST(document_convert_out_of_memory) delete[] files[j].data; } } + +TEST(document_deprecated_load) +{ + xml_document doc; + CHECK(doc.load(STR("<node/>"))); + CHECK_NODE(doc, STR("<node />")); +} diff --git a/tests/test_dom_modify.cpp b/tests/test_dom_modify.cpp index 6417033..9c9109b 100644 --- a/tests/test_dom_modify.cpp +++ b/tests/test_dom_modify.cpp @@ -1289,7 +1289,7 @@ TEST(dom_node_copy_stackless) data += STR("</a>"); xml_document doc; - CHECK(doc.load(data.c_str())); + CHECK(doc.load_string(data.c_str())); xml_document copy; CHECK(copy.append_copy(doc.first_child())); @@ -1329,7 +1329,7 @@ TEST(dom_node_copy_copyless) TEST(dom_node_copy_copyless_mix) { xml_document doc; - CHECK(doc.load(STR("<node>pcdata<?name value?><child attr1=\"\" attr2=\"value2\" /></node>"), parse_full)); + CHECK(doc.load_string(STR("<node>pcdata<?name value?><child attr1=\"\" attr2=\"value2\" /></node>"), parse_full)); xml_node child = doc.child(STR("node")).child(STR("child")); @@ -1431,3 +1431,15 @@ TEST_XML(dom_node_set_deallocate, "<node attr='value'>text</node>") CHECK_NODE(doc, STR("<:anonymous :anonymous=\"\"></:anonymous>")); } + +TEST(dom_node_copy_declaration_empty_name) +{ + xml_document doc1; + xml_node decl1 = doc1.append_child(node_declaration); + decl1.set_name(STR("")); + + xml_document doc2; + xml_node decl2 = doc2.append_copy(decl1); + + CHECK_STRING(decl2.name(), STR("")); +} diff --git a/tests/test_memory.cpp b/tests/test_memory.cpp index ae5eb8c..5edfd65 100644 --- a/tests/test_memory.cpp +++ b/tests/test_memory.cpp @@ -46,7 +46,7 @@ TEST(memory_custom_memory_management) CHECK(page_allocs == 0 && page_deallocs == 0); - CHECK(doc.load(STR("<node />"))); + CHECK(doc.load_string(STR("<node />"))); CHECK(page_allocs == 1 && page_deallocs == 0); diff --git a/tests/test_parse.cpp b/tests/test_parse.cpp index c45b783..321b84c 100644 --- a/tests/test_parse.cpp +++ b/tests/test_parse.cpp @@ -12,10 +12,10 @@ TEST(parse_pi_skip) { unsigned int flags = flag_sets[i]; - CHECK(doc.load(STR("<?pi?><?pi value?>"), flags)); + CHECK(doc.load_string(STR("<?pi?><?pi value?>"), flags)); CHECK(!doc.first_child()); - CHECK(doc.load(STR("<?pi <tag/> value?>"), flags)); + CHECK(doc.load_string(STR("<?pi <tag/> value?>"), flags)); CHECK(!doc.first_child()); } } @@ -23,7 +23,7 @@ TEST(parse_pi_skip) TEST(parse_pi_parse) { xml_document doc; - CHECK(doc.load(STR("<?pi1?><?pi2 value?>"), parse_fragment | parse_pi)); + CHECK(doc.load_string(STR("<?pi1?><?pi2 value?>"), parse_fragment | parse_pi)); xml_node pi1 = doc.first_child(); xml_node pi2 = doc.last_child(); @@ -40,7 +40,7 @@ TEST(parse_pi_parse) TEST(parse_pi_parse_spaces) { xml_document doc; - CHECK(doc.load(STR("<?target \r\n\t value ?>"), parse_fragment | parse_pi)); + CHECK(doc.load_string(STR("<?target \r\n\t value ?>"), parse_fragment | parse_pi)); xml_node pi = doc.first_child(); @@ -59,46 +59,46 @@ TEST(parse_pi_error) { unsigned int flags = flag_sets[i]; - CHECK(doc.load(STR("<?"), flags).status == status_bad_pi); - CHECK(doc.load(STR("<??"), flags).status == status_bad_pi); - CHECK(doc.load(STR("<?>"), flags).status == status_bad_pi); - CHECK(doc.load(STR("<?#?>"), flags).status == status_bad_pi); - CHECK(doc.load(STR("<?name"), flags).status == status_bad_pi); - CHECK(doc.load(STR("<?name>"), flags).status == status_bad_pi); - CHECK(doc.load(STR("<?name ?"), flags).status == status_bad_pi); - CHECK(doc.load(STR("<?name?"), flags).status == status_bad_pi); - CHECK(doc.load(STR("<?name? "), flags).status == status_bad_pi); - CHECK(doc.load(STR("<?name? "), flags).status == status_bad_pi); - CHECK(doc.load(STR("<?name "), flags).status == status_bad_pi); - CHECK(doc.load(STR("<?name "), flags).status == status_bad_pi); - CHECK(doc.load(STR("<?name "), flags).status == status_bad_pi); - CHECK(doc.load(STR("<?name value"), flags).status == status_bad_pi); - CHECK(doc.load(STR("<?name value "), flags).status == status_bad_pi); - CHECK(doc.load(STR("<?name value "), flags).status == status_bad_pi); - CHECK(doc.load(STR("<?name value ?"), flags).status == status_bad_pi); - CHECK(doc.load(STR("<?name value ? "), flags).status == status_bad_pi); - CHECK(doc.load(STR("<?name value ? >"), flags).status == status_bad_pi); - CHECK(doc.load(STR("<?name value ? > "), flags).status == status_bad_pi); - CHECK(doc.load(STR("<?name&"), flags).status == status_bad_pi); - CHECK(doc.load(STR("<?name&?"), flags).status == status_bad_pi); + CHECK(doc.load_string(STR("<?"), flags).status == status_bad_pi); + CHECK(doc.load_string(STR("<??"), flags).status == status_bad_pi); + CHECK(doc.load_string(STR("<?>"), flags).status == status_bad_pi); + CHECK(doc.load_string(STR("<?#?>"), flags).status == status_bad_pi); + CHECK(doc.load_string(STR("<?name"), flags).status == status_bad_pi); + CHECK(doc.load_string(STR("<?name>"), flags).status == status_bad_pi); + CHECK(doc.load_string(STR("<?name ?"), flags).status == status_bad_pi); + CHECK(doc.load_string(STR("<?name?"), flags).status == status_bad_pi); + CHECK(doc.load_string(STR("<?name? "), flags).status == status_bad_pi); + CHECK(doc.load_string(STR("<?name? "), flags).status == status_bad_pi); + CHECK(doc.load_string(STR("<?name "), flags).status == status_bad_pi); + CHECK(doc.load_string(STR("<?name "), flags).status == status_bad_pi); + CHECK(doc.load_string(STR("<?name "), flags).status == status_bad_pi); + CHECK(doc.load_string(STR("<?name value"), flags).status == status_bad_pi); + CHECK(doc.load_string(STR("<?name value "), flags).status == status_bad_pi); + CHECK(doc.load_string(STR("<?name value "), flags).status == status_bad_pi); + CHECK(doc.load_string(STR("<?name value ?"), flags).status == status_bad_pi); + CHECK(doc.load_string(STR("<?name value ? "), flags).status == status_bad_pi); + CHECK(doc.load_string(STR("<?name value ? >"), flags).status == status_bad_pi); + CHECK(doc.load_string(STR("<?name value ? > "), flags).status == status_bad_pi); + CHECK(doc.load_string(STR("<?name&"), flags).status == status_bad_pi); + CHECK(doc.load_string(STR("<?name&?"), flags).status == status_bad_pi); } - CHECK(doc.load(STR("<?xx#?>"), parse_fragment | parse_pi).status == status_bad_pi); - CHECK(doc.load(STR("<?name&?>"), parse_fragment | parse_pi).status == status_bad_pi); - CHECK(doc.load(STR("<?name& x?>"), parse_fragment | parse_pi).status == status_bad_pi); + CHECK(doc.load_string(STR("<?xx#?>"), parse_fragment | parse_pi).status == status_bad_pi); + CHECK(doc.load_string(STR("<?name&?>"), parse_fragment | parse_pi).status == status_bad_pi); + CHECK(doc.load_string(STR("<?name& x?>"), parse_fragment | parse_pi).status == status_bad_pi); } TEST(parse_comments_skip) { xml_document doc; - CHECK(doc.load(STR("<!----><!--value-->"), parse_fragment)); + CHECK(doc.load_string(STR("<!----><!--value-->"), parse_fragment)); CHECK(!doc.first_child()); } TEST(parse_comments_parse) { xml_document doc; - CHECK(doc.load(STR("<!----><!--value-->"), parse_fragment | parse_comments)); + CHECK(doc.load_string(STR("<!----><!--value-->"), parse_fragment | parse_comments)); xml_node c1 = doc.first_child(); xml_node c2 = doc.last_child(); @@ -115,7 +115,7 @@ TEST(parse_comments_parse) TEST(parse_comments_parse_no_eol) { xml_document doc; - CHECK(doc.load(STR("<!--\r\rval1\rval2\r\nval3\nval4\r\r-->"), parse_fragment | parse_comments)); + CHECK(doc.load_string(STR("<!--\r\rval1\rval2\r\nval3\nval4\r\r-->"), parse_fragment | parse_comments)); xml_node c = doc.first_child(); CHECK(c.type() == node_comment); @@ -125,7 +125,7 @@ TEST(parse_comments_parse_no_eol) TEST(parse_comments_parse_eol) { xml_document doc; - CHECK(doc.load(STR("<!--\r\rval1\rval2\r\nval3\nval4\r\r-->"), parse_fragment | parse_comments | parse_eol)); + CHECK(doc.load_string(STR("<!--\r\rval1\rval2\r\nval3\nval4\r\r-->"), parse_fragment | parse_comments | parse_eol)); xml_node c = doc.first_child(); CHECK(c.type() == node_comment); @@ -142,33 +142,33 @@ TEST(parse_comments_error) { unsigned int flags = flag_sets[i]; - CHECK(doc.load(STR("<!-"), flags).status == status_bad_comment); - CHECK(doc.load(STR("<!--"), flags).status == status_bad_comment); - CHECK(doc.load(STR("<!--v"), flags).status == status_bad_comment); - CHECK(doc.load(STR("<!-->"), flags).status == status_bad_comment); - CHECK(doc.load(STR("<!--->"), flags).status == status_bad_comment); - CHECK(doc.load(STR("<!-- <!-- --><!- -->"), flags).status == status_bad_comment); + CHECK(doc.load_string(STR("<!-"), flags).status == status_bad_comment); + CHECK(doc.load_string(STR("<!--"), flags).status == status_bad_comment); + CHECK(doc.load_string(STR("<!--v"), flags).status == status_bad_comment); + CHECK(doc.load_string(STR("<!-->"), flags).status == status_bad_comment); + CHECK(doc.load_string(STR("<!--->"), flags).status == status_bad_comment); + CHECK(doc.load_string(STR("<!-- <!-- --><!- -->"), flags).status == status_bad_comment); } } TEST(parse_cdata_skip) { xml_document doc; - CHECK(doc.load(STR("<![CDATA[]]><![CDATA[value]]>"), parse_fragment)); + CHECK(doc.load_string(STR("<![CDATA[]]><![CDATA[value]]>"), parse_fragment)); CHECK(!doc.first_child()); } TEST(parse_cdata_skip_contents) { xml_document doc; - CHECK(doc.load(STR("<node><![CDATA[]]>hello<![CDATA[value]]>, world!</node>"), parse_fragment)); + CHECK(doc.load_string(STR("<node><![CDATA[]]>hello<![CDATA[value]]>, world!</node>"), parse_fragment)); CHECK_NODE(doc, STR("<node>hello, world!</node>")); } TEST(parse_cdata_parse) { xml_document doc; - CHECK(doc.load(STR("<![CDATA[]]><![CDATA[value]]>"), parse_fragment | parse_cdata)); + CHECK(doc.load_string(STR("<![CDATA[]]><![CDATA[value]]>"), parse_fragment | parse_cdata)); xml_node c1 = doc.first_child(); xml_node c2 = doc.last_child(); @@ -185,7 +185,7 @@ TEST(parse_cdata_parse) TEST(parse_cdata_parse_no_eol) { xml_document doc; - CHECK(doc.load(STR("<![CDATA[\r\rval1\rval2\r\nval3\nval4\r\r]]>"), parse_fragment | parse_cdata)); + CHECK(doc.load_string(STR("<![CDATA[\r\rval1\rval2\r\nval3\nval4\r\r]]>"), parse_fragment | parse_cdata)); xml_node c = doc.first_child(); CHECK(c.type() == node_cdata); @@ -195,7 +195,7 @@ TEST(parse_cdata_parse_no_eol) TEST(parse_cdata_parse_eol) { xml_document doc; - CHECK(doc.load(STR("<![CDATA[\r\rval1\rval2\r\nval3\nval4\r\r]]>"), parse_fragment | parse_cdata | parse_eol)); + CHECK(doc.load_string(STR("<![CDATA[\r\rval1\rval2\r\nval3\nval4\r\r]]>"), parse_fragment | parse_cdata | parse_eol)); xml_node c = doc.first_child(); CHECK(c.type() == node_cdata); @@ -212,29 +212,29 @@ TEST(parse_cdata_error) { unsigned int flags = flag_sets[i]; - CHECK(doc.load(STR("<!["), flags).status == status_bad_cdata); - CHECK(doc.load(STR("<![C"), flags).status == status_bad_cdata); - CHECK(doc.load(STR("<![CD"), flags).status == status_bad_cdata); - CHECK(doc.load(STR("<![CDA"), flags).status == status_bad_cdata); - CHECK(doc.load(STR("<![CDAT"), flags).status == status_bad_cdata); - CHECK(doc.load(STR("<![CDATA"), flags).status == status_bad_cdata); - CHECK(doc.load(STR("<![CDATA["), flags).status == status_bad_cdata); - CHECK(doc.load(STR("<![CDATA[]"), flags).status == status_bad_cdata); - CHECK(doc.load(STR("<![CDATA[data"), flags).status == status_bad_cdata); - CHECK(doc.load(STR("<![CDATA[data]"), flags).status == status_bad_cdata); - CHECK(doc.load(STR("<![CDATA[data]]"), flags).status == status_bad_cdata); - CHECK(doc.load(STR("<![CDATA[>"), flags).status == status_bad_cdata); - CHECK(doc.load(STR("<![CDATA[ <![CDATA[]]><![CDATA ]]>"), flags).status == status_bad_cdata); + CHECK(doc.load_string(STR("<!["), flags).status == status_bad_cdata); + CHECK(doc.load_string(STR("<![C"), flags).status == status_bad_cdata); + CHECK(doc.load_string(STR("<![CD"), flags).status == status_bad_cdata); + CHECK(doc.load_string(STR("<![CDA"), flags).status == status_bad_cdata); + CHECK(doc.load_string(STR("<![CDAT"), flags).status == status_bad_cdata); + CHECK(doc.load_string(STR("<![CDATA"), flags).status == status_bad_cdata); + CHECK(doc.load_string(STR("<![CDATA["), flags).status == status_bad_cdata); + CHECK(doc.load_string(STR("<![CDATA[]"), flags).status == status_bad_cdata); + CHECK(doc.load_string(STR("<![CDATA[data"), flags).status == status_bad_cdata); + CHECK(doc.load_string(STR("<![CDATA[data]"), flags).status == status_bad_cdata); + CHECK(doc.load_string(STR("<![CDATA[data]]"), flags).status == status_bad_cdata); + CHECK(doc.load_string(STR("<![CDATA[>"), flags).status == status_bad_cdata); + CHECK(doc.load_string(STR("<![CDATA[ <![CDATA[]]><![CDATA ]]>"), flags).status == status_bad_cdata); } } TEST(parse_ws_pcdata_skip) { xml_document doc; - CHECK(doc.load(STR(" "), parse_fragment)); + CHECK(doc.load_string(STR(" "), parse_fragment)); CHECK(!doc.first_child()); - CHECK(doc.load(STR("<root> <node> </node> </root>"), parse_minimal)); + CHECK(doc.load_string(STR("<root> <node> </node> </root>"), parse_minimal)); xml_node root = doc.child(STR("root")); @@ -245,7 +245,7 @@ TEST(parse_ws_pcdata_skip) TEST(parse_ws_pcdata_parse) { xml_document doc; - CHECK(doc.load(STR("<root> <node> </node> </root>"), parse_minimal | parse_ws_pcdata)); + CHECK(doc.load_string(STR("<root> <node> </node> </root>"), parse_minimal | parse_ws_pcdata)); xml_node root = doc.child(STR("root")); @@ -334,7 +334,7 @@ TEST(parse_ws_pcdata_permutations) unsigned int flags[] = {parse_default, parse_default | parse_ws_pcdata, parse_default | parse_ws_pcdata_single}; xml_document doc; - CHECK((td.nodes > 0) == doc.load(td.source, flags[flag])); + CHECK((td.nodes > 0) == doc.load_string(td.source, flags[flag])); CHECK_NODE(doc, td.result); int nodes = get_tree_node_count(doc); @@ -385,7 +385,7 @@ TEST(parse_ws_pcdata_fragment_permutations) unsigned int flags[] = {parse_default, parse_default | parse_ws_pcdata, parse_default | parse_ws_pcdata_single}; xml_document doc; - CHECK((td.nodes > 0) == doc.load(td.source, flags[flag] | parse_fragment)); + CHECK((td.nodes > 0) == doc.load_string(td.source, flags[flag] | parse_fragment)); CHECK_NODE(doc, td.result); int nodes = get_tree_node_count(doc); @@ -398,7 +398,7 @@ TEST(parse_ws_pcdata_fragment_permutations) TEST(parse_pcdata_no_eol) { xml_document doc; - CHECK(doc.load(STR("<root>\r\rval1\rval2\r\nval3\nval4\r\r</root>"), parse_minimal)); + CHECK(doc.load_string(STR("<root>\r\rval1\rval2\r\nval3\nval4\r\r</root>"), parse_minimal)); CHECK_STRING(doc.child_value(STR("root")), STR("\r\rval1\rval2\r\nval3\nval4\r\r")); } @@ -406,7 +406,7 @@ TEST(parse_pcdata_no_eol) TEST(parse_pcdata_eol) { xml_document doc; - CHECK(doc.load(STR("<root>\r\rval1\rval2\r\nval3\nval4\r\r</root>"), parse_minimal | parse_eol)); + CHECK(doc.load_string(STR("<root>\r\rval1\rval2\r\nval3\nval4\r\r</root>"), parse_minimal | parse_eol)); CHECK_STRING(doc.child_value(STR("root")), STR("\n\nval1\nval2\nval3\nval4\n\n")); } @@ -414,7 +414,7 @@ TEST(parse_pcdata_eol) TEST(parse_pcdata_skip_ext) { xml_document doc; - CHECK(doc.load(STR("pre<root/>post"), parse_minimal)); + CHECK(doc.load_string(STR("pre<root/>post"), parse_minimal)); CHECK(doc.first_child() == doc.last_child()); CHECK(doc.first_child().type() == node_element); } @@ -422,7 +422,7 @@ TEST(parse_pcdata_skip_ext) TEST(parse_pcdata_error) { xml_document doc; - CHECK(doc.load(STR("<root>pcdata"), parse_minimal).status == status_end_element_mismatch); + CHECK(doc.load_string(STR("<root>pcdata"), parse_minimal).status == status_end_element_mismatch); } TEST(parse_pcdata_trim) @@ -460,7 +460,7 @@ TEST(parse_pcdata_trim) const test_data_t& td = test_data[i]; xml_document doc; - CHECK(doc.load(td.source, td.flags | parse_trim_pcdata)); + CHECK(doc.load_string(td.source, td.flags | parse_trim_pcdata)); const pugi::char_t* value = doc.child(STR("node")) ? doc.child_value(STR("node")) : doc.text().get(); CHECK_STRING(value, td.result); @@ -474,7 +474,7 @@ TEST(parse_pcdata_trim_empty) for (size_t i = 0; i < sizeof(flags) / sizeof(flags[0]); ++i) { xml_document doc; - CHECK(doc.load(STR("<node> </node>"), flags[i] | parse_trim_pcdata)); + CHECK(doc.load_string(STR("<node> </node>"), flags[i] | parse_trim_pcdata)); xml_node node = doc.child(STR("node")); CHECK(node); @@ -485,14 +485,14 @@ TEST(parse_pcdata_trim_empty) TEST(parse_escapes_skip) { xml_document doc; - CHECK(doc.load(STR("<node id='<>&'"'><>&'"</node>"), parse_minimal)); + CHECK(doc.load_string(STR("<node id='<>&'"'><>&'"</node>"), parse_minimal)); CHECK_STRING(doc.child(STR("node")).attribute(STR("id")).value(), STR("<>&'"")); } TEST(parse_escapes_parse) { xml_document doc; - CHECK(doc.load(STR("<node id='<>&'"'><>&'"</node>"), parse_minimal | parse_escapes)); + CHECK(doc.load_string(STR("<node id='<>&'"'><>&'"</node>"), parse_minimal | parse_escapes)); CHECK_STRING(doc.child_value(STR("node")), STR("<>&'\"")); CHECK_STRING(doc.child(STR("node")).attribute(STR("id")).value(), STR("<>&'\"")); } @@ -500,28 +500,28 @@ TEST(parse_escapes_parse) TEST(parse_escapes_code) { xml_document doc; - CHECK(doc.load(STR("<node>  </node>"), parse_minimal | parse_escapes)); + CHECK(doc.load_string(STR("<node>  </node>"), parse_minimal | parse_escapes)); CHECK_STRING(doc.child_value(STR("node")), STR("\01 ")); } TEST(parse_escapes_code_exhaustive_dec) { xml_document doc; - CHECK(doc.load(STR("<node>&#/;	&#:;&#a;&#A;
</node>"), parse_minimal | parse_escapes)); + CHECK(doc.load_string(STR("<node>&#/;	&#:;&#a;&#A;
</node>"), parse_minimal | parse_escapes)); CHECK_STRING(doc.child_value(STR("node")), STR("&#/;\x1\x2\x3\x4\x5\x6\x7\x8\x9&#:;&#a;&#A;
")); } TEST(parse_escapes_code_exhaustive_hex) { xml_document doc; - CHECK(doc.load(STR("<node>&#x/;	&#x:;&#x@;

&#xG;&#x`;

&#xg;</node>"), parse_minimal | parse_escapes)); + CHECK(doc.load_string(STR("<node>&#x/;	&#x:;&#x@;

&#xG;&#x`;

&#xg;</node>"), parse_minimal | parse_escapes)); CHECK_STRING(doc.child_value(STR("node")), STR("&#x/;\x1\x2\x3\x4\x5\x6\x7\x8\x9&#x:;&#x@;\xa\xb\xc\xd\xe\xf&#xG;&#x`;\xa\xb\xc\xd\xe\xf&#xg;")); } TEST(parse_escapes_code_restore) { xml_document doc; - CHECK(doc.load(STR("<node>  - - </node>"), parse_minimal | parse_escapes)); + CHECK(doc.load_string(STR("<node>  - - </node>"), parse_minimal | parse_escapes)); CHECK_STRING(doc.child_value(STR("node")), STR("  - - ")); } @@ -529,26 +529,26 @@ TEST(parse_escapes_char_restore) { xml_document doc; - CHECK(doc.load(STR("<node>&q &qu &quo " </node>"), parse_minimal | parse_escapes)); + CHECK(doc.load_string(STR("<node>&q &qu &quo " </node>"), parse_minimal | parse_escapes)); CHECK_STRING(doc.child_value(STR("node")), STR("&q &qu &quo " ")); - CHECK(doc.load(STR("<node>&a &ap &apo &apos </node>"), parse_minimal | parse_escapes)); + CHECK(doc.load_string(STR("<node>&a &ap &apo &apos </node>"), parse_minimal | parse_escapes)); CHECK_STRING(doc.child_value(STR("node")), STR("&a &ap &apo &apos ")); - CHECK(doc.load(STR("<node>&a &am & </node>"), parse_minimal | parse_escapes)); + CHECK(doc.load_string(STR("<node>&a &am & </node>"), parse_minimal | parse_escapes)); CHECK_STRING(doc.child_value(STR("node")), STR("&a &am & ")); - CHECK(doc.load(STR("<node>&l < </node>"), parse_minimal | parse_escapes)); + CHECK(doc.load_string(STR("<node>&l < </node>"), parse_minimal | parse_escapes)); CHECK_STRING(doc.child_value(STR("node")), STR("&l < ")); - CHECK(doc.load(STR("<node>&g > </node>"), parse_minimal | parse_escapes)); + CHECK(doc.load_string(STR("<node>&g > </node>"), parse_minimal | parse_escapes)); CHECK_STRING(doc.child_value(STR("node")), STR("&g > ")); } TEST(parse_escapes_unicode) { xml_document doc; - CHECK(doc.load(STR("<node>γγ𤭢</node>"), parse_minimal | parse_escapes)); + CHECK(doc.load_string(STR("<node>γγ𤭢</node>"), parse_minimal | parse_escapes)); #ifdef PUGIXML_WCHAR_MODE const pugi::char_t* v = doc.child_value(STR("node")); @@ -564,23 +564,23 @@ TEST(parse_escapes_unicode) TEST(parse_escapes_error) { xml_document doc; - CHECK(doc.load(STR("<node>g;&#ab;"</node>"), parse_minimal | parse_escapes)); + CHECK(doc.load_string(STR("<node>g;&#ab;"</node>"), parse_minimal | parse_escapes)); CHECK_STRING(doc.child_value(STR("node")), STR("g;&#ab;"")); - CHECK(!doc.load(STR("<node id='"))); - CHECK(!doc.load(STR("<node id='&g"))); - CHECK(!doc.load(STR("<node id='>"))); - CHECK(!doc.load(STR("<node id='&l"))); - CHECK(!doc.load(STR("<node id='<"))); - CHECK(!doc.load(STR("<node id='&a"))); - CHECK(!doc.load(STR("<node id='&"))); - CHECK(!doc.load(STR("<node id='&apos"))); + CHECK(!doc.load_string(STR("<node id='"))); + CHECK(!doc.load_string(STR("<node id='&g"))); + CHECK(!doc.load_string(STR("<node id='>"))); + CHECK(!doc.load_string(STR("<node id='&l"))); + CHECK(!doc.load_string(STR("<node id='<"))); + CHECK(!doc.load_string(STR("<node id='&a"))); + CHECK(!doc.load_string(STR("<node id='&"))); + CHECK(!doc.load_string(STR("<node id='&apos"))); } TEST(parse_escapes_code_invalid) { xml_document doc; - CHECK(doc.load(STR("<node>&#;&#x;&;&#x-;&#-;</node>"), parse_minimal | parse_escapes)); + CHECK(doc.load_string(STR("<node>&#;&#x;&;&#x-;&#-;</node>"), parse_minimal | parse_escapes)); CHECK_STRING(doc.child_value(STR("node")), STR("&#;&#x;&;&#x-;&#-;")); } @@ -598,7 +598,7 @@ TEST(parse_escapes_attribute) flags |= (eol ? parse_eol : 0); flags |= (wconv ? parse_wconv_attribute : 0); - CHECK(doc.load(STR("<node id='"'/>"), flags)); + CHECK(doc.load_string(STR("<node id='"'/>"), flags)); CHECK_STRING(doc.child(STR("node")).attribute(STR("id")).value(), STR("\"")); } } @@ -606,7 +606,7 @@ TEST(parse_escapes_attribute) TEST(parse_attribute_spaces) { xml_document doc; - CHECK(doc.load(STR("<node id1='v1' id2 ='v2' id3= 'v3' id4 = 'v4' id5 \n\r\t = \r\t\n 'v5' />"), parse_minimal)); + CHECK(doc.load_string(STR("<node id1='v1' id2 ='v2' id3= 'v3' id4 = 'v4' id5 \n\r\t = \r\t\n 'v5' />"), parse_minimal)); CHECK_STRING(doc.child(STR("node")).attribute(STR("id1")).value(), STR("v1")); CHECK_STRING(doc.child(STR("node")).attribute(STR("id2")).value(), STR("v2")); CHECK_STRING(doc.child(STR("node")).attribute(STR("id3")).value(), STR("v3")); @@ -617,7 +617,7 @@ TEST(parse_attribute_spaces) TEST(parse_attribute_quot) { xml_document doc; - CHECK(doc.load(STR("<node id1='v1' id2=\"v2\"/>"), parse_minimal)); + CHECK(doc.load_string(STR("<node id1='v1' id2=\"v2\"/>"), parse_minimal)); CHECK_STRING(doc.child(STR("node")).attribute(STR("id1")).value(), STR("v1")); CHECK_STRING(doc.child(STR("node")).attribute(STR("id2")).value(), STR("v2")); } @@ -625,28 +625,28 @@ TEST(parse_attribute_quot) TEST(parse_attribute_no_eol_no_wconv) { xml_document doc; - CHECK(doc.load(STR("<node id=' \t\r\rval1 \rval2\r\nval3\nval4\r\r'/>"), parse_minimal)); + CHECK(doc.load_string(STR("<node id=' \t\r\rval1 \rval2\r\nval3\nval4\r\r'/>"), parse_minimal)); CHECK_STRING(doc.child(STR("node")).attribute(STR("id")).value(), STR(" \t\r\rval1 \rval2\r\nval3\nval4\r\r")); } TEST(parse_attribute_eol_no_wconv) { xml_document doc; - CHECK(doc.load(STR("<node id=' \t\r\rval1 \rval2\r\nval3\nval4\r\r'/>"), parse_minimal | parse_eol)); + CHECK(doc.load_string(STR("<node id=' \t\r\rval1 \rval2\r\nval3\nval4\r\r'/>"), parse_minimal | parse_eol)); CHECK_STRING(doc.child(STR("node")).attribute(STR("id")).value(), STR(" \t\n\nval1 \nval2\nval3\nval4\n\n")); } TEST(parse_attribute_no_eol_wconv) { xml_document doc; - CHECK(doc.load(STR("<node id=' \t\r\rval1 \rval2\r\nval3\nval4\r\r'/>"), parse_minimal | parse_wconv_attribute)); + CHECK(doc.load_string(STR("<node id=' \t\r\rval1 \rval2\r\nval3\nval4\r\r'/>"), parse_minimal | parse_wconv_attribute)); CHECK_STRING(doc.child(STR("node")).attribute(STR("id")).value(), STR(" val1 val2 val3 val4 ")); } TEST(parse_attribute_eol_wconv) { xml_document doc; - CHECK(doc.load(STR("<node id=' \t\r\rval1 \rval2\r\nval3\nval4\r\r'/>"), parse_minimal | parse_eol | parse_wconv_attribute)); + CHECK(doc.load_string(STR("<node id=' \t\r\rval1 \rval2\r\nval3\nval4\r\r'/>"), parse_minimal | parse_eol | parse_wconv_attribute)); CHECK_STRING(doc.child(STR("node")).attribute(STR("id")).value(), STR(" val1 val2 val3 val4 ")); } @@ -658,7 +658,7 @@ TEST(parse_attribute_wnorm) for (int wconv = 0; wconv < 2; ++wconv) { unsigned int flags = parse_minimal | parse_wnorm_attribute | (eol ? parse_eol : 0) | (wconv ? parse_wconv_attribute : 0); - CHECK(doc.load(STR("<node id=' \t\r\rval1 \rval2\r\nval3\nval4\r\r'/>"), flags)); + CHECK(doc.load_string(STR("<node id=' \t\r\rval1 \rval2\r\nval3\nval4\r\r'/>"), flags)); CHECK_STRING(doc.child(STR("node")).attribute(STR("id")).value(), STR("val1 val2 val3 val4")); } } @@ -679,7 +679,7 @@ TEST(parse_attribute_variations) flags |= (wconv ? parse_wconv_attribute : 0); flags |= (escapes ? parse_escapes : 0); - CHECK(doc.load(STR("<node id='1'/>"), flags)); + CHECK(doc.load_string(STR("<node id='1'/>"), flags)); CHECK_STRING(doc.child(STR("node")).attribute(STR("id")).value(), STR("1")); } } @@ -688,24 +688,24 @@ TEST(parse_attribute_variations) TEST(parse_attribute_error) { xml_document doc; - CHECK(doc.load(STR("<node id"), parse_minimal).status == status_bad_attribute); - CHECK(doc.load(STR("<node id "), parse_minimal).status == status_bad_attribute); - CHECK(doc.load(STR("<node id "), parse_minimal).status == status_bad_attribute); - CHECK(doc.load(STR("<node id "), parse_minimal).status == status_bad_attribute); - CHECK(doc.load(STR("<node id/"), parse_minimal).status == status_bad_attribute); - CHECK(doc.load(STR("<node id/>"), parse_minimal).status == status_bad_attribute); - CHECK(doc.load(STR("<node id?/>"), parse_minimal).status == status_bad_attribute); - CHECK(doc.load(STR("<node id=/>"), parse_minimal).status == status_bad_attribute); - CHECK(doc.load(STR("<node id='/>"), parse_minimal).status == status_bad_attribute); - CHECK(doc.load(STR("<node id=\"/>"), parse_minimal).status == status_bad_attribute); - CHECK(doc.load(STR("<node id=\"'/>"), parse_minimal).status == status_bad_attribute); - CHECK(doc.load(STR("<node id='\"/>"), parse_minimal).status == status_bad_attribute); - CHECK(doc.load(STR("<node id='\"/>"), parse_minimal).status == status_bad_attribute); - CHECK(doc.load(STR("<node #/>"), parse_minimal).status == status_bad_start_element); - CHECK(doc.load(STR("<node#/>"), parse_minimal).status == status_bad_start_element); - CHECK(doc.load(STR("<node id1='1'id2='2'/>"), parse_minimal).status == status_bad_attribute); - CHECK(doc.load(STR("<node id&='1'/>"), parse_minimal).status == status_bad_attribute); - CHECK(doc.load(STR("<node &='1'/>"), parse_minimal).status == status_bad_start_element); + CHECK(doc.load_string(STR("<node id"), parse_minimal).status == status_bad_attribute); + CHECK(doc.load_string(STR("<node id "), parse_minimal).status == status_bad_attribute); + CHECK(doc.load_string(STR("<node id "), parse_minimal).status == status_bad_attribute); + CHECK(doc.load_string(STR("<node id "), parse_minimal).status == status_bad_attribute); + CHECK(doc.load_string(STR("<node id/"), parse_minimal).status == status_bad_attribute); + CHECK(doc.load_string(STR("<node id/>"), parse_minimal).status == status_bad_attribute); + CHECK(doc.load_string(STR("<node id?/>"), parse_minimal).status == status_bad_attribute); + CHECK(doc.load_string(STR("<node id=/>"), parse_minimal).status == status_bad_attribute); + CHECK(doc.load_string(STR("<node id='/>"), parse_minimal).status == status_bad_attribute); + CHECK(doc.load_string(STR("<node id=\"/>"), parse_minimal).status == status_bad_attribute); + CHECK(doc.load_string(STR("<node id=\"'/>"), parse_minimal).status == status_bad_attribute); + CHECK(doc.load_string(STR("<node id='\"/>"), parse_minimal).status == status_bad_attribute); + CHECK(doc.load_string(STR("<node id='\"/>"), parse_minimal).status == status_bad_attribute); + CHECK(doc.load_string(STR("<node #/>"), parse_minimal).status == status_bad_start_element); + CHECK(doc.load_string(STR("<node#/>"), parse_minimal).status == status_bad_start_element); + CHECK(doc.load_string(STR("<node id1='1'id2='2'/>"), parse_minimal).status == status_bad_attribute); + CHECK(doc.load_string(STR("<node id&='1'/>"), parse_minimal).status == status_bad_attribute); + CHECK(doc.load_string(STR("<node &='1'/>"), parse_minimal).status == status_bad_start_element); } TEST(parse_attribute_termination_error) @@ -722,7 +722,7 @@ TEST(parse_attribute_termination_error) flags |= (eol ? parse_eol : 0); flags |= (wconv ? parse_wconv_attribute : 0); - CHECK(doc.load(STR("<node id='value"), flags).status == status_bad_attribute); + CHECK(doc.load_string(STR("<node id='value"), flags).status == status_bad_attribute); } } @@ -740,7 +740,7 @@ TEST(parse_attribute_quot_inside) flags |= (eol ? parse_eol : 0); flags |= (wconv ? parse_wconv_attribute : 0); - CHECK(doc.load(STR("<node id1='\"' id2=\"'\"/>"), flags)); + CHECK(doc.load_string(STR("<node id1='\"' id2=\"'\"/>"), flags)); CHECK_STRING(doc.child(STR("node")).attribute(STR("id1")).value(), STR("\"")); CHECK_STRING(doc.child(STR("node")).attribute(STR("id2")).value(), STR("'")); } @@ -749,60 +749,60 @@ TEST(parse_attribute_quot_inside) TEST(parse_tag_single) { xml_document doc; - CHECK(doc.load(STR("<node/><node /><node\n/>"), parse_minimal)); + CHECK(doc.load_string(STR("<node/><node /><node\n/>"), parse_minimal)); CHECK_NODE(doc, STR("<node /><node /><node />")); } TEST(parse_tag_hierarchy) { xml_document doc; - CHECK(doc.load(STR("<node><n1><n2/></n1><n3><n4><n5></n5></n4></n3 \r\n></node>"), parse_minimal)); + CHECK(doc.load_string(STR("<node><n1><n2/></n1><n3><n4><n5></n5></n4></n3 \r\n></node>"), parse_minimal)); CHECK_NODE(doc, STR("<node><n1><n2 /></n1><n3><n4><n5 /></n4></n3></node>")); } TEST(parse_tag_error) { xml_document doc; - CHECK(doc.load(STR("<"), parse_minimal).status == status_unrecognized_tag); - CHECK(doc.load(STR("<!"), parse_minimal).status == status_unrecognized_tag); - CHECK(doc.load(STR("<!D"), parse_minimal).status == status_unrecognized_tag); - CHECK(doc.load(STR("<#"), parse_minimal).status == status_unrecognized_tag); - CHECK(doc.load(STR("<node#"), parse_minimal).status == status_bad_start_element); - CHECK(doc.load(STR("<node"), parse_minimal).status == status_bad_start_element); - CHECK(doc.load(STR("<node/"), parse_minimal).status == status_bad_start_element); - CHECK(doc.load(STR("<node /"), parse_minimal).status == status_bad_start_element); - CHECK(doc.load(STR("<node / "), parse_minimal).status == status_bad_start_element); - CHECK(doc.load(STR("<node / >"), parse_minimal).status == status_bad_start_element); - CHECK(doc.load(STR("<node/ >"), parse_minimal).status == status_bad_start_element); - CHECK(doc.load(STR("</ node>"), parse_minimal).status == status_end_element_mismatch); - CHECK(doc.load(STR("</node"), parse_minimal).status == status_end_element_mismatch); - CHECK(doc.load(STR("</node "), parse_minimal).status == status_end_element_mismatch); - CHECK(doc.load(STR("<node></ node>"), parse_minimal).status == status_end_element_mismatch); - CHECK(doc.load(STR("<node></node"), parse_minimal).status == status_bad_end_element); - CHECK(doc.load(STR("<node></node "), parse_minimal).status == status_bad_end_element); - CHECK(doc.load(STR("<node></nodes>"), parse_minimal).status == status_end_element_mismatch); - CHECK(doc.load(STR("<node>"), parse_minimal).status == status_end_element_mismatch); - CHECK(doc.load(STR("<node/><"), parse_minimal).status == status_unrecognized_tag); - CHECK(doc.load(STR("<node attr='value'>"), parse_minimal).status == status_end_element_mismatch); - CHECK(doc.load(STR("</></node>"), parse_minimal).status == status_end_element_mismatch); - CHECK(doc.load(STR("</node>"), parse_minimal).status == status_end_element_mismatch); - CHECK(doc.load(STR("</>"), parse_minimal).status == status_end_element_mismatch); - CHECK(doc.load(STR("<node></node v>"), parse_minimal).status == status_bad_end_element); - CHECK(doc.load(STR("<node&/>"), parse_minimal).status == status_bad_start_element); - CHECK(doc.load(STR("<node& v='1'/>"), parse_minimal).status == status_bad_start_element); + CHECK(doc.load_string(STR("<"), parse_minimal).status == status_unrecognized_tag); + CHECK(doc.load_string(STR("<!"), parse_minimal).status == status_unrecognized_tag); + CHECK(doc.load_string(STR("<!D"), parse_minimal).status == status_unrecognized_tag); + CHECK(doc.load_string(STR("<#"), parse_minimal).status == status_unrecognized_tag); + CHECK(doc.load_string(STR("<node#"), parse_minimal).status == status_bad_start_element); + CHECK(doc.load_string(STR("<node"), parse_minimal).status == status_bad_start_element); + CHECK(doc.load_string(STR("<node/"), parse_minimal).status == status_bad_start_element); + CHECK(doc.load_string(STR("<node /"), parse_minimal).status == status_bad_start_element); + CHECK(doc.load_string(STR("<node / "), parse_minimal).status == status_bad_start_element); + CHECK(doc.load_string(STR("<node / >"), parse_minimal).status == status_bad_start_element); + CHECK(doc.load_string(STR("<node/ >"), parse_minimal).status == status_bad_start_element); + CHECK(doc.load_string(STR("</ node>"), parse_minimal).status == status_end_element_mismatch); + CHECK(doc.load_string(STR("</node"), parse_minimal).status == status_end_element_mismatch); + CHECK(doc.load_string(STR("</node "), parse_minimal).status == status_end_element_mismatch); + CHECK(doc.load_string(STR("<node></ node>"), parse_minimal).status == status_end_element_mismatch); + CHECK(doc.load_string(STR("<node></node"), parse_minimal).status == status_bad_end_element); + CHECK(doc.load_string(STR("<node></node "), parse_minimal).status == status_bad_end_element); + CHECK(doc.load_string(STR("<node></nodes>"), parse_minimal).status == status_end_element_mismatch); + CHECK(doc.load_string(STR("<node>"), parse_minimal).status == status_end_element_mismatch); + CHECK(doc.load_string(STR("<node/><"), parse_minimal).status == status_unrecognized_tag); + CHECK(doc.load_string(STR("<node attr='value'>"), parse_minimal).status == status_end_element_mismatch); + CHECK(doc.load_string(STR("</></node>"), parse_minimal).status == status_end_element_mismatch); + CHECK(doc.load_string(STR("</node>"), parse_minimal).status == status_end_element_mismatch); + CHECK(doc.load_string(STR("</>"), parse_minimal).status == status_end_element_mismatch); + CHECK(doc.load_string(STR("<node></node v>"), parse_minimal).status == status_bad_end_element); + CHECK(doc.load_string(STR("<node&/>"), parse_minimal).status == status_bad_start_element); + CHECK(doc.load_string(STR("<node& v='1'/>"), parse_minimal).status == status_bad_start_element); } TEST(parse_declaration_cases) { xml_document doc; - CHECK(doc.load(STR("<?xml?><?xmL?><?xMl?><?xML?><?Xml?><?XmL?><?XMl?><?XML?>"), parse_fragment | parse_pi)); + CHECK(doc.load_string(STR("<?xml?><?xmL?><?xMl?><?xML?><?Xml?><?XmL?><?XMl?><?XML?>"), parse_fragment | parse_pi)); CHECK(!doc.first_child()); } TEST(parse_declaration_attr_cases) { xml_document doc; - CHECK(doc.load(STR("<?xml ?><?xmL ?><?xMl ?><?xML ?><?Xml ?><?XmL ?><?XMl ?><?XML ?>"), parse_fragment | parse_pi)); + CHECK(doc.load_string(STR("<?xml ?><?xmL ?><?xMl ?><?xML ?><?Xml ?><?XmL ?><?XMl ?><?XML ?>"), parse_fragment | parse_pi)); CHECK(!doc.first_child()); } @@ -816,10 +816,10 @@ TEST(parse_declaration_skip) { unsigned int flags = flag_sets[i]; - CHECK(doc.load(STR("<?xml?><?xml version='1.0'?>"), flags)); + CHECK(doc.load_string(STR("<?xml?><?xml version='1.0'?>"), flags)); CHECK(!doc.first_child()); - CHECK(doc.load(STR("<?xml <tag/> ?>"), flags)); + CHECK(doc.load_string(STR("<?xml <tag/> ?>"), flags)); CHECK(!doc.first_child()); } } @@ -827,7 +827,7 @@ TEST(parse_declaration_skip) TEST(parse_declaration_parse) { xml_document doc; - CHECK(doc.load(STR("<?xml?><?xml version='1.0'?>"), parse_fragment | parse_declaration)); + CHECK(doc.load_string(STR("<?xml?><?xml version='1.0'?>"), parse_fragment | parse_declaration)); xml_node d1 = doc.first_child(); xml_node d2 = doc.last_child(); @@ -850,21 +850,21 @@ TEST(parse_declaration_error) { unsigned int flags = flag_sets[i]; - CHECK(doc.load(STR("<?xml"), flags).status == status_bad_pi); - CHECK(doc.load(STR("<?xml?"), flags).status == status_bad_pi); - CHECK(doc.load(STR("<?xml>"), flags).status == status_bad_pi); - CHECK(doc.load(STR("<?xml version='1>"), flags).status == status_bad_pi); + CHECK(doc.load_string(STR("<?xml"), flags).status == status_bad_pi); + CHECK(doc.load_string(STR("<?xml?"), flags).status == status_bad_pi); + CHECK(doc.load_string(STR("<?xml>"), flags).status == status_bad_pi); + CHECK(doc.load_string(STR("<?xml version='1>"), flags).status == status_bad_pi); } - CHECK(doc.load(STR("<?xml version='1?>"), parse_fragment | parse_declaration).status == status_bad_attribute); - CHECK(doc.load(STR("<foo><?xml version='1'?></foo>"), parse_fragment | parse_declaration).status == status_bad_pi); + CHECK(doc.load_string(STR("<?xml version='1?>"), parse_fragment | parse_declaration).status == status_bad_attribute); + CHECK(doc.load_string(STR("<foo><?xml version='1'?></foo>"), parse_fragment | parse_declaration).status == status_bad_pi); } TEST(parse_empty) { xml_document doc; - CHECK(doc.load(STR("")).status == status_no_document_element && !doc.first_child()); - CHECK(doc.load(STR(""), parse_fragment) && !doc.first_child()); + CHECK(doc.load_string(STR("")).status == status_no_document_element && !doc.first_child()); + CHECK(doc.load_string(STR(""), parse_fragment) && !doc.first_child()); } TEST(parse_out_of_memory) @@ -872,7 +872,7 @@ TEST(parse_out_of_memory) test_runner::_memory_fail_threshold = 256; xml_document doc; - CHECK(doc.load(STR("<foo a='1'/>")).status == status_out_of_memory); + CHECK(doc.load_string(STR("<foo a='1'/>")).status == status_out_of_memory); CHECK(!doc.first_child()); } @@ -928,7 +928,7 @@ TEST(parse_out_of_memory_halfway_attr) static bool test_offset(const char_t* contents, unsigned int options, pugi::xml_parse_status status, ptrdiff_t offset) { xml_document doc; - xml_parse_result res = doc.load(contents, options); + xml_parse_result res = doc.load_string(contents, options); return res.status == status && res.offset == offset; } @@ -1065,7 +1065,7 @@ TEST(parse_bom_fragment_invalid_utf32) TEST(parse_pcdata_gap_fragment) { xml_document doc; - CHECK(doc.load(STR("a&b"), parse_fragment | parse_escapes)); + CHECK(doc.load_string(STR("a&b"), parse_fragment | parse_escapes)); CHECK_STRING(doc.text().get(), STR("a&b")); } diff --git a/tests/test_parse_doctype.cpp b/tests/test_parse_doctype.cpp index f8619fd..14268f6 100644 --- a/tests/test_parse_doctype.cpp +++ b/tests/test_parse_doctype.cpp @@ -20,7 +20,7 @@ static xml_parse_result load_concat(xml_document& doc, const char_t* a, const ch strcat(buffer, c); #endif - return doc.load(buffer, parse_fragment); + return doc.load_string(buffer, parse_fragment); } static bool test_doctype_wf(const char_t* decl) @@ -41,7 +41,7 @@ static bool test_doctype_wf(const char_t* decl) if (!load_concat(doc, STR("<nodea/>"), decl, STR("<nodeb/>")) || !test_node(doc, STR("<nodea /><nodeb />"), STR(""), format_raw)) return false; // check load-store contents preservation - CHECK(doc.load(decl, parse_doctype | parse_fragment)); + CHECK(doc.load_string(decl, parse_doctype | parse_fragment)); CHECK_NODE(doc, decl); return true; @@ -281,8 +281,8 @@ TEST(parse_doctype_xmlconf_oasis_1) // not actually a doctype :) xml_document doc; - CHECK(doc.load(STR("<!--a <!DOCTYPE <?- ]]>-<[ CDATA [ \"- -'- -<doc>--> <!---->"), parse_full | parse_fragment) && doc.first_child().type() == node_comment && doc.last_child().type() == node_comment && doc.first_child().next_sibling() == doc.last_child()); - CHECK(doc.load(STR("<?xmla <!DOCTYPE <[ CDATA [</doc> &a%b&#c?>"), parse_full | parse_fragment) && doc.first_child().type() == node_pi && doc.first_child() == doc.last_child()); + CHECK(doc.load_string(STR("<!--a <!DOCTYPE <?- ]]>-<[ CDATA [ \"- -'- -<doc>--> <!---->"), parse_full | parse_fragment) && doc.first_child().type() == node_comment && doc.last_child().type() == node_comment && doc.first_child().next_sibling() == doc.last_child()); + CHECK(doc.load_string(STR("<?xmla <!DOCTYPE <[ CDATA [</doc> &a%b&#c?>"), parse_full | parse_fragment) && doc.first_child().type() == node_pi && doc.first_child() == doc.last_child()); } TEST(parse_doctype_xmlconf_xmltest_1) @@ -310,15 +310,15 @@ TEST_XML_FLAGS(parse_doctype_value, "<!DOCTYPE doc [ <!ELEMENT doc (#PCDATA)> <! TEST(parse_doctype_error_toplevel) { xml_document doc; - CHECK(doc.load(STR("<node><!DOCTYPE></node>")).status == status_bad_doctype); - CHECK(doc.load(STR("<node><!DOCTYPE></node>"), parse_doctype).status == status_bad_doctype); + CHECK(doc.load_string(STR("<node><!DOCTYPE></node>")).status == status_bad_doctype); + CHECK(doc.load_string(STR("<node><!DOCTYPE></node>"), parse_doctype).status == status_bad_doctype); } TEST(parse_doctype_error_ignore) { xml_document doc; - CHECK(doc.load(STR("<!DOCTYPE root [ <![IGNORE[ ")).status == status_bad_doctype); - CHECK(doc.load(STR("<!DOCTYPE root [ <![IGNORE[ "), parse_doctype).status == status_bad_doctype); - CHECK(doc.load(STR("<!DOCTYPE root [ <![IGNORE[ <![INCLUDE[")).status == status_bad_doctype); - CHECK(doc.load(STR("<!DOCTYPE root [ <![IGNORE[ <![INCLUDE["), parse_doctype).status == status_bad_doctype); + CHECK(doc.load_string(STR("<!DOCTYPE root [ <![IGNORE[ ")).status == status_bad_doctype); + CHECK(doc.load_string(STR("<!DOCTYPE root [ <![IGNORE[ "), parse_doctype).status == status_bad_doctype); + CHECK(doc.load_string(STR("<!DOCTYPE root [ <![IGNORE[ <![INCLUDE[")).status == status_bad_doctype); + CHECK(doc.load_string(STR("<!DOCTYPE root [ <![IGNORE[ <![INCLUDE["), parse_doctype).status == status_bad_doctype); } diff --git a/tests/test_version.cpp b/tests/test_version.cpp index 622a100..24036fc 100644 --- a/tests/test_version.cpp +++ b/tests/test_version.cpp @@ -1,5 +1,5 @@ #include "../src/pugixml.hpp"
-#if PUGIXML_VERSION != 140
+#if PUGIXML_VERSION != 150
#error Unexpected pugixml version
#endif
diff --git a/tests/test_write.cpp b/tests/test_write.cpp index 8fc88e1..ca230c3 100644 --- a/tests/test_write.cpp +++ b/tests/test_write.cpp @@ -483,7 +483,7 @@ TEST(write_stackless) data += STR("</a>"); xml_document doc; - CHECK(doc.load(data.c_str())); + CHECK(doc.load_string(data.c_str())); CHECK_NODE(doc, data.c_str()); } diff --git a/tests/test_xpath.cpp b/tests/test_xpath.cpp index a65ee37..f5b4c66 100644 --- a/tests/test_xpath.cpp +++ b/tests/test_xpath.cpp @@ -13,7 +13,7 @@ static void load_document_copy(xml_document& doc, const char_t* text) { xml_document source; - CHECK(source.load(text)); + CHECK(source.load_string(text)); doc.append_copy(source.first_child()); } @@ -551,10 +551,10 @@ TEST_XML(xpath_sort_append_buffer, "<node /><node />") TEST(xpath_sort_crossdoc) { xml_document doc1; - CHECK(doc1.load(STR("<node />"))); + CHECK(doc1.load_string(STR("<node />"))); xml_document doc2; - CHECK(doc2.load(STR("<node />"))); + CHECK(doc2.load_string(STR("<node />"))); xpath_node_set ns1 = doc1.select_nodes(STR("*")); CHECK(ns1.size() == 1); @@ -639,9 +639,11 @@ TEST(xpath_allocate_string_out_of_memory) #else try { + #ifndef __DMC__ // DigitalMars exception handling crashes instead of catching the exception... xpath_query q(query.c_str()); CHECK_FORCE_FAIL("Expected out of memory exception"); + #endif } catch (const std::bad_alloc&) { diff --git a/tests/test_xpath_operators.cpp b/tests/test_xpath_operators.cpp index 57e3755..450af5d 100644 --- a/tests/test_xpath_operators.cpp +++ b/tests/test_xpath_operators.cpp @@ -492,6 +492,7 @@ TEST(xpath_operators_mod) CHECK_XPATH_NUMBER(c, STR("-5 mod 3"), -2); CHECK_XPATH_NUMBER(c, STR("-5 mod -3"), -2); +#if !defined(__BORLANDC__) // If either operand is NaN, the result is NaN CHECK_XPATH_NUMBER_NAN(c, STR("(0 div 0) mod 3")); CHECK_XPATH_NUMBER_NAN(c, STR("3 mod (0 div 0)")); @@ -505,14 +506,17 @@ TEST(xpath_operators_mod) CHECK_XPATH_NUMBER_NAN(c, STR("-1 mod 0")); CHECK_XPATH_NUMBER_NAN(c, STR("(1 div 0) mod 0")); CHECK_XPATH_NUMBER_NAN(c, STR("(-1 div 0) mod 0")); +#endif // If the dividend is finite and the divisor is an infinity, the result equals the dividend +#if !defined(_MSC_VER) && !defined(__MINGW32__) CHECK_XPATH_NUMBER(c, STR("1 mod (1 div 0)"), 1); CHECK_XPATH_NUMBER(c, STR("1 mod (-1 div 0)"), 1); CHECK_XPATH_NUMBER(c, STR("-1 mod (1 div 0)"), -1); CHECK_XPATH_NUMBER(c, STR("0 mod (1 div 0)"), 0); CHECK_XPATH_NUMBER(c, STR("0 mod (-1 div 0)"), 0); CHECK_XPATH_NUMBER(c, STR("100000 mod (1 div 0)"), 100000); +#endif // If the dividend is a zero and the divisor is finite, the result equals the dividend. CHECK_XPATH_NUMBER(c, STR("0 mod 1000000"), 0); diff --git a/tests/test_xpath_paths.cpp b/tests/test_xpath_paths.cpp index e51a395..69215d8 100644 --- a/tests/test_xpath_paths.cpp +++ b/tests/test_xpath_paths.cpp @@ -460,7 +460,10 @@ TEST_XML(xpath_paths_predicate_number_out_of_range, "<node><chapter/><chapter/>< CHECK_XPATH_NODESET(n, STR("following-sibling::chapter[-1 div 0]")); CHECK_XPATH_NODESET(n, STR("following-sibling::chapter[1000000000000]")); CHECK_XPATH_NODESET(n, STR("following-sibling::chapter[1 div 0]")); + +#ifndef MSVC6_NAN_BUG CHECK_XPATH_NODESET(n, STR("following-sibling::chapter[0 div 0]")); +#endif } TEST_XML(xpath_paths_predicate_constant_boolean, "<node><chapter/><chapter/><chapter/><chapter/><chapter/></node>") @@ -480,7 +483,10 @@ TEST_XML(xpath_paths_predicate_position_eq, "<node><chapter/><chapter/><chapter> CHECK_XPATH_NODESET(doc, STR("node/chapter[position()=1]")) % 3; CHECK_XPATH_NODESET(doc, STR("node/chapter[position()=2+2]")) % 7; CHECK_XPATH_NODESET(doc, STR("node/chapter[position()=last()]")) % 8; + +#ifndef MSVC6_NAN_BUG CHECK_XPATH_NODESET(doc, STR("node/chapter[position()=string()]")) % 5; +#endif } TEST_XML(xpath_paths_predicate_several, "<node><employee/><employee secretary=''/><employee assistant=''/><employee secretary='' assistant=''/><employee assistant='' secretary=''/></node>") |