mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-11 16:13:53 +00:00
adding test_promotion_of_disowned_to_shared
This commit is contained in:
parent
76e7770134
commit
3cf4db18ed
@ -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;
|
||||
});
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user