diff options
author | arseny.kapoulkine <arseny.kapoulkine@99668b35-9821-0410-8761-19e4c4f06640> | 2010-06-11 21:44:28 +0000 |
---|---|---|
committer | arseny.kapoulkine <arseny.kapoulkine@99668b35-9821-0410-8761-19e4c4f06640> | 2010-06-11 21:44:28 +0000 |
commit | 12843b2f1b17811a244778c9236fb7bcfb1a9c2e (patch) | |
tree | 1d2c8d0eddf2acafcf5078bd44d7864445ef024f /tests/test_parse.cpp | |
parent | 624b5702d75d63dde56fbbc89680358241035aa7 (diff) |
tests: Added more (failing) declaration/PI tests
git-svn-id: http://pugixml.googlecode.com/svn/trunk@513 99668b35-9821-0410-8761-19e4c4f06640
Diffstat (limited to 'tests/test_parse.cpp')
-rw-r--r-- | tests/test_parse.cpp | 38 |
1 files 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("<?pi?><?pi value?>"), 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("<?pi?><?pi value?>"), flags));
+ CHECK(!doc.first_child());
+
+ CHECK(doc.load(STR("<?pi <tag/> value?>"), flags));
+ CHECK(!doc.first_child());
+ }
}
TEST(parse_pi_parse)
@@ -54,6 +65,10 @@ TEST(parse_pi_error) 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(STR("<?name&?>"), flags).status == status_bad_pi);
+ CHECK(doc.load(STR("<?name& x?>"), flags).status == status_bad_pi);
}
CHECK(doc.load(STR("<?xx#?>"), parse_minimal | parse_pi).status == status_bad_pi);
@@ -447,6 +462,8 @@ TEST(parse_attribute_error) 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);
}
TEST(parse_tag_single)
@@ -491,6 +508,8 @@ TEST(parse_tag_error) 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);
}
TEST(parse_declaration_cases)
@@ -510,8 +529,19 @@ TEST(parse_declaration_attr_cases) TEST(parse_declaration_skip)
{
xml_document doc;
- CHECK(doc.load(STR("<?xml?><?xml version='1.0'?>"), 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("<?xml?><?xml version='1.0'?>"), flags));
+ CHECK(!doc.first_child());
+
+ CHECK(doc.load(STR("<?xml <tag/> ?>"), flags));
+ CHECK(!doc.first_child());
+ }
}
TEST(parse_declaration_parse)
|