Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
pybind11
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
pybind11
Commits
69bb05c0
Commit
69bb05c0
authored
Feb 04, 2021
by
Ralf W. Grosse-Kunstleve
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replacing condense_for_macro with much simpler approach.
parent
c3aafe08
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
19 deletions
+8
-19
tests/pure_cpp/smart_holder_poc_test.cpp
+8
-19
No files found.
tests/pure_cpp/smart_holder_poc_test.cpp
View file @
69bb05c0
...
@@ -65,10 +65,8 @@ TEST_CASE("from_raw_ptr_unowned+as_unique_ptr", "[E]") {
...
@@ -65,10 +65,8 @@ TEST_CASE("from_raw_ptr_unowned+as_unique_ptr", "[E]") {
TEST_CASE
(
"from_raw_ptr_unowned+as_unique_ptr_with_deleter"
,
"[E]"
)
{
TEST_CASE
(
"from_raw_ptr_unowned+as_unique_ptr_with_deleter"
,
"[E]"
)
{
static
int
value
=
19
;
static
int
value
=
19
;
auto
hld
=
smart_holder
::
from_raw_ptr_unowned
(
&
value
);
auto
hld
=
smart_holder
::
from_raw_ptr_unowned
(
&
value
);
auto
condense_for_macro
=
[](
smart_holder
&
hld
)
{
REQUIRE_THROWS_WITH
((
hld
.
as_unique_ptr
<
int
,
helpers
::
functor_builtin_delete
<
int
>>
()),
hld
.
as_unique_ptr
<
int
,
helpers
::
functor_builtin_delete
<
int
>>
();
"Missing unique_ptr deleter (as_unique_ptr)."
);
};
REQUIRE_THROWS_WITH
(
condense_for_macro
(
hld
),
"Missing unique_ptr deleter (as_unique_ptr)."
);
}
}
TEST_CASE
(
"from_raw_ptr_unowned+as_shared_ptr"
,
"[S]"
)
{
TEST_CASE
(
"from_raw_ptr_unowned+as_shared_ptr"
,
"[S]"
)
{
...
@@ -112,10 +110,8 @@ TEST_CASE("from_raw_ptr_take_ownership+as_unique_ptr2", "[E]") {
...
@@ -112,10 +110,8 @@ TEST_CASE("from_raw_ptr_take_ownership+as_unique_ptr2", "[E]") {
TEST_CASE
(
"from_raw_ptr_take_ownership+as_unique_ptr_with_deleter"
,
"[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
hld
=
smart_holder
::
from_raw_ptr_take_ownership
(
new
int
(
19
));
auto
condense_for_macro
=
[](
smart_holder
&
hld
)
{
REQUIRE_THROWS_WITH
((
hld
.
as_unique_ptr
<
int
,
helpers
::
functor_builtin_delete
<
int
>>
()),
hld
.
as_unique_ptr
<
int
,
helpers
::
functor_builtin_delete
<
int
>>
();
"Missing unique_ptr deleter (as_unique_ptr)."
);
};
REQUIRE_THROWS_WITH
(
condense_for_macro
(
hld
),
"Missing unique_ptr deleter (as_unique_ptr)."
);
}
}
TEST_CASE
(
"from_raw_ptr_take_ownership+as_shared_ptr"
,
"[S]"
)
{
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]") {
...
@@ -171,10 +167,7 @@ TEST_CASE("from_unique_ptr+as_unique_ptr_with_deleter", "[E]") {
std
::
unique_ptr
<
int
>
orig_owner
(
new
int
(
19
));
std
::
unique_ptr
<
int
>
orig_owner
(
new
int
(
19
));
auto
hld
=
smart_holder
::
from_unique_ptr
(
std
::
move
(
orig_owner
));
auto
hld
=
smart_holder
::
from_unique_ptr
(
std
::
move
(
orig_owner
));
REQUIRE
(
orig_owner
.
get
()
==
nullptr
);
REQUIRE
(
orig_owner
.
get
()
==
nullptr
);
auto
condense_for_macro
=
[](
smart_holder
&
hld
)
{
REQUIRE_THROWS_WITH
((
hld
.
as_unique_ptr
<
int
,
helpers
::
functor_builtin_delete
<
int
>>
()),
hld
.
as_unique_ptr
<
int
,
helpers
::
functor_builtin_delete
<
int
>>
();
};
REQUIRE_THROWS_WITH
(
condense_for_macro
(
hld
),
"Incompatible unique_ptr deleter (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]") {
...
@@ -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
));
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
));
auto
hld
=
smart_holder
::
from_unique_ptr
(
std
::
move
(
orig_owner
));
REQUIRE
(
orig_owner
.
get
()
==
nullptr
);
REQUIRE
(
orig_owner
.
get
()
==
nullptr
);
auto
condense_for_macro
REQUIRE_THROWS_WITH
((
hld
.
as_unique_ptr
<
int
,
helpers
::
functor_other_delete
<
int
>>
()),
=
[](
smart_holder
&
hld
)
{
hld
.
as_unique_ptr
<
int
,
helpers
::
functor_other_delete
<
int
>>
();
};
REQUIRE_THROWS_WITH
(
condense_for_macro
(
hld
),
"Incompatible unique_ptr deleter (as_unique_ptr)."
);
"Incompatible unique_ptr deleter (as_unique_ptr)."
);
}
}
...
@@ -262,10 +253,8 @@ TEST_CASE("from_shared_ptr+as_unique_ptr", "[E]") {
...
@@ -262,10 +253,8 @@ TEST_CASE("from_shared_ptr+as_unique_ptr", "[E]") {
TEST_CASE
(
"from_shared_ptr+as_unique_ptr_with_deleter"
,
"[E]"
)
{
TEST_CASE
(
"from_shared_ptr+as_unique_ptr_with_deleter"
,
"[E]"
)
{
std
::
shared_ptr
<
int
>
orig_owner
(
new
int
(
19
));
std
::
shared_ptr
<
int
>
orig_owner
(
new
int
(
19
));
auto
hld
=
smart_holder
::
from_shared_ptr
(
orig_owner
);
auto
hld
=
smart_holder
::
from_shared_ptr
(
orig_owner
);
auto
condense_for_macro
=
[](
smart_holder
&
hld
)
{
REQUIRE_THROWS_WITH
((
hld
.
as_unique_ptr
<
int
,
helpers
::
functor_builtin_delete
<
int
>>
()),
hld
.
as_unique_ptr
<
int
,
helpers
::
functor_builtin_delete
<
int
>>
();
"Missing unique_ptr deleter (as_unique_ptr)."
);
};
REQUIRE_THROWS_WITH
(
condense_for_macro
(
hld
),
"Missing unique_ptr deleter (as_unique_ptr)."
);
}
}
TEST_CASE
(
"from_shared_ptr+as_shared_ptr"
,
"[S]"
)
{
TEST_CASE
(
"from_shared_ptr+as_shared_ptr"
,
"[S]"
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment