[pypy-commit] creflect default: more test

arigo noreply at buildbot.pypy.org
Fri Dec 19 17:28:16 CET 2014


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r212:0ef23a1fa399
Date: 2014-12-19 17:13 +0100
http://bitbucket.org/cffi/creflect/changeset/0ef23a1fa399/

Log:	more test

diff --git a/zeffir/test/test_c.py b/zeffir/test/test_c.py
--- a/zeffir/test/test_c.py
+++ b/zeffir/test/test_c.py
@@ -518,3 +518,22 @@
     py.test.raises(TypeError, "a - q")
     e = py.test.raises(TypeError, "q - a")
     assert str(e.value) == "cannot subtract cdata 'short *' and cdata 'int *'"
+
+def test_cast_between_pointers():
+    ffi = support.new_ffi()
+    BIntP = ffi.typeof("int *")
+    a = ffi.new("int[]", [40, 41, 42, 43, 44])
+    b = ffi.cast("short *", a)
+    c = ffi.cast(BIntP, b)
+    assert c[3] == 43
+    d = ffi.cast("long long", c)
+    e = ffi.cast(BIntP, d)
+    assert e[3] == 43
+    f = ffi.cast(BIntP, d)
+    assert f[3] == 43
+    #
+    b = ffi.cast("short *", 0)
+    assert not b
+    c = ffi.cast(BIntP, b)
+    assert not c
+    assert ffi.cast("long long", c) == 0


More information about the pypy-commit mailing list