Commits

Armin Rigo committed e2d0cba

Import test from hg/cffi/c

Comments (0)

Files changed (1)

pypy/module/_cffi_backend/test/_backend_test_c.py

     x = cast(BArray, 0)
     assert repr(x) == "<cdata 'int[3]' NULL>"
 
+def test_cast_invalid():
+    BStruct = new_struct_type("foo")
+    complete_struct_or_union(BStruct, [])
+    p = cast(new_pointer_type(BStruct), 123456)
+    s = p[0]
+    py.test.raises(TypeError, cast, BStruct, s)
+
 def test_bug_float_convertion():
     BDouble = new_primitive_type("double")
     BDoubleP = new_pointer_type(BDouble)