Deprecate xml_document::load(const char*) and xml_node::select_single_node
These functions were deprecated via comments in 1.5 but never got the deprecated attribute; now is the time! Using deprecated functions produces a warning; to silence it, this change moves the relevant tests to a separate translation unit that has deprecation disabled.
This commit is contained in:
parent
94ef7b3a03
commit
2252927c04
@ -631,8 +631,8 @@ namespace pugi
|
|||||||
xpath_node_set select_nodes(const xpath_query& query) const;
|
xpath_node_set select_nodes(const xpath_query& query) const;
|
||||||
|
|
||||||
// (deprecated: use select_node instead) Select single node by evaluating XPath query.
|
// (deprecated: use select_node instead) Select single node by evaluating XPath query.
|
||||||
xpath_node select_single_node(const char_t* query, xpath_variable_set* variables = 0) const;
|
PUGIXML_DEPRECATED xpath_node select_single_node(const char_t* query, xpath_variable_set* variables = 0) const;
|
||||||
xpath_node select_single_node(const xpath_query& query) const;
|
PUGIXML_DEPRECATED xpath_node select_single_node(const xpath_query& query) const;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1004,7 +1004,7 @@ namespace pugi
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// (deprecated: use load_string instead) Load document from zero-terminated string. No encoding conversions are applied.
|
// (deprecated: use load_string instead) Load document from zero-terminated string. No encoding conversions are applied.
|
||||||
xml_parse_result load(const char_t* contents, unsigned int options = parse_default);
|
PUGIXML_DEPRECATED xml_parse_result load(const char_t* contents, unsigned int options = parse_default);
|
||||||
|
|
||||||
// Load document from zero-terminated string. No encoding conversions are applied.
|
// Load document from zero-terminated string. No encoding conversions are applied.
|
||||||
xml_parse_result load_string(const char_t* contents, unsigned int options = parse_default);
|
xml_parse_result load_string(const char_t* contents, unsigned int options = parse_default);
|
||||||
|
|||||||
21
tests/test_deprecated.cpp
Normal file
21
tests/test_deprecated.cpp
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#define PUGIXML_DEPRECATED // Suppress deprecated declarations to avoid warnings
|
||||||
|
|
||||||
|
#include "common.hpp"
|
||||||
|
|
||||||
|
TEST(document_deprecated_load)
|
||||||
|
{
|
||||||
|
xml_document doc;
|
||||||
|
CHECK(doc.load(STR("<node/>")));
|
||||||
|
CHECK_NODE(doc, STR("<node/>"));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_XML(xpath_api_deprecated_select_single_node, "<node><head/><foo id='1'/><foo/><tail/></node>")
|
||||||
|
{
|
||||||
|
xpath_node n1 = doc.select_single_node(STR("node/foo"));
|
||||||
|
|
||||||
|
xpath_query q(STR("node/foo"));
|
||||||
|
xpath_node n2 = doc.select_single_node(q);
|
||||||
|
|
||||||
|
CHECK(n1.node().attribute(STR("id")).as_int() == 1);
|
||||||
|
CHECK(n2.node().attribute(STR("id")).as_int() == 1);
|
||||||
|
}
|
||||||
@ -1479,10 +1479,3 @@ TEST(document_convert_out_of_memory)
|
|||||||
delete[] files[j].data;
|
delete[] files[j].data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(document_deprecated_load)
|
|
||||||
{
|
|
||||||
xml_document doc;
|
|
||||||
CHECK(doc.load(STR("<node/>")));
|
|
||||||
CHECK_NODE(doc, STR("<node/>"));
|
|
||||||
}
|
|
||||||
|
|||||||
@ -399,17 +399,6 @@ TEST_XML(xpath_api_node_set_assign_out_of_memory_preserve, "<node><a/><b/></node
|
|||||||
CHECK(ns[0] == doc.child(STR("node")).child(STR("a")) && ns[1] == doc.child(STR("node")).child(STR("b")));
|
CHECK(ns[0] == doc.child(STR("node")).child(STR("a")) && ns[1] == doc.child(STR("node")).child(STR("b")));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_XML(xpath_api_deprecated_select_single_node, "<node><head/><foo id='1'/><foo/><tail/></node>")
|
|
||||||
{
|
|
||||||
xpath_node n1 = doc.select_single_node(STR("node/foo"));
|
|
||||||
|
|
||||||
xpath_query q(STR("node/foo"));
|
|
||||||
xpath_node n2 = doc.select_single_node(q);
|
|
||||||
|
|
||||||
CHECK(n1.node().attribute(STR("id")).as_int() == 1);
|
|
||||||
CHECK(n2.node().attribute(STR("id")).as_int() == 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST(xpath_api_empty)
|
TEST(xpath_api_empty)
|
||||||
{
|
{
|
||||||
xml_node c;
|
xml_node c;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user