summaryrefslogtreecommitdiff
path: root/tests/test_parse.cpp
diff options
context:
space:
mode:
authorarseny.kapoulkine <arseny.kapoulkine@99668b35-9821-0410-8761-19e4c4f06640>2010-08-04 10:01:16 +0000
committerarseny.kapoulkine <arseny.kapoulkine@99668b35-9821-0410-8761-19e4c4f06640>2010-08-04 10:01:16 +0000
commit05c651d87f95268823f4f0ed5a9206b5cd734507 (patch)
tree4439f7fdb0665693ed724fa914c37aac7469ebe3 /tests/test_parse.cpp
parentf8c18461e6e6459a4e13c05fb964dddfa810dae0 (diff)
tests: Added more tests for better code coverage
git-svn-id: http://pugixml.googlecode.com/svn/trunk@626 99668b35-9821-0410-8761-19e4c4f06640
Diffstat (limited to 'tests/test_parse.cpp')
-rw-r--r--tests/test_parse.cpp74
1 files changed, 69 insertions, 5 deletions
diff --git a/tests/test_parse.cpp b/tests/test_parse.cpp
index c7e3ae3..5b3cf3f 100644
--- a/tests/test_parse.cpp
+++ b/tests/test_parse.cpp
@@ -144,6 +144,13 @@ TEST(parse_cdata_skip)
CHECK(!doc.first_child());
}
+TEST(parse_cdata_skip_contents)
+{
+ xml_document doc;
+ CHECK(doc.load(STR("<node><![CDATA[]]>hello<![CDATA[value]]>, world!</node>"), parse_minimal));
+ CHECK_NODE(doc, STR("<node>hello, world!</node>"));
+}
+
TEST(parse_cdata_parse)
{
xml_document doc;
@@ -377,6 +384,25 @@ TEST(parse_escapes_code_invalid)
CHECK_STRING(doc.child_value(STR("node")), STR("&#;&#x;&;&#x-;&#-;"));
}
+TEST(parse_escapes_attribute)
+{
+ xml_document doc;
+
+ for (int wnorm = 0; wnorm < 2; ++wnorm)
+ for (int eol = 0; eol < 2; ++eol)
+ for (int wconv = 0; wconv < 2; ++wconv)
+ {
+ unsigned int flags = parse_escapes;
+
+ flags |= (wnorm ? parse_wnorm_attribute : 0);
+ flags |= (eol ? parse_eol : 0);
+ flags |= (wconv ? parse_wconv_attribute : 0);
+
+ CHECK(doc.load(STR("<node id='&quot;'/>"), flags));
+ CHECK_STRING(doc.child(STR("node")).attribute(STR("id")).value(), STR("\""));
+ }
+}
+
TEST(parse_attribute_spaces)
{
xml_document doc;
@@ -447,11 +473,11 @@ TEST(parse_attribute_variations)
for (int escapes = 0; escapes < 2; ++escapes)
{
unsigned int flags = parse_minimal;
-
- flags |= (wnorm ? parse_wnorm_attribute : 0);
- flags |= (eol ? parse_eol : 0);
- flags |= (wconv ? parse_wconv_attribute : 0);
- flags |= (escapes ? parse_escapes : 0);
+
+ flags |= (wnorm ? parse_wnorm_attribute : 0);
+ flags |= (eol ? parse_eol : 0);
+ flags |= (wconv ? parse_wconv_attribute : 0);
+ flags |= (escapes ? parse_escapes : 0);
CHECK(doc.load(STR("<node id='1'/>"), flags));
CHECK_STRING(doc.child(STR("node")).attribute(STR("id")).value(), STR("1"));
@@ -482,6 +508,44 @@ TEST(parse_attribute_error)
CHECK(doc.load(STR("<node &='1'/>"), parse_minimal).status == status_bad_start_element);
}
+TEST(parse_attribute_termination_error)
+{
+ xml_document doc;
+
+ for (int wnorm = 0; wnorm < 2; ++wnorm)
+ for (int eol = 0; eol < 2; ++eol)
+ for (int wconv = 0; wconv < 2; ++wconv)
+ {
+ unsigned int flags = parse_minimal;
+
+ flags |= (wnorm ? parse_wnorm_attribute : 0);
+ flags |= (eol ? parse_eol : 0);
+ flags |= (wconv ? parse_wconv_attribute : 0);
+
+ CHECK(doc.load(STR("<node id='value"), flags).status == status_bad_attribute);
+ }
+}
+
+TEST(parse_attribute_quot_inside)
+{
+ xml_document doc;
+
+ for (int wnorm = 0; wnorm < 2; ++wnorm)
+ for (int eol = 0; eol < 2; ++eol)
+ for (int wconv = 0; wconv < 2; ++wconv)
+ {
+ unsigned int flags = parse_escapes;
+
+ flags |= (wnorm ? parse_wnorm_attribute : 0);
+ flags |= (eol ? parse_eol : 0);
+ flags |= (wconv ? parse_wconv_attribute : 0);
+
+ CHECK(doc.load(STR("<node id1='\"' id2=\"'\"/>"), flags));
+ CHECK_STRING(doc.child(STR("node")).attribute(STR("id1")).value(), STR("\""));
+ CHECK_STRING(doc.child(STR("node")).attribute(STR("id2")).value(), STR("'"));
+ }
+}
+
TEST(parse_tag_single)
{
xml_document doc;