From 50bfdb1856659a89d4db674abe2b69a2c7589a83 Mon Sep 17 00:00:00 2001 From: Arseny Kapoulkine Date: Thu, 6 Nov 2014 09:59:07 +0100 Subject: tests: Fix all tests for compact mode Memory allocation behavior is different in compact mode so tests that rely on current behavior have to be adjusted. --- tests/test_dom_modify.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'tests/test_dom_modify.cpp') diff --git a/tests/test_dom_modify.cpp b/tests/test_dom_modify.cpp index 45cf3ea..6417033 100644 --- a/tests/test_dom_modify.cpp +++ b/tests/test_dom_modify.cpp @@ -1310,6 +1310,11 @@ TEST(dom_node_copy_copyless) // the document is parsed in-place so there should only be 1 page worth of allocations test_runner::_memory_fail_threshold = 32768 + 128; +#ifdef PUGIXML_COMPACT + // ... and some space for hash table + test_runner::_memory_fail_threshold += 2048; +#endif + xml_document doc; CHECK(doc.load_buffer_inplace(&datacopy[0], datacopy.size() * sizeof(char_t), parse_full)); -- cgit v1.2.3 From 6c11a0c693da9ccf38225471d614bde162312427 Mon Sep 17 00:00:00 2001 From: Arseny Kapoulkine Date: Sun, 12 Apr 2015 03:14:08 -0700 Subject: Fix compilation and tests after merge. --- tests/test_dom_modify.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'tests/test_dom_modify.cpp') diff --git a/tests/test_dom_modify.cpp b/tests/test_dom_modify.cpp index 47c4a04..071b798 100644 --- a/tests/test_dom_modify.cpp +++ b/tests/test_dom_modify.cpp @@ -1115,6 +1115,11 @@ TEST(dom_node_append_buffer_out_of_memory_nodes) test_runner::_memory_fail_threshold = 32768 + 128 + data.length() * sizeof(char_t) + 32; +#ifdef PUGIXML_COMPACT + // ... and some space for hash table + test_runner::_memory_fail_threshold += 2048; +#endif + xml_document doc; CHECK_ALLOC_FAIL(CHECK(doc.append_buffer(data.c_str(), data.length() * sizeof(char_t), parse_fragment).status == status_out_of_memory)); @@ -1131,9 +1136,9 @@ TEST(dom_node_append_buffer_out_of_memory_nodes) TEST(dom_node_append_buffer_out_of_memory_name) { - test_runner::_memory_fail_threshold = 32768 + 128; + test_runner::_memory_fail_threshold = 32768 + 4096; - char data[128] = {0}; + char data[4096] = {0}; xml_document doc; CHECK(doc.append_child(STR("root"))); @@ -1459,6 +1464,11 @@ TEST(dom_node_copy_attribute_copyless) // the document is parsed in-place so there should only be 1 page worth of allocations test_runner::_memory_fail_threshold = 32768 + 128; +#ifdef PUGIXML_COMPACT + // ... and some space for hash table + test_runner::_memory_fail_threshold += 2048; +#endif + xml_document doc; CHECK(doc.load_buffer_inplace(&datacopy[0], datacopy.size() * sizeof(char_t), parse_full)); -- cgit v1.2.3 From 3643b505a6f95e65037c5d906e7fb81ac16698cf Mon Sep 17 00:00:00 2001 From: Arseny Kapoulkine Date: Wed, 22 Apr 2015 08:38:52 -0700 Subject: Fix node_pi memory leak --- tests/test_dom_modify.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'tests/test_dom_modify.cpp') diff --git a/tests/test_dom_modify.cpp b/tests/test_dom_modify.cpp index 54bbee4..365561f 100644 --- a/tests/test_dom_modify.cpp +++ b/tests/test_dom_modify.cpp @@ -948,6 +948,25 @@ TEST(dom_node_memory_limit) } } +TEST(dom_node_memory_limit_pi) +{ + const unsigned int length = 65536; + static char_t string[length + 1]; + + for (unsigned int i = 0; i < length; ++i) string[i] = 'a'; + string[length] = 0; + + test_runner::_memory_fail_threshold = 32768 * 2 + sizeof(string); + + xml_document doc; + + for (int j = 0; j < 32; ++j) + { + CHECK(doc.append_child(node_pi).set_value(string)); + CHECK(doc.remove_child(doc.first_child())); + } +} + TEST(dom_node_doctype_top_level) { xml_document doc; -- cgit v1.2.3