0
0
mirror of https://github.com/zeux/pugixml.git synced 2024-12-28 06:10:55 +08:00

tests: Added wildcard and doctype tests

git-svn-id: http://pugixml.googlecode.com/svn/trunk@163 99668b35-9821-0410-8761-19e4c4f06640
This commit is contained in:
arseny.kapoulkine 2009-10-20 20:51:20 +00:00
parent c026597234
commit a837271e9d
2 changed files with 55 additions and 0 deletions

View File

@ -724,3 +724,27 @@ TEST_XML_FLAGS(dom_offset_debug, "<?xml?><?pi?><!--comment--><node>pcdata<![CDAT
CHECK((cit++)->offset_debug() == 33);
CHECK((cit++)->offset_debug() == 48);
}
TEST_XML(dom_node_wildcard_cset, "<node c='1'/>")
{
xml_node node = doc.child("node");
CHECK(node.attribute_w("[A-Z]").as_int() == 0);
CHECK(node.attribute_w("[a-z]").as_int() == 1);
CHECK(node.attribute_w("[A-z]").as_int() == 1);
CHECK(node.attribute_w("[z-a]").as_int() == 0);
CHECK(node.attribute_w("[a-zA-Z]").as_int() == 1);
CHECK(node.attribute_w("[!A-Z]").as_int() == 1);
CHECK(node.attribute_w("[!A-Za-z]").as_int() == 0);
}
TEST_XML(dom_node_wildcard_star, "<node cd='1'/>")
{
xml_node node = doc.child("node");
CHECK(node.attribute_w("*").as_int() == 1);
CHECK(node.attribute_w("?d*").as_int() == 1);
CHECK(node.attribute_w("?c*").as_int() == 0);
CHECK(node.attribute_w("*?*c*").as_int() == 0);
CHECK(node.attribute_w("*?*d*").as_int() == 1);
}

View File

@ -273,6 +273,8 @@ TEST(parse_escapes_error)
xml_document doc;
CHECK(doc.load("<node>&#x03g;&#ab;&quot</node>", parse_minimal | parse_escapes));
CHECK_STRING(doc.child_value("node"), "&#x03g;&#ab;&quot");
CHECK(!doc.load("<node id='&#x12"));
}
TEST(parse_attribute_spaces)
@ -388,6 +390,8 @@ TEST(parse_tag_error)
{
xml_document doc;
CHECK(doc.load("<", parse_minimal).status == status_unrecognized_tag);
CHECK(doc.load("<!", parse_minimal).status == status_unrecognized_tag);
CHECK(doc.load("<!D", parse_minimal).status == status_unrecognized_tag);
CHECK(doc.load("<#", parse_minimal).status == status_unrecognized_tag);
CHECK(doc.load("<node#", parse_minimal).status == status_bad_start_element);
CHECK(doc.load("<node", parse_minimal).status == status_bad_start_element);
@ -443,3 +447,30 @@ TEST(parse_declaration_error)
CHECK(doc.load("<?xml version='1?>", parse_minimal | parse_declaration).status == status_bad_attribute);
}
TEST(parse_doctype_skip)
{
xml_document doc;
CHECK(doc.load("<!DOCTYPE doc>") && !doc.first_child());
CHECK(doc.load("<!DOCTYPE doc SYSTEM 'foo'>") && !doc.first_child());
CHECK(doc.load("<!DOCTYPE doc SYSTEM \"foo\">") && !doc.first_child());
CHECK(doc.load("<!DOCTYPE doc PUBLIC \"foo\" 'bar'>") && !doc.first_child());
CHECK(doc.load("<!DOCTYPE doc PUBLIC \"foo'\">") && !doc.first_child());
CHECK(doc.load("<!DOCTYPE doc SYSTEM 'foo' [<!ELEMENT foo 'ANY'>]>") && !doc.first_child());
CHECK(doc.load("<!DOCTYPE doc SYSTEM 'foo' [<!ELEMENT foo 'ANY'>]><node/>"));
CHECK_NODE(doc, "<node />");
}
TEST(parse_doctype_error)
{
xml_document doc;
CHECK(doc.load("<!DOCTYPE").status == status_bad_doctype);
CHECK(doc.load("<!DOCTYPE doc").status == status_bad_doctype);
CHECK(doc.load("<!DOCTYPE doc SYSTEM 'foo").status == status_bad_doctype);
CHECK(doc.load("<!DOCTYPE doc SYSTEM \"foo").status == status_bad_doctype);
CHECK(doc.load("<!DOCTYPE doc PUBLIC \"foo\" 'bar").status == status_bad_doctype);
CHECK(doc.load("<!DOCTYPE doc PUBLIC \"foo'\"").status == status_bad_doctype);
CHECK(doc.load("<!DOCTYPE doc SYSTEM 'foo' [<!ELEMENT foo 'ANY").status == status_bad_doctype);
CHECK(doc.load("<!DOCTYPE doc SYSTEM 'foo' [<!ELEMENT foo 'ANY'>").status == status_bad_doctype);
}