[pypy-commit] cffi default: Add a test for another use case

arigo pypy.commits at gmail.com
Fri Jun 3 08:17:22 EDT 2016


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r2705:847bbc0297f8
Date: 2016-06-03 14:18 +0200
http://bitbucket.org/cffi/cffi/changeset/847bbc0297f8/

Log:	Add a test for another use case

diff --git a/c/test_c.py b/c/test_c.py
--- a/c/test_c.py
+++ b/c/test_c.py
@@ -2704,6 +2704,13 @@
     p[1:3] = bytearray(b"XY")
     assert list(p) == [b"f", b"X", b"Y", b".", b"\x00"]
 
+def test_string_assignment_to_byte_array():
+    BByteArray = new_array_type(
+        new_pointer_type(new_primitive_type("unsigned char")), None)
+    p = newp(BByteArray, 5)
+    p[0:3] = bytearray(b"XYZ")
+    assert list(p) == [ord("X"), ord("Y"), ord("Z"), 0, 0]
+
 # XXX hack
 if sys.version_info >= (3,):
     try:


More information about the pypy-commit mailing list