diff options
author | Armin Rigo <arigo@tunes.org> | 2015-05-12 11:07:25 +0200 |
---|---|---|
committer | Armin Rigo <arigo@tunes.org> | 2015-05-12 11:07:25 +0200 |
commit | fe4bb73d2191ea7b2ee5586848e1c5bbbcbaa72b (patch) | |
tree | 5c80d5c2ee50bc8e99039c7483522e2febc08cb7 /testing/cffi0/test_cdata.py | |
parent | 34dbd9932de50a5de29f0fdaab9e9a06526d93a7 (diff) | |
download | cffi-fe4bb73d2191ea7b2ee5586848e1c5bbbcbaa72b.tar.gz |
the big Moving Files Around step
Diffstat (limited to 'testing/cffi0/test_cdata.py')
-rw-r--r-- | testing/cffi0/test_cdata.py | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/testing/cffi0/test_cdata.py b/testing/cffi0/test_cdata.py new file mode 100644 index 0000000..116d0b3 --- /dev/null +++ b/testing/cffi0/test_cdata.py @@ -0,0 +1,39 @@ +import py +from cffi import FFI + +class FakeBackend(object): + + def nonstandard_integer_types(self): + return {} + + def sizeof(self, name): + return 1 + + def load_library(self, path): + return "fake library" + + def new_primitive_type(self, name): + return FakeType("primitive " + name) + + def new_void_type(self): + return FakeType("void") + def new_pointer_type(self, x): + return FakeType('ptr-to-%r' % (x,)) + def new_array_type(self, x, y): + return FakeType('array-from-%r-len-%r' % (x, y)) + def cast(self, x, y): + return 'casted!' + def _get_types(self): + return "CData", "CType" + + +class FakeType(object): + def __init__(self, cdecl): + self.cdecl = cdecl + + +def test_typeof(): + ffi = FFI(backend=FakeBackend()) + clong = ffi.typeof("signed long int") + assert isinstance(clong, FakeType) + assert clong.cdecl == 'primitive long' |