diff options
author | ali-beep <54114435+ali-beep@users.noreply.github.com> | 2019-08-15 13:41:12 -0400 |
---|---|---|
committer | Wenzel Jakob <wenzel.jakob@epfl.ch> | 2019-08-15 19:41:11 +0200 |
commit | 5ef13eb680069680c41e89265d4f1105bd501846 (patch) | |
tree | 7e78747fd9032b25110e1a3f02cd653f1fdc1963 /tests/test_stl_binders.py | |
parent | b2fdfd122827c1170c75702c05a4040997cf3bf5 (diff) | |
download | platform_external_python_pybind11-5ef13eb680069680c41e89265d4f1105bd501846.tar.gz platform_external_python_pybind11-5ef13eb680069680c41e89265d4f1105bd501846.tar.bz2 platform_external_python_pybind11-5ef13eb680069680c41e89265d4f1105bd501846.zip |
Add negative indexing support to stl_bind. (#1882)
Diffstat (limited to 'tests/test_stl_binders.py')
-rw-r--r-- | tests/test_stl_binders.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/test_stl_binders.py b/tests/test_stl_binders.py index 52c8ac0..6d5a159 100644 --- a/tests/test_stl_binders.py +++ b/tests/test_stl_binders.py @@ -53,6 +53,16 @@ def test_vector_int(): v_int2.extend(x for x in range(5)) assert v_int2 == m.VectorInt([0, 99, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4]) + # test negative indexing + assert v_int2[-1] == 4 + + # insert with negative index + v_int2.insert(-1, 88) + assert v_int2 == m.VectorInt([0, 99, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 88, 4]) + + # delete negative index + del v_int2[-1] + assert v_int2 == m.VectorInt([0, 99, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 88]) # related to the PyPy's buffer protocol. @pytest.unsupported_on_pypy |