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
91588cde
Commit
91588cde
authored
Jan 07, 2021
by
Ralf W. Grosse-Kunstleve
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Testing of exceptions not covered by the from-as matrix.
parent
17bc9117
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
0 deletions
+22
-0
tests/core/smart_holder_poc_test.cpp
+22
-0
No files found.
tests/core/smart_holder_poc_test.cpp
View file @
91588cde
...
@@ -310,3 +310,25 @@ TEST_CASE("from_shared_ptr+as_shared_ptr", "[S]") {
...
@@ -310,3 +310,25 @@ TEST_CASE("from_shared_ptr+as_shared_ptr", "[S]") {
hld
.
from_shared_ptr
(
orig_owner
);
hld
.
from_shared_ptr
(
orig_owner
);
REQUIRE
(
*
hld
.
as_shared_ptr
<
int
>
()
==
19
);
REQUIRE
(
*
hld
.
as_shared_ptr
<
int
>
()
==
19
);
}
}
TEST_CASE
(
"error_unpopulated_holder"
,
"[E]"
)
{
smart_holder
hld
;
REQUIRE_THROWS_WITH
(
hld
.
as_raw_ptr_unowned
<
int
>
(),
"Unpopulated holder (as_raw_ptr_unowned)."
);
}
TEST_CASE
(
"error_incompatible_type"
,
"[E]"
)
{
static
int
value
=
19
;
smart_holder
hld
;
hld
.
from_raw_ptr_unowned
(
&
value
);
REQUIRE_THROWS_WITH
(
hld
.
as_unique_ptr
<
std
::
string
>
(),
"Incompatible type (as_unique_ptr)."
);
}
TEST_CASE
(
"error_disowned_holder"
,
"[E]"
)
{
smart_holder
hld
;
hld
.
from_raw_ptr_take_ownership
(
new
int
(
19
));
hld
.
as_unique_ptr
<
int
>
();
REQUIRE_THROWS_WITH
(
hld
.
const_value_ref
<
int
>
(),
"Disowned holder (const_value_ref)."
);
}
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