MCPcopy Create free account
hub / github.com/pybind/pybind11 / test_unique_ptr_roundtrip

Function test_unique_ptr_roundtrip

tests/test_class_sh_basic.py:138–149  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

136
137
138def test_unique_ptr_roundtrip():
139 # Multiple roundtrips to stress-test instance registration/deregistration.
140 num_round_trips = 1000
141 recycled = m.atyp("passenger")
142 for _ in range(num_round_trips):
143 id_orig = id(recycled)
144 recycled = m.unique_ptr_roundtrip(recycled)
145 assert re.match("passenger(_MvCtor)*_MvCtor", m.get_mtxt(recycled))
146 id_rtrn = id(recycled)
147 # Ensure the returned object is a different Python instance.
148 assert id_rtrn != id_orig
149 id_orig = id_rtrn
150
151
152def test_pass_unique_ptr_cref():

Callers

nothing calls this directly

Calls 1

atypMethod · 0.80

Tested by

no test coverage detected