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
e82720e5
Commit
e82720e5
authored
Dec 04, 2020
by
Ralf W. Grosse-Kunstleve
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adding test_promotion_of_disowned_to_shared
parent
b0806e76
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
2 deletions
+18
-2
tests/test_variant_unique_shared.cpp
+7
-2
tests/test_variant_unique_shared.py
+11
-0
No files found.
tests/test_variant_unique_shared.cpp
View file @
e82720e5
...
...
@@ -40,8 +40,13 @@ TEST_SUBMODULE(variant_unique_shared, m) {
v
.
get_unique
();
return
;
})
.
def
(
"get_shared"
,
[](
vptr
<
double
>
&
v
)
{
v
.
get_shared
();
.
def
(
"get_shared"
,
[](
vptr
<
double
>
&
v
)
{
v
.
get_shared
();
return
;
})
.
def
(
"disown_unique"
,
[](
vptr
<
double
>
&
v
)
{
v
.
get_unique
().
reset
();
return
;
});
}
...
...
tests/test_variant_unique_shared.py
View file @
e82720e5
...
...
@@ -48,3 +48,14 @@ def test_shared_from_birth():
v
.
get_unique
()
assert
str
(
exc_info
.
value
)
==
"get_unique failure."
v
.
get_shared
()
# Still works.
def
test_promotion_of_disowned_to_shared
():
v
=
m
.
from_unique
()
assert
v
.
get_value
()
==
5
v
.
disown_unique
()
assert
v
.
ownership_type
()
==
0
assert
v
.
get_value
()
==
-
1
v
.
get_shared
()
# Promotion of disowned to shared_ptr.
assert
v
.
ownership_type
()
==
1
assert
v
.
get_value
()
==
-
1
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