From 12843b2f1b17811a244778c9236fb7bcfb1a9c2e Mon Sep 17 00:00:00 2001 From: "arseny.kapoulkine" Date: Fri, 11 Jun 2010 21:44:28 +0000 Subject: tests: Added more (failing) declaration/PI tests git-svn-id: http://pugixml.googlecode.com/svn/trunk@513 99668b35-9821-0410-8761-19e4c4f06640 --- tests/test_parse.cpp | 38 ++++++++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/tests/test_parse.cpp b/tests/test_parse.cpp index 50f8867..bfa84c0 100644 --- a/tests/test_parse.cpp +++ b/tests/test_parse.cpp @@ -3,8 +3,19 @@ TEST(parse_pi_skip) { xml_document doc; - CHECK(doc.load(STR(""), parse_minimal)); - CHECK(!doc.first_child()); + + unsigned int flag_sets[] = {parse_minimal, parse_minimal | parse_declaration}; + + for (unsigned int i = 0; i < sizeof(flag_sets) / sizeof(flag_sets[0]); ++i) + { + unsigned int flags = flag_sets[i]; + + CHECK(doc.load(STR(""), flags)); + CHECK(!doc.first_child()); + + CHECK(doc.load(STR(" value?>"), flags)); + CHECK(!doc.first_child()); + } } TEST(parse_pi_parse) @@ -54,6 +65,10 @@ TEST(parse_pi_error) 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(""), parse_minimal | parse_pi).status == status_bad_pi); @@ -447,6 +462,8 @@ TEST(parse_attribute_error) CHECK(doc.load(STR(""), parse_minimal).status == status_bad_start_element); CHECK(doc.load(STR(""), parse_minimal).status == status_bad_start_element); CHECK(doc.load(STR(""), parse_minimal).status == status_bad_attribute); + CHECK(doc.load(STR(""), parse_minimal).status == status_bad_attribute); + CHECK(doc.load(STR(""), parse_minimal).status == status_bad_start_element); } TEST(parse_tag_single) @@ -491,6 +508,8 @@ TEST(parse_tag_error) CHECK(doc.load(STR(""), parse_minimal).status == status_end_element_mismatch); CHECK(doc.load(STR(""), parse_minimal).status == status_end_element_mismatch); CHECK(doc.load(STR(""), parse_minimal).status == status_bad_end_element); + CHECK(doc.load(STR(""), parse_minimal).status == status_bad_start_element); + CHECK(doc.load(STR(""), parse_minimal).status == status_bad_start_element); } TEST(parse_declaration_cases) @@ -510,8 +529,19 @@ TEST(parse_declaration_attr_cases) TEST(parse_declaration_skip) { xml_document doc; - CHECK(doc.load(STR(""), parse_minimal)); - CHECK(!doc.first_child()); + + unsigned int flag_sets[] = {parse_minimal, parse_minimal | parse_pi}; + + for (unsigned int i = 0; i < sizeof(flag_sets) / sizeof(flag_sets[0]); ++i) + { + unsigned int flags = flag_sets[i]; + + CHECK(doc.load(STR(""), flags)); + CHECK(!doc.first_child()); + + CHECK(doc.load(STR(" ?>"), flags)); + CHECK(!doc.first_child()); + } } TEST(parse_declaration_parse) -- cgit v1.2.3