From 97e41de4e292bf0171babc75df65da0023fbd250 Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Thu, 4 Feb 2021 21:36:49 -0800 Subject: [PATCH] Replacing condense_for_macro with much simpler approach. --- tests/pure_cpp/smart_holder_poc_test.cpp | 35 ++++++++---------------- 1 file changed, 12 insertions(+), 23 deletions(-) diff --git a/tests/pure_cpp/smart_holder_poc_test.cpp b/tests/pure_cpp/smart_holder_poc_test.cpp index c61991a28..4d05147a1 100644 --- a/tests/pure_cpp/smart_holder_poc_test.cpp +++ b/tests/pure_cpp/smart_holder_poc_test.cpp @@ -63,12 +63,10 @@ TEST_CASE("from_raw_ptr_unowned+as_unique_ptr", "[E]") { } TEST_CASE("from_raw_ptr_unowned+as_unique_ptr_with_deleter", "[E]") { - static int value = 19; - auto hld = smart_holder::from_raw_ptr_unowned(&value); - auto condense_for_macro = [](smart_holder &hld) { - hld.as_unique_ptr>(); - }; - REQUIRE_THROWS_WITH(condense_for_macro(hld), "Missing unique_ptr deleter (as_unique_ptr)."); + static int value = 19; + auto hld = smart_holder::from_raw_ptr_unowned(&value); + REQUIRE_THROWS_WITH((hld.as_unique_ptr>()), + "Missing unique_ptr deleter (as_unique_ptr)."); } TEST_CASE("from_raw_ptr_unowned+as_shared_ptr", "[S]") { @@ -111,11 +109,9 @@ TEST_CASE("from_raw_ptr_take_ownership+as_unique_ptr2", "[E]") { } TEST_CASE("from_raw_ptr_take_ownership+as_unique_ptr_with_deleter", "[E]") { - auto hld = smart_holder::from_raw_ptr_take_ownership(new int(19)); - auto condense_for_macro = [](smart_holder &hld) { - hld.as_unique_ptr>(); - }; - REQUIRE_THROWS_WITH(condense_for_macro(hld), "Missing unique_ptr deleter (as_unique_ptr)."); + auto hld = smart_holder::from_raw_ptr_take_ownership(new int(19)); + REQUIRE_THROWS_WITH((hld.as_unique_ptr>()), + "Missing unique_ptr deleter (as_unique_ptr)."); } TEST_CASE("from_raw_ptr_take_ownership+as_shared_ptr", "[S]") { @@ -171,10 +167,7 @@ TEST_CASE("from_unique_ptr+as_unique_ptr_with_deleter", "[E]") { std::unique_ptr orig_owner(new int(19)); auto hld = smart_holder::from_unique_ptr(std::move(orig_owner)); REQUIRE(orig_owner.get() == nullptr); - auto condense_for_macro = [](smart_holder &hld) { - hld.as_unique_ptr>(); - }; - REQUIRE_THROWS_WITH(condense_for_macro(hld), + REQUIRE_THROWS_WITH((hld.as_unique_ptr>()), "Incompatible unique_ptr deleter (as_unique_ptr)."); } @@ -224,9 +217,7 @@ TEST_CASE("from_unique_ptr_with_deleter+as_unique_ptr_with_deleter2", "[E]") { std::unique_ptr> orig_owner(new int(19)); auto hld = smart_holder::from_unique_ptr(std::move(orig_owner)); REQUIRE(orig_owner.get() == nullptr); - auto condense_for_macro - = [](smart_holder &hld) { hld.as_unique_ptr>(); }; - REQUIRE_THROWS_WITH(condense_for_macro(hld), + REQUIRE_THROWS_WITH((hld.as_unique_ptr>()), "Incompatible unique_ptr deleter (as_unique_ptr)."); } @@ -261,11 +252,9 @@ TEST_CASE("from_shared_ptr+as_unique_ptr", "[E]") { TEST_CASE("from_shared_ptr+as_unique_ptr_with_deleter", "[E]") { std::shared_ptr orig_owner(new int(19)); - auto hld = smart_holder::from_shared_ptr(orig_owner); - auto condense_for_macro = [](smart_holder &hld) { - hld.as_unique_ptr>(); - }; - REQUIRE_THROWS_WITH(condense_for_macro(hld), "Missing unique_ptr deleter (as_unique_ptr)."); + auto hld = smart_holder::from_shared_ptr(orig_owner); + REQUIRE_THROWS_WITH((hld.as_unique_ptr>()), + "Missing unique_ptr deleter (as_unique_ptr)."); } TEST_CASE("from_shared_ptr+as_shared_ptr", "[S]") {