[pypy-commit] cffi default: Another few tests, and fix the error message

arigo noreply at buildbot.pypy.org
Sun Jan 11 22:50:31 CET 2015


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r1632:a211e3ed8ba7
Date: 2015-01-11 22:48 +0100
http://bitbucket.org/cffi/cffi/changeset/a211e3ed8ba7/

Log:	Another few tests, and fix the error message

diff --git a/c/_cffi_backend.c b/c/_cffi_backend.c
--- a/c/_cffi_backend.c
+++ b/c/_cffi_backend.c
@@ -4905,7 +4905,7 @@
     accepted_flags = CT_STRUCT | CT_UNION | CT_ARRAY | CT_POINTER;
     if ((cd->c_type->ct_flags & accepted_flags) == 0) {
         PyErr_SetString(PyExc_TypeError,
-                        "expected a 'cdata struct-or-union' object");
+                        "expected a cdata struct/union/array/pointer object");
         return NULL;
     }
     if ((ct->ct_flags & CT_POINTER) == 0) {
diff --git a/c/test_c.py b/c/test_c.py
--- a/c/test_c.py
+++ b/c/test_c.py
@@ -2544,6 +2544,7 @@
     assert typeoffsetof(BStructPtr, 'a2') == (BChar, 1)
     assert typeoffsetof(BStruct, 'a3') == (BChar, 2)
     assert typeoffsetof(BStructPtr, 'a2', 0) == (BChar, 1)
+    assert typeoffsetof(BStruct, u+'a3') == (BChar, 2)
     py.test.raises(TypeError, typeoffsetof, BStructPtr, 'a2', 1)
     py.test.raises(KeyError, typeoffsetof, BStructPtr, 'a4')
     py.test.raises(KeyError, typeoffsetof, BStruct, 'a5')
@@ -2593,6 +2594,15 @@
     #
     d = rawaddressof(BCharP, s, 1)
     assert d == cast(BCharP, p) + 1
+    #
+    e = cast(BCharP, 109238)
+    f = rawaddressof(BCharP, e, 42)
+    assert f == e + 42
+    #
+    BCharA = new_array_type(BCharP, None)
+    e = newp(BCharA, 50)
+    f = rawaddressof(BCharP, e, 42)
+    assert f == e + 42
 
 def test_newp_signed_unsigned_char():
     BCharArray = new_array_type(


More information about the pypy-commit mailing list