Author: Armin Rigo <ar...@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 _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit