Author: Armin Rigo <[email protected]>
Branch:
Changeset: r493:c02fd3e1bbd9
Date: 2012-06-23 12:23 +0200
http://bitbucket.org/cffi/cffi/changeset/c02fd3e1bbd9/
Log: Test directly cdata_sub().
diff --git a/c/test_c.py b/c/test_c.py
--- a/c/test_c.py
+++ b/c/test_c.py
@@ -353,6 +353,21 @@
assert type(a[0][0]) is int
assert type((a[0] + 0)[0]) is int
+def test_array_sub():
+ BInt = new_primitive_type("int")
+ BArray = new_array_type(new_pointer_type(BInt), 5) # int[5]
+ a = newp(BArray, None)
+ p = a + 1
+ assert p - a == 1
+ assert p - (a+0) == 1
+ assert a == (p - 1)
+ BPtr = new_pointer_type(new_primitive_type("short"))
+ q = newp(BPtr, None)
+ py.test.raises(TypeError, "p - q")
+ py.test.raises(TypeError, "q - p")
+ py.test.raises(TypeError, "a - q")
+ py.test.raises(TypeError, "q - a")
+
def test_cast_primitive_from_cdata():
p = new_primitive_type("int")
n = cast(p, cast(p, -42))
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit