2024-06-22 06:00:13 +00:00
|
|
|
from __future__ import annotations
|
|
|
|
|
2021-06-19 14:35:20 +00:00
|
|
|
from pybind11_tests import class_sh_shared_ptr_copy_move as m
|
|
|
|
|
|
|
|
|
2021-06-20 07:44:25 +00:00
|
|
|
def test_shptr_copy():
|
2021-06-24 09:54:20 +00:00
|
|
|
txt = m.test_ShPtr_copy()[0].get_history()
|
2021-06-20 07:44:25 +00:00
|
|
|
assert txt == "FooShPtr_copy"
|
2021-06-19 14:35:20 +00:00
|
|
|
|
|
|
|
|
2021-06-20 07:44:25 +00:00
|
|
|
def test_smhld_copy():
|
2021-06-24 09:54:20 +00:00
|
|
|
txt = m.test_SmHld_copy()[0].get_history()
|
2021-06-20 07:44:25 +00:00
|
|
|
assert txt == "FooSmHld_copy"
|
2021-06-19 14:35:20 +00:00
|
|
|
|
|
|
|
|
2021-06-20 07:44:25 +00:00
|
|
|
def test_shptr_move():
|
2021-06-24 09:54:20 +00:00
|
|
|
txt = m.test_ShPtr_move()[0].get_history()
|
2021-06-20 07:44:25 +00:00
|
|
|
assert txt == "FooShPtr_move"
|
2021-06-19 14:35:20 +00:00
|
|
|
|
|
|
|
|
2021-06-20 07:44:25 +00:00
|
|
|
def test_smhld_move():
|
2021-06-24 09:54:20 +00:00
|
|
|
txt = m.test_SmHld_move()[0].get_history()
|
2021-06-20 07:44:25 +00:00
|
|
|
assert txt == "FooSmHld_move"
|
2021-06-29 10:35:50 +00:00
|
|
|
|
|
|
|
|
2021-06-29 10:56:34 +00:00
|
|
|
def _check_property(foo_typ, prop_typ, policy):
|
2021-06-29 10:35:50 +00:00
|
|
|
o = m.Outer()
|
2022-02-15 03:00:40 +00:00
|
|
|
name = f"{foo_typ}_{prop_typ}_{policy}"
|
|
|
|
history = f"Foo{foo_typ}_Outer"
|
2021-06-29 10:35:50 +00:00
|
|
|
f = getattr(o, name)
|
|
|
|
assert f.get_history() == history
|
|
|
|
# and try again to check that o did not get changed
|
|
|
|
f = getattr(o, name)
|
|
|
|
assert f.get_history() == history
|
|
|
|
|
|
|
|
|
|
|
|
def test_properties():
|
|
|
|
for prop_typ in ("readonly", "readwrite", "property_readonly"):
|
|
|
|
for foo_typ in ("ShPtr", "SmHld"):
|
|
|
|
for policy in ("default", "copy", "move"):
|
|
|
|
_check_property(foo_typ, prop_typ, policy)
|