diff options
author | Arseny Kapoulkine <arseny.kapoulkine@gmail.com> | 2015-04-12 03:05:58 -0700 |
---|---|---|
committer | Arseny Kapoulkine <arseny.kapoulkine@gmail.com> | 2015-04-12 03:05:58 -0700 |
commit | a19da1c246f244da57197915df3ab70f24bf1502 (patch) | |
tree | 08522294870adb468c37042365095ebbae2c0177 /tests/test_xpath.cpp | |
parent | e90d2ac8ba44fbcf4d5702643f708f2c86bde42e (diff) | |
parent | a0d065cd22d1d43c417f6d3db88a04bf57b67ed0 (diff) |
Merge branch 'master' into compact
Diffstat (limited to 'tests/test_xpath.cpp')
-rw-r--r-- | tests/test_xpath.cpp | 72 |
1 files changed, 6 insertions, 66 deletions
diff --git a/tests/test_xpath.cpp b/tests/test_xpath.cpp index f5b4c66..57fa95b 100644 --- a/tests/test_xpath.cpp +++ b/tests/test_xpath.cpp @@ -378,19 +378,7 @@ TEST(xpath_out_of_memory_evaluate_concat) pugi::xpath_query q(query.c_str()); -#ifdef PUGIXML_NO_EXCEPTIONS - CHECK(q.evaluate_string(0, 0, xml_node()) == 1); -#else - try - { - q.evaluate_string(0, 0, xml_node()); - - CHECK_FORCE_FAIL("Expected out of memory exception"); - } - catch (const std::bad_alloc&) - { - } -#endif + CHECK_ALLOC_FAIL(CHECK(q.evaluate_string(0, 0, xml_node()) == 1)); } TEST(xpath_out_of_memory_evaluate_substring) @@ -404,19 +392,7 @@ TEST(xpath_out_of_memory_evaluate_substring) pugi::xpath_query q(query.c_str()); -#ifdef PUGIXML_NO_EXCEPTIONS - CHECK(q.evaluate_string(0, 0, xml_node()) == 1); -#else - try - { - q.evaluate_string(0, 0, xml_node()); - - CHECK_FORCE_FAIL("Expected out of memory exception"); - } - catch (const std::bad_alloc&) - { - } -#endif + CHECK_ALLOC_FAIL(CHECK(q.evaluate_string(0, 0, xml_node()) == 1)); } TEST_XML(xpath_out_of_memory_evaluate_union, "<node><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/></node>") @@ -425,19 +401,7 @@ TEST_XML(xpath_out_of_memory_evaluate_union, "<node><a/><a/><a/><a/><a/><a/><a/> pugi::xpath_query q(STR("a|(a|(a|(a|(a|(a|(a|(a|(a|(a|(a|(a|(a|(a|(a|(a|(a|(a|(a|(a|a)))))))))))))))))))")); -#ifdef PUGIXML_NO_EXCEPTIONS - CHECK(q.evaluate_node_set(doc.child(STR("node"))).empty()); -#else - try - { - q.evaluate_node_set(doc.child(STR("node"))); - - CHECK_FORCE_FAIL("Expected out of memory exception"); - } - catch (const std::bad_alloc&) - { - } -#endif + CHECK_ALLOC_FAIL(CHECK(q.evaluate_node_set(doc.child(STR("node"))).empty())); } TEST_XML(xpath_out_of_memory_evaluate_predicate, "<node><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/></node>") @@ -446,19 +410,7 @@ TEST_XML(xpath_out_of_memory_evaluate_predicate, "<node><a/><a/><a/><a/><a/><a/> pugi::xpath_query q(STR("//a[//a[//a[//a[//a[//a[//a[//a[//a[//a[//a[//a[//a[//a[true()]]]]]]]]]]]]]]")); -#ifdef PUGIXML_NO_EXCEPTIONS - CHECK(q.evaluate_node_set(doc).empty()); -#else - try - { - q.evaluate_node_set(doc); - - CHECK_FORCE_FAIL("Expected out of memory exception"); - } - catch (const std::bad_alloc&) - { - } -#endif + CHECK_ALLOC_FAIL(CHECK(q.evaluate_node_set(doc).empty())); } TEST(xpath_memory_concat_massive) @@ -634,20 +586,8 @@ TEST(xpath_allocate_string_out_of_memory) test_runner::_memory_fail_threshold = 8*1024; -#ifdef PUGIXML_NO_EXCEPTIONS - CHECK(!xpath_query(query.c_str())); -#else - try - { - #ifndef __DMC__ // DigitalMars exception handling crashes instead of catching the exception... - xpath_query q(query.c_str()); - - CHECK_FORCE_FAIL("Expected out of memory exception"); - #endif - } - catch (const std::bad_alloc&) - { - } +#ifndef __DMC__ // DigitalMars exception handling crashes instead of catching the exception... + CHECK_ALLOC_FAIL(CHECK(!xpath_query(query.c_str()))); #endif } |