示例#1
0
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
示例#2
0
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
示例#3
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())
示例#4
0
文件: wrappers.py 项目: vodik/repose
    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())
示例#5
0
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)
示例#6
0
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
示例#7
0
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
示例#8
0
def test_strstrip(input):
    arg = ffi.new('char[]', input)

    result = lib.strstrip(arg)
    assert ffi.string(result) == input.strip()
示例#9
0
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)
示例#10
0
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
示例#11
0
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
示例#12
0
def test_strstrip(input):
    arg = ffi.new('char[]', input)

    result = lib.strstrip(arg)
    assert ffi.string(result) == input.strip()
示例#13
0
 def init_parser(self):
     parser = ffi.new('struct pkginfo_parser*')
     lib.pkginfo_parser_init(parser)
     return parser
示例#14
0
 def init_parser(self):
     parser = ffi.new('struct pkginfo_parser*')
     lib.pkginfo_parser_init(parser)
     return parser
示例#15
0
文件: test_desc.py 项目: vodik/repose
 def init_parser(self):
     parser = ffi.new('struct desc_parser*')
     lib.desc_parser_init(parser)
     return parser