[pypy-commit] cffi default: Add a passing test.
arigo
noreply at buildbot.pypy.org
Tue Jun 26 11:26:11 CEST 2012
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r523:f98fe6c9ad1e
Date: 2012-06-26 11:25 +0200
http://bitbucket.org/cffi/cffi/changeset/f98fe6c9ad1e/
Log: Add a passing test.
diff --git a/c/test_c.py b/c/test_c.py
--- a/c/test_c.py
+++ b/c/test_c.py
@@ -1083,3 +1083,18 @@
BDouble = new_primitive_type("double")
x = cast(BDouble, 42)
py.test.raises(TypeError, newp, new_pointer_type(BCharP), x)
+
+def test_set_struct_fields():
+ BChar = new_primitive_type("char")
+ BCharP = new_pointer_type(BChar)
+ BCharArray10 = new_array_type(BCharP, 10)
+ BStruct = new_struct_type("foo")
+ BStructPtr = new_pointer_type(BStruct)
+ complete_struct_or_union(BStruct, [('a1', BCharArray10, -1)])
+ p = newp(BStructPtr, None)
+ assert str(p.a1) == ''
+ p.a1 = 'foo'
+ assert str(p.a1) == 'foo'
+ assert list(p.a1) == ['f', 'o', 'o'] + ['\x00'] * 7
+ p.a1 = ['x', 'y']
+ assert str(p.a1) == 'xyo'
More information about the pypy-commit
mailing list