[pypy-commit] cffi default: Improve the tests for the size printed in "owning xx bytes".
arigo
noreply at buildbot.pypy.org
Fri Jul 6 12:06:48 CEST 2012
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r583:c130598379a1
Date: 2012-07-06 12:06 +0200
http://bitbucket.org/cffi/cffi/changeset/c130598379a1/
Log: Improve the tests for the size printed in "owning xx bytes".
diff --git a/c/test_c.py b/c/test_c.py
--- a/c/test_c.py
+++ b/c/test_c.py
@@ -895,7 +895,8 @@
f = callback(BFunc, cb)
s = f(10)
assert typeof(s) is BStruct
- assert repr(s).startswith("<cdata 'struct foo' owning ")
+ assert repr(s) in ["<cdata 'struct foo' owning 12 bytes>",
+ "<cdata 'struct foo' owning 16 bytes>"]
assert s.a == -10
assert s.b == 1E-42
@@ -1276,17 +1277,19 @@
# struct that *also* owns the memory
BStruct = new_struct_type("foo")
BStructPtr = new_pointer_type(BStruct)
- complete_struct_or_union(BStruct, [('a1', new_primitive_type("int"), -1)])
+ complete_struct_or_union(BStruct, [('a1', new_primitive_type("int"), -1),
+ ('a2', new_primitive_type("int"), -1),
+ ('a3', new_primitive_type("int"), -1)])
p = newp(BStructPtr)
- assert repr(p) == "<cdata 'struct foo *' owning 4 bytes>"
+ assert repr(p) == "<cdata 'struct foo *' owning 12 bytes>"
q = p[0]
- assert repr(q) == "<cdata 'struct foo' owning 4 bytes>"
+ assert repr(q) == "<cdata 'struct foo' owning 12 bytes>"
q.a1 = 123456
assert p.a1 == 123456
del p
import gc; gc.collect()
assert q.a1 == 123456
- assert repr(q) == "<cdata 'struct foo' owning 4 bytes>"
+ assert repr(q) == "<cdata 'struct foo' owning 12 bytes>"
assert q.a1 == 123456
def test_nokeepalive_struct():
More information about the pypy-commit
mailing list