[pypy-commit] cffi cffi-1.0: A few more small tests
arigo
noreply at buildbot.pypy.org
Sat May 9 12:50:21 CEST 2015
Author: Armin Rigo <arigo at tunes.org>
Branch: cffi-1.0
Changeset: r1945:2ea81fd4c7a9
Date: 2015-05-09 12:50 +0200
http://bitbucket.org/cffi/cffi/changeset/2ea81fd4c7a9/
Log: A few more small tests
diff --git a/_cffi1/test_ffi_obj.py b/_cffi1/test_ffi_obj.py
--- a/_cffi1/test_ffi_obj.py
+++ b/_cffi1/test_ffi_obj.py
@@ -162,3 +162,19 @@
ffi = _cffi1_backend.FFI()
a = ffi.new("signed char[]", [5, 6, 7])
assert ffi.buffer(a)[:] == '\x05\x06\x07'
+
+def test_ffi_from_buffer():
+ import array
+ ffi = _cffi1_backend.FFI()
+ a = array.array('H', [10000, 20000, 30000])
+ c = ffi.from_buffer(a)
+ assert ffi.typeof(c) is ffi.typeof("char[]")
+ ffi.cast("unsigned short *", c)[1] += 500
+ assert list(a) == [10000, 20500, 30000]
+
+def test_ffi_types():
+ CData = _cffi1_backend.FFI.CData
+ CType = _cffi1_backend.FFI.CType
+ ffi = _cffi1_backend.FFI()
+ assert isinstance(ffi.cast("int", 42), CData)
+ assert isinstance(ffi.typeof("int"), CType)
More information about the pypy-commit
mailing list