def test_sizeof_type(self):
ffi = FFI(backend=self.Backend())
ffi.cdef("""
struct foo { int a; short b, c, d; };
union foo { int a; short b, c, d; };
""")
for c_type, expected_size in [
('char', 1),
('unsigned int', 4),
('char *', SIZE_OF_PTR),
('int[5]', 20),
('struct foo', 12),
('union foo', 4),
]:
size = ffi.sizeof(c_type)
assert size == expected_size, (size, expected_size, ctype)
评论列表
文章目录