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
3cf4db18
Commit
3cf4db18
authored
Dec 04, 2020
by
Ralf W. Grosse-Kunstleve
Browse files
adding test_promotion_of_disowned_to_shared
parent
76e77701
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
2 deletions
+18
-2
tests/test_variant_unique_shared.cpp
tests/test_variant_unique_shared.cpp
+7
-2
tests/test_variant_unique_shared.py
tests/test_variant_unique_shared.py
+11
-0
No files found.
tests/test_variant_unique_shared.cpp
View file @
3cf4db18
...
@@ -40,9 +40,14 @@ TEST_SUBMODULE(variant_unique_shared, m) {
...
@@ -40,9 +40,14 @@ TEST_SUBMODULE(variant_unique_shared, m) {
v
.
get_unique
();
v
.
get_unique
();
return
;
return
;
})
})
.
def
(
"get_shared"
,
[](
vptr
<
double
>
&
v
)
{
.
def
(
"get_shared"
,
[](
vptr
<
double
>
&
v
)
{
v
.
get_shared
();
v
.
get_shared
();
return
;
return
;
})
.
def
(
"disown_unique"
,
[](
vptr
<
double
>
&
v
)
{
v
.
get_unique
().
reset
();
return
;
});
});
}
}
...
...
tests/test_variant_unique_shared.py
View file @
3cf4db18
...
@@ -48,3 +48,14 @@ def test_shared_from_birth():
...
@@ -48,3 +48,14 @@ def test_shared_from_birth():
v
.
get_unique
()
v
.
get_unique
()
assert
str
(
exc_info
.
value
)
==
"get_unique failure."
assert
str
(
exc_info
.
value
)
==
"get_unique failure."
v
.
get_shared
()
# Still works.
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