def test_parse_size_ERANGE(size_t_max): input = str(size_t_max + 1).encode() arg = ffi.new('char[]', input) out = ffi.new('size_t *') assert lib.parse_size(arg, out) == -1 assert ffi.errno == errno.ERANGE assert out[0] == 0
def __init__(self, name=None, version=None): self.weakkeydict = weakref.WeakKeyDictionary() init_data = {} if name: init_data['name'] = ffi.new('char[]', name.encode()) if version: init_data['version'] = ffi.new('char[]', version.encode()) self._struct = ffi.new('struct pkg*', init_data) self.weakkeydict[self._struct] = tuple(init_data.values())
def test_joinstring(input): args = [ffi.new('char[]', x) for x in input] args.append(ffi.NULL) result = lib.joinstring(*args) assert ffi.string(result) == b''.join(input)
def test_parse_time(): arg = ffi.new('char[]', b'1448690669') out = ffi.new('time_t *') assert lib.parse_time(arg, out) == 0 assert out[0] == 1448690669
def test_parse_size(): arg = ffi.new('char[]', b'832421') out = ffi.new('size_t *') assert lib.parse_size(arg, out) == 0 assert out[0] == 832421
def test_strstrip(input): arg = ffi.new('char[]', input) result = lib.strstrip(arg) assert ffi.string(result) == input.strip()
def init_parser(self): parser = ffi.new('struct pkginfo_parser*') lib.pkginfo_parser_init(parser) return parser
def init_parser(self): parser = ffi.new('struct desc_parser*') lib.desc_parser_init(parser) return parser