[pypy-commit] cffi default: Issue #375

arigo pypy.commits at gmail.com
Wed Aug 8 05:46:50 EDT 2018


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r3137:1dd7bdcf4993
Date: 2018-08-08 11:44 +0200
http://bitbucket.org/cffi/cffi/changeset/1dd7bdcf4993/

Log:	Issue #375

	Port another test from CPython, which also passes already on win64.

diff --git a/testing/cffi0/test_ownlib.py b/testing/cffi0/test_ownlib.py
--- a/testing/cffi0/test_ownlib.py
+++ b/testing/cffi0/test_ownlib.py
@@ -102,6 +102,11 @@
 {
     return (unsigned int)(a + 42);
 }
+
+EXPORT void modify_struct_value(RECT r)
+{
+    r.left = r.right = r.top = r.bottom = 500;
+}
 """
 
 class TestOwnLib(object):
@@ -330,3 +335,25 @@
         assert lib.foo_2bytes(u+'\u1234') == u+'\u125e'
         assert lib.foo_4bytes(u+'\u1234') == u+'\u125e'
         assert lib.foo_4bytes(u+'\U00012345') == u+'\U0001236f'
+
+    def test_modify_struct_value(self):
+        if self.module is None:
+            py.test.skip("fix the auto-generation of the tiny test lib")
+        ffi = FFI(backend=self.Backend())
+        ffi.cdef("""
+            typedef struct {
+                long left;
+                long top;
+                long right;
+                long bottom;
+            } RECT;
+
+            void modify_struct_value(RECT r);
+        """)
+        lib = ffi.dlopen(self.module)
+        s = ffi.new("RECT *", [11, 22, 33, 44])
+        lib.modify_struct_value(s[0])
+        assert s.left == 11
+        assert s.top == 22
+        assert s.right == 33
+        assert s.bottom == 44


More information about the pypy-commit mailing list