summaryrefslogtreecommitdiff
path: root/tests/test_document.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_document.cpp
parent6c11a0c693da9ccf38225471d614bde162312427 (diff)
parent9539c488c29e7c2c06afa63abce70785cb5d15c5 (diff)
Merge branch 'master' into compact
Diffstat (limited to 'tests/test_document.cpp')
-rw-r--r--tests/test_document.cpp37
1 files changed, 35 insertions, 2 deletions
diff --git a/tests/test_document.cpp b/tests/test_document.cpp
index 1545e19..9c8c860 100644
--- a/tests/test_document.cpp
+++ b/tests/test_document.cpp
@@ -319,9 +319,7 @@ TEST(document_load_file_out_of_memory_file_leak)
pugi::xml_document doc;
for (int i = 0; i < 256; ++i)
- {
CHECK_ALLOC_FAIL(CHECK(doc.load_file("tests/data/small.xml").status == status_out_of_memory));
- }
test_runner::_memory_fail_threshold = 0;
@@ -329,6 +327,21 @@ TEST(document_load_file_out_of_memory_file_leak)
CHECK_NODE(doc, STR("<node />"));
}
+TEST(document_load_file_wide_out_of_memory_file_leak)
+{
+ test_runner::_memory_fail_threshold = 256;
+
+ pugi::xml_document doc;
+
+ for (int i = 0; i < 256; ++i)
+ CHECK_ALLOC_FAIL(CHECK(doc.load_file(L"tests/data/small.xml").status == status_out_of_memory));
+
+ test_runner::_memory_fail_threshold = 0;
+
+ CHECK(doc.load_file(L"tests/data/small.xml"));
+ CHECK_NODE(doc, STR("<node />"));
+}
+
TEST(document_load_file_error_previous)
{
pugi::xml_document doc;
@@ -556,6 +569,26 @@ TEST_XML(document_save_file_wide_text, "<node/>")
CHECK(test_file_contents(f.path, "<node />\n", 9));
}
+TEST_XML(document_save_file_leak, "<node/>")
+{
+ temp_file f;
+
+ for (int i = 0; i < 256; ++i)
+ CHECK(doc.save_file(f.path));
+}
+
+TEST_XML(document_save_file_wide_leak, "<node/>")
+{
+ temp_file f;
+
+ // widen the path
+ wchar_t wpath[sizeof(f.path)];
+ std::copy(f.path, f.path + strlen(f.path) + 1, wpath + 0);
+
+ for (int i = 0; i < 256; ++i)
+ CHECK(doc.save_file(wpath));
+}
+
TEST(document_load_buffer)
{
const pugi::char_t text[] = STR("<?xml?><node/>");