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

Function test_ref_qualified_noexcept_def_buffer

tests/test_buffers.py:454–471  ·  view source on GitHub ↗

Test issue #2234 follow-up: def_buffer with noexcept ref-qualified member pointers. Covers: - def_buffer(Return (Class::*)(Args...) & noexcept) - def_buffer(Return (Class::*)(Args...) const & noexcept)

()

Source from the content-addressed store, hash-verified

452 reason="Requires __cpp_noexcept_function_type",
453)
454def test_ref_qualified_noexcept_def_buffer():
455 """Test issue #2234 follow-up: def_buffer with noexcept ref-qualified member pointers.
456
457 Covers:
458 - def_buffer(Return (Class::*)(Args...) & noexcept)
459 - def_buffer(Return (Class::*)(Args...) const & noexcept)
460 """
461 nbuf = m.OneDBufferLRefNoexcept(3)
462 narr = np.frombuffer(nbuf, dtype=np.float32)
463 assert narr.shape == (3,)
464 narr[2] = 7.0
465 narr2 = np.frombuffer(nbuf, dtype=np.float32)
466 assert narr2[2] == pytest.approx(7.0)
467
468 ncbuf = m.OneDBufferConstLRefNoexcept(2)
469 ncarr = np.frombuffer(ncbuf, dtype=np.float32)
470 assert ncarr.shape == (2,)
471 assert ncarr.flags["WRITEABLE"] is False

Callers

nothing calls this directly

Calls 2

Tested by

no test coverage detected