summaryrefslogtreecommitdiff
path: root/tests/test_parse.cpp
diff options
context:
space:
mode:
authorArseny Kapoulkine <arseny.kapoulkine@gmail.com>2015-04-12 22:09:45 -0700
committerArseny Kapoulkine <arseny.kapoulkine@gmail.com>2015-04-12 22:09:45 -0700
commit054b0b447eff82327c37a617849c3e20fbbb9789 (patch)
tree3055ee4603f8a05ca8dd04f8056573aac3cf4123 /tests/test_parse.cpp
parent6c11a0c693da9ccf38225471d614bde162312427 (diff)
parent9539c488c29e7c2c06afa63abce70785cb5d15c5 (diff)
Merge branch 'master' into compact
Diffstat (limited to 'tests/test_parse.cpp')
-rw-r--r--tests/test_parse.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/test_parse.cpp b/tests/test_parse.cpp
index 08ddee4..393e14c 100644
--- a/tests/test_parse.cpp
+++ b/tests/test_parse.cpp
@@ -935,6 +935,31 @@ TEST(parse_out_of_memory_conversion)
CHECK(!doc.first_child());
}
+TEST(parse_out_of_memory_allocator_state_sync)
+{
+ const unsigned int count = 10000;
+ static char_t text[count * 4];
+
+ for (unsigned int i = 0; i < count; ++i)
+ {
+ text[4*i + 0] = '<';
+ text[4*i + 1] = 'n';
+ text[4*i + 2] = '/';
+ text[4*i + 3] = '>';
+ }
+
+ test_runner::_memory_fail_threshold = 65536;
+
+ xml_document doc;
+ CHECK_ALLOC_FAIL(CHECK(doc.load_buffer_inplace(text, count * 4).status == status_out_of_memory));
+ CHECK_NODE(doc.first_child(), STR("<n />"));
+
+ test_runner::_memory_fail_threshold = 0;
+
+ for (unsigned int i = 0; i < count; ++i)
+ CHECK(doc.append_child(STR("n")));
+}
+
static bool test_offset(const char_t* contents, unsigned int options, pugi::xml_parse_status status, ptrdiff_t offset)
{
xml_document doc;