[pypy-commit] pypy default: Add the test from CFFI/8d3d149fd8c0.

arigo noreply at buildbot.pypy.org
Sat Sep 22 13:19:21 CEST 2012


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r57472:419a21153544
Date: 2012-09-22 13:19 +0200
http://bitbucket.org/pypy/pypy/changeset/419a21153544/

Log:	Add the test from CFFI/8d3d149fd8c0.

diff --git a/pypy/module/_cffi_backend/test/_backend_test_c.py b/pypy/module/_cffi_backend/test/_backend_test_c.py
--- a/pypy/module/_cffi_backend/test/_backend_test_c.py
+++ b/pypy/module/_cffi_backend/test/_backend_test_c.py
@@ -2180,3 +2180,12 @@
     p = newp(BSCharArray, b"fo\xff")
     assert len(p) == 4
     assert list(p) == [ord("f"), ord("o"), -1, 0]
+
+def test_newp_from_bytearray_doesnt_work():
+    BCharArray = new_array_type(
+        new_pointer_type(new_primitive_type("char")), None)
+    py.test.raises(TypeError, newp, BCharArray, bytearray(b"foo"))
+    p = newp(BCharArray, 4)
+    buffer(p)[:] = bytearray(b"foo\x00")
+    assert len(p) == 4
+    assert list(p) == [b"f", b"o", b"o", b"\x00"]


More information about the pypy-commit mailing list