diff options
author | Arseny Kapoulkine <arseny.kapoulkine@gmail.com> | 2015-04-12 21:27:12 -0700 |
---|---|---|
committer | Arseny Kapoulkine <arseny.kapoulkine@gmail.com> | 2015-04-12 21:27:12 -0700 |
commit | 5edeaf67658a3ab27e9ace87ccff37aba8352607 (patch) | |
tree | b49648254cc6c4de54dcacb88fcbdccd3bd1ebba /tests/test_parse.cpp | |
parent | a0d065cd22d1d43c417f6d3db88a04bf57b67ed0 (diff) |
tests: Add more out of memory tests
Also add tests that verify save_file for absence of FILE leaks.
Diffstat (limited to 'tests/test_parse.cpp')
-rw-r--r-- | tests/test_parse.cpp | 25 |
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; |