diff options
author | Armin Rigo <arigo@tunes.org> | 2016-10-19 09:43:33 +0200 |
---|---|---|
committer | Armin Rigo <arigo@tunes.org> | 2016-10-19 09:43:33 +0200 |
commit | 409cf78412bce61e0772804c8689d631ad2367f3 (patch) | |
tree | b8cf65676f691bc2af358b48bbdca45680441720 /testing/cffi0/test_ffi_backend.py | |
parent | eb2d79451733d2002db087814e7ae2ce78957787 (diff) | |
download | cffi-409cf78412bce61e0772804c8689d631ad2367f3.tar.gz |
Tweaks, and add extra tests, which fail for now :-/
Diffstat (limited to 'testing/cffi0/test_ffi_backend.py')
-rw-r--r-- | testing/cffi0/test_ffi_backend.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/testing/cffi0/test_ffi_backend.py b/testing/cffi0/test_ffi_backend.py index c4435fa..cd7d2ae 100644 --- a/testing/cffi0/test_ffi_backend.py +++ b/testing/cffi0/test_ffi_backend.py @@ -282,10 +282,20 @@ class TestBitfield: ffi.cdef("struct foo_s { int x; int a[]; };") p = ffi.new("struct foo_s *", [100, [200, 300, 400]]) assert p.x == 100 - assert ffi.typeof(p.a) is ffi.typeof("int *") # no length available + assert ffi.typeof(p.a) is ffi.typeof("int[]") + assert len(p.a) == 3 # length recorded assert p.a[0] == 200 assert p.a[1] == 300 assert p.a[2] == 400 + assert list(p.a) == [200, 300, 400] + q = ffi.cast("struct foo_s *", p) + assert q.x == 100 + assert ffi.typeof(q.a) is ffi.typeof("int *") # no length recorded + py.test.raises(TypeError, len, q.a) + assert q.a[0] == 200 + assert q.a[1] == 300 + assert q.a[2] == 400 + py.test.raises(TypeError, list, q.a) @pytest.mark.skipif("sys.platform != 'win32'") def test_getwinerror(self): |