From 630be2edb3110b9627718bd7b735348e4940fdd4 Mon Sep 17 00:00:00 2001 From: "arseny.kapoulkine" Date: Sun, 26 Sep 2010 19:01:36 +0000 Subject: tests: Added node_doctype and parse_doctype tests git-svn-id: http://pugixml.googlecode.com/svn/trunk@757 99668b35-9821-0410-8761-19e4c4f06640 --- tests/test_parse_doctype.cpp | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) (limited to 'tests/test_parse_doctype.cpp') diff --git a/tests/test_parse_doctype.cpp b/tests/test_parse_doctype.cpp index c633467..2a092d9 100644 --- a/tests/test_parse_doctype.cpp +++ b/tests/test_parse_doctype.cpp @@ -40,8 +40,9 @@ static bool test_doctype_wf(const char_t* decl) if (!load_concat(doc, decl, STR("")) || !test_node(doc, STR(""), STR(""), format_raw)) return false; if (!load_concat(doc, STR(""), decl, STR("")) || !test_node(doc, STR(""), STR(""), format_raw)) return false; - // wrap in node to check that doctype is parsed fully (does not leave any "pcdata") - if (!load_concat(doc, STR(""), decl, STR("")) || !test_node(doc, STR(""), STR(""), format_raw)) return false; + // check load-store contents preservation + CHECK(doc.load(decl, parse_doctype)); + CHECK_NODE(doc, decl); return true; } @@ -276,9 +277,12 @@ TEST(parse_doctype_xmlconf_oasis_1) TEST_DOCTYPE_WF(" ?>/\''\"> ]>"); TEST_DOCTYPE_WF(" ]>"); TEST_DOCTYPE_WF(" ]>"); - TEST_DOCTYPE_WF(" "); // not actually a doctype :) - TEST_DOCTYPE_WF(" &a%b&#c?>"); // not actually a doctype :) TEST_DOCTYPE_WF("]>"); + + // not actually a doctype :) + xml_document doc; + CHECK(doc.load(STR(" "), parse_full) && doc.first_child().type() == node_comment && doc.last_child().type() == node_comment && doc.first_child().next_sibling() == doc.last_child()); + CHECK(doc.load(STR(" &a%b&#c?>"), parse_full) && doc.first_child().type() == node_pi && doc.first_child() == doc.last_child()); } TEST(parse_doctype_xmlconf_xmltest_1) @@ -294,3 +298,18 @@ TEST(parse_doctype_xmlconf_xmltest_1) TEST_DOCTYPE_WF("\"> ]>"); TEST_DOCTYPE_WF(" \"> ]>"); } + +TEST_XML_FLAGS(parse_doctype_value, " \"> ]>", parse_minimal | parse_doctype) +{ + xml_node n = doc.first_child(); + + CHECK(n.type() == node_doctype); + CHECK_STRING(n.value(), STR("doc [ \"> ]")); +} + +TEST(parse_doctype_error_toplevel) +{ + xml_document doc; + CHECK(doc.load(STR("")).status == status_bad_doctype); + CHECK(doc.load(STR(""), parse_doctype).status == status_bad_doctype); +} -- cgit v1.2.3