Support more natural syntax for vector extend
diff --git a/tests/test_stl_binders.py b/tests/test_stl_binders.py
index 0030924..52c8ac0 100644
--- a/tests/test_stl_binders.py
+++ b/tests/test_stl_binders.py
@@ -11,6 +11,10 @@
assert len(v_int) == 2
assert bool(v_int) is True
+ # test construction from a generator
+ v_int1 = m.VectorInt(x for x in range(5))
+ assert v_int1 == m.VectorInt([0, 1, 2, 3, 4])
+
v_int2 = m.VectorInt([0, 0])
assert v_int == v_int2
v_int2[1] = 1
@@ -33,6 +37,22 @@
del v_int2[0]
assert v_int2 == m.VectorInt([0, 99, 2, 3])
+ v_int2.extend(m.VectorInt([4, 5]))
+ assert v_int2 == m.VectorInt([0, 99, 2, 3, 4, 5])
+
+ v_int2.extend([6, 7])
+ assert v_int2 == m.VectorInt([0, 99, 2, 3, 4, 5, 6, 7])
+
+ # test error handling, and that the vector is unchanged
+ with pytest.raises(RuntimeError):
+ v_int2.extend([8, 'a'])
+
+ assert v_int2 == m.VectorInt([0, 99, 2, 3, 4, 5, 6, 7])
+
+ # test extending from a generator
+ 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])
+
# related to the PyPy's buffer protocol.
@pytest.unsupported_on_pypy