From 4e004176bacb0160007102742ec62e79a9d958bb Mon Sep 17 00:00:00 2001 From: Arseny Kapoulkine Date: Sat, 11 Apr 2015 22:46:08 -0700 Subject: 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. --- tests/test_xpath_api.cpp | 32 ++++---------------------------- 1 file changed, 4 insertions(+), 28 deletions(-) (limited to 'tests/test_xpath_api.cpp') diff --git a/tests/test_xpath_api.cpp b/tests/test_xpath_api.cpp index deb3beb..df078a0 100644 --- a/tests/test_xpath_api.cpp +++ b/tests/test_xpath_api.cpp @@ -356,6 +356,7 @@ TEST(xpath_api_exception_what) CHECK(e.what()[0] != 0); } } +#endif TEST(xpath_api_node_set_ctor_out_of_memory) { @@ -363,15 +364,7 @@ TEST(xpath_api_node_set_ctor_out_of_memory) xpath_node data[2]; - try - { - xpath_node_set ns(data, data + 2); - - CHECK_FORCE_FAIL("Expected out of memory exception"); - } - catch (const std::bad_alloc&) - { - } + CHECK_ALLOC_FAIL(xpath_node_set ns(data, data + 2)); } TEST(xpath_api_node_set_copy_ctor_out_of_memory) @@ -381,15 +374,7 @@ TEST(xpath_api_node_set_copy_ctor_out_of_memory) test_runner::_memory_fail_threshold = 1; - try - { - xpath_node_set copy = ns; - - CHECK_FORCE_FAIL("Expected out of memory exception"); - } - catch (const std::bad_alloc&) - { - } + CHECK_ALLOC_FAIL(xpath_node_set copy = ns); } TEST_XML(xpath_api_node_set_assign_out_of_memory_preserve, "") @@ -402,19 +387,10 @@ TEST_XML(xpath_api_node_set_assign_out_of_memory_preserve, "") { -- cgit v1.2.3