diff --git a/tests/test_stl_binders.py b/tests/test_stl_binders.py index c1264c01f2..edfa5a1c2c 100644 --- a/tests/test_stl_binders.py +++ b/tests/test_stl_binders.py @@ -84,6 +84,10 @@ def test_vector_buffer(): mv[2] = '\x06' assert v[2] == 6 + mv = memoryview(b) + v = m.VectorUChar(mv[::2]) + assert v[1] == 3 + with pytest.raises(RuntimeError) as excinfo: m.create_undeclstruct() # Undeclared struct contents, no buffer interface assert "NumPy type info missing for " in str(excinfo.value) @@ -118,6 +122,10 @@ def test_vector_buffer_numpy(): ('y', 'float64'), ('z', 'bool')], align=True))) assert len(v) == 3 + b = np.array([1, 2, 3, 4], dtype=np.uint8) + v = m.VectorUChar(b[::2]) + assert v[1] == 3 + def test_vector_bool(): import pybind11_cross_module_tests as cm