mirror of
https://github.com/pybind/pybind11.git
synced 2025-03-12 07:49:28 +00:00
Replacing condense_for_macro with much simpler approach.
This commit is contained in:
parent
1dcf115b22
commit
97e41de4e2
@ -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<int, helpers::functor_builtin_delete<int>>();
|
||||
};
|
||||
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<int, helpers::functor_builtin_delete<int>>()),
|
||||
"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<int, helpers::functor_builtin_delete<int>>();
|
||||
};
|
||||
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<int, helpers::functor_builtin_delete<int>>()),
|
||||
"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<int> 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<int, helpers::functor_builtin_delete<int>>();
|
||||
};
|
||||
REQUIRE_THROWS_WITH(condense_for_macro(hld),
|
||||
REQUIRE_THROWS_WITH((hld.as_unique_ptr<int, helpers::functor_builtin_delete<int>>()),
|
||||
"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<int, helpers::functor_builtin_delete<int>> 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<int, helpers::functor_other_delete<int>>(); };
|
||||
REQUIRE_THROWS_WITH(condense_for_macro(hld),
|
||||
REQUIRE_THROWS_WITH((hld.as_unique_ptr<int, helpers::functor_other_delete<int>>()),
|
||||
"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<int> 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<int, helpers::functor_builtin_delete<int>>();
|
||||
};
|
||||
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<int, helpers::functor_builtin_delete<int>>()),
|
||||
"Missing unique_ptr deleter (as_unique_ptr).");
|
||||
}
|
||||
|
||||
TEST_CASE("from_shared_ptr+as_shared_ptr", "[S]") {
|
||||
|
Loading…
Reference in New Issue
Block a user