summaryrefslogtreecommitdiff
path: root/tests/test_parse.cpp
diff options
context:
space:
mode:
authorArseny Kapoulkine <arseny.kapoulkine@gmail.com>2014-10-23 05:46:44 +0000
committerArseny Kapoulkine <arseny.kapoulkine@gmail.com>2014-10-23 05:46:44 +0000
commitbbd75fda4618dcbef272c8e5432153992c392588 (patch)
tree8180298876db07ff3cfc553822c048fb372fc441 /tests/test_parse.cpp
parent4a7762af9d96f8f12e8aa3f0c0899e9673d38d08 (diff)
tests: Improve test coverage
git-svn-id: https://pugixml.googlecode.com/svn/trunk@1074 99668b35-9821-0410-8761-19e4c4f06640
Diffstat (limited to 'tests/test_parse.cpp')
-rw-r--r--tests/test_parse.cpp31
1 files changed, 30 insertions, 1 deletions
diff --git a/tests/test_parse.cpp b/tests/test_parse.cpp
index 2094ef9..444a0fb 100644
--- a/tests/test_parse.cpp
+++ b/tests/test_parse.cpp
@@ -876,7 +876,7 @@ TEST(parse_out_of_memory)
CHECK(!doc.first_child());
}
-TEST(parse_out_of_memory_halfway)
+TEST(parse_out_of_memory_halfway_node)
{
const unsigned int count = 10000;
static char_t text[count * 4];
@@ -896,6 +896,35 @@ TEST(parse_out_of_memory_halfway)
CHECK_NODE(doc.first_child(), STR("<n />"));
}
+TEST(parse_out_of_memory_halfway_attr)
+{
+ const unsigned int count = 10000;
+ static char_t text[count * 5 + 4];
+
+ text[0] = '<';
+ text[1] = 'n';
+
+ for (unsigned int i = 0; i < count; ++i)
+ {
+ text[5*i + 2] = ' ';
+ text[5*i + 3] = 'a';
+ text[5*i + 4] = '=';
+ text[5*i + 5] = '"';
+ text[5*i + 6] = '"';
+ }
+
+ text[5 * count + 2] = '/';
+ text[5 * count + 3] = '>';
+
+ test_runner::_memory_fail_threshold = 65536;
+
+ xml_document doc;
+ CHECK(doc.load_buffer_inplace(text, count * 5 + 4).status == status_out_of_memory);
+ CHECK_STRING(doc.first_child().name(), STR("n"));
+ CHECK_STRING(doc.first_child().first_attribute().name(), STR("a"));
+ CHECK_STRING(doc.first_child().last_attribute().name(), STR("a"));
+}
+
static bool test_offset(const char_t* contents, unsigned int options, pugi::xml_parse_status status, ptrdiff_t offset)
{
xml_document doc;