summaryrefslogtreecommitdiff
path: root/tests/test_dom_modify.cpp
diff options
context:
space:
mode:
authorArseny Kapoulkine <arseny.kapoulkine@gmail.com>2015-04-11 00:16:39 -0700
committerArseny Kapoulkine <arseny.kapoulkine@gmail.com>2015-04-11 00:16:39 -0700
commit29fef9aca2f5832eb721f9d097d2a6f6ebdb0179 (patch)
treec66aec5d90db94633d72ff47d879dacbad15ef46 /tests/test_dom_modify.cpp
parent405fefc8777c55900a4e44561b545a9abb5276ba (diff)
tests: Add more out of memory tests
This provides more coverage for #17.
Diffstat (limited to 'tests/test_dom_modify.cpp')
-rw-r--r--tests/test_dom_modify.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/test_dom_modify.cpp b/tests/test_dom_modify.cpp
index fa50112..8610a74 100644
--- a/tests/test_dom_modify.cpp
+++ b/tests/test_dom_modify.cpp
@@ -1100,6 +1100,42 @@ TEST(dom_node_append_buffer_out_of_memory_buffer)
CHECK(!doc.first_child());
}
+TEST(dom_node_append_buffer_out_of_memory_nodes)
+{
+ unsigned int count = 4000;
+ std::basic_string<char_t> data;
+
+ for (unsigned int i = 0; i < count; ++i)
+ data += STR("<a/>");
+
+ test_runner::_memory_fail_threshold = 32768 + 128 + data.length() * sizeof(wchar_t) + 32;
+
+ xml_document doc;
+ CHECK(doc.append_buffer(data.c_str(), data.length() * sizeof(wchar_t), parse_fragment).status == status_out_of_memory);
+
+ unsigned int valid = 0;
+
+ for (xml_node n = doc.first_child(); n; n = n.next_sibling())
+ {
+ CHECK_STRING(n.name(), STR("a"));
+ valid++;
+ }
+
+ CHECK(valid > 0 && valid < count);
+}
+
+TEST(dom_node_append_buffer_out_of_memory_name)
+{
+ test_runner::_memory_fail_threshold = 32768 + 128;
+
+ char data[128] = {0};
+
+ xml_document doc;
+ CHECK(doc.append_child(STR("root")));
+ CHECK(doc.first_child().append_buffer(data, sizeof(data)).status == status_out_of_memory);
+ CHECK_STRING(doc.first_child().name(), STR("root"));
+}
+
TEST_XML(dom_node_append_buffer_fragment, "<node />")
{
xml_node node = doc.child(STR("node"));