summaryrefslogtreecommitdiff
path: root/tests/test_parse.cpp
diff options
context:
space:
mode:
authorArseny Kapoulkine <arseny.kapoulkine@gmail.com>2015-04-11 22:46:08 -0700
committerArseny Kapoulkine <arseny.kapoulkine@gmail.com>2015-04-11 22:46:08 -0700
commit4e004176bacb0160007102742ec62e79a9d958bb (patch)
treee903e77b67e3a24c50238b7b60b223340fc52b8e /tests/test_parse.cpp
parent37467c13bfdfbdbee7cc5176a8755e04353a9deb (diff)
tests: Improve out-of-memory tests
Previously there was no guarantee that the tests that check for out of memory handling behavior are actually correct - e.g. that they correctly simulate out of memory conditions. Now every simulated out of memory condition has to be "guarded" using CHECK_ALLOC_FAIL. It makes sure that every piece of code that is supposed to cause out-of-memory does so, and that no other code runs out of memory unnoticed.
Diffstat (limited to 'tests/test_parse.cpp')
-rw-r--r--tests/test_parse.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/tests/test_parse.cpp b/tests/test_parse.cpp
index 3ae96d1..08ddee4 100644
--- a/tests/test_parse.cpp
+++ b/tests/test_parse.cpp
@@ -873,7 +873,7 @@ TEST(parse_out_of_memory)
test_runner::_memory_fail_threshold = 256;
xml_document doc;
- CHECK(doc.load_string(STR("<foo a='1'/>")).status == status_out_of_memory);
+ CHECK_ALLOC_FAIL(CHECK(doc.load_string(STR("<foo a='1'/>")).status == status_out_of_memory));
CHECK(!doc.first_child());
}
@@ -893,7 +893,7 @@ TEST(parse_out_of_memory_halfway_node)
test_runner::_memory_fail_threshold = 65536;
xml_document doc;
- CHECK(doc.load_buffer_inplace(text, count * 4).status == status_out_of_memory);
+ CHECK_ALLOC_FAIL(CHECK(doc.load_buffer_inplace(text, count * 4).status == status_out_of_memory));
CHECK_NODE(doc.first_child(), STR("<n />"));
}
@@ -920,7 +920,7 @@ TEST(parse_out_of_memory_halfway_attr)
test_runner::_memory_fail_threshold = 65536;
xml_document doc;
- CHECK(doc.load_buffer_inplace(text, count * 5 + 4).status == status_out_of_memory);
+ CHECK_ALLOC_FAIL(CHECK(doc.load_buffer_inplace(text, count * 5 + 4).status == status_out_of_memory));
CHECK_STRING(doc.first_child().name(), STR("n"));
CHECK_STRING(doc.first_child().first_attribute().name(), STR("a"));
CHECK_STRING(doc.first_child().last_attribute().name(), STR("a"));
@@ -931,7 +931,7 @@ TEST(parse_out_of_memory_conversion)
test_runner::_memory_fail_threshold = 256;
xml_document doc;
- CHECK(doc.load_buffer("<foo\x90/>", 7, parse_default, encoding_latin1).status == status_out_of_memory);
+ CHECK_ALLOC_FAIL(CHECK(doc.load_buffer("<foo\x90/>", 7, parse_default, encoding_latin1).status == status_out_of_memory));
CHECK(!doc.first_child());
}
@@ -950,7 +950,7 @@ TEST(parse_error_offset)
CHECK_OFFSET("<node/>", parse_default, status_ok, 0);
test_runner::_memory_fail_threshold = 1;
- CHECK_OFFSET("<node/>", parse_default, status_out_of_memory, 0);
+ CHECK_ALLOC_FAIL(CHECK_OFFSET("<node/>", parse_default, status_out_of_memory, 0));
test_runner::_memory_fail_threshold = 0;
CHECK_OFFSET("<3d/>", parse_default, status_unrecognized_tag, 1);