Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
gaoqiong
pybind11
Commits
01cacaf2
Commit
01cacaf2
authored
Jan 07, 2021
by
Ralf W. Grosse-Kunstleve
Browse files
Testing of exceptions not covered by the from-as matrix.
parent
04a95684
Changes
1
Show 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
tests/core/smart_holder_poc_test.cpp
+22
-0
No files found.
tests/core/smart_holder_poc_test.cpp
View file @
01cacaf2
...
...
@@ -310,3 +310,25 @@ TEST_CASE("from_shared_ptr+as_shared_ptr", "[S]") {
hld
.
from_shared_ptr
(
orig_owner
);
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