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

Function test_mi_unaligned_base

tests/test_multiple_inheritance.py:274–300  ·  view source on GitHub ↗

Returning an offset (non-first MI) base class pointer should recognize the instance

()

Source from the content-addressed store, hash-verified

272
273
274def test_mi_unaligned_base():
275 """Returning an offset (non-first MI) base class pointer should recognize the instance"""
276
277 n_inst = ConstructorStats.detail_reg_inst()
278
279 c = m.I801C()
280 d = m.I801D()
281 if not env.GRAALPY:
282 # + 4 below because we have the two instances, and each instance has offset base I801B2
283 assert ConstructorStats.detail_reg_inst() == n_inst + 4
284 b1c = m.i801b1_c(c)
285 assert b1c is c
286 b2c = m.i801b2_c(c)
287 assert b2c is c
288 b1d = m.i801b1_d(d)
289 assert b1d is d
290 b2d = m.i801b2_d(d)
291 assert b2d is d
292
293 if env.GRAALPY:
294 pytest.skip("ConstructorStats is incompatible with GraalPy.")
295
296 assert ConstructorStats.detail_reg_inst() == n_inst + 4 # no extra instances
297 del c, b1c, b2c
298 assert ConstructorStats.detail_reg_inst() == n_inst + 2
299 del d, b1d, b2d
300 assert ConstructorStats.detail_reg_inst() == n_inst
301
302
303def test_mi_base_return():

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected