コード例 #1
0
ファイル: provider.py プロジェクト: d0c-s4vage/syringe
 def test_flatten():
     from array import array
     s = lambda x:array('c',x)
     a = provider.virtual()
     a.available = [0,5]
     a.data = {0:s('hello'),5:s('world')}
     a.flatten(0,5)
     if len(a.data[0]) == 10:
         raise Success
コード例 #2
0
ファイル: provider.py プロジェクト: d0c-s4vage/syringe
    def test_consume():
        s = lambda x:array.array('c',x)

        global a
        a = provider.virtual()
        a.available = [0, 5, 10, 15, 20]
        a.data = {0:s('hello'),5:s('world'),10:s('55555'),15:s('66666'),20:s('77777')}
        a.seek(17)
        if a.consume(5) == '66677':
            raise Success
コード例 #3
0
ファイル: provider.py プロジェクト: d0c-s4vage/syringe
        if a.consume(4) == '0\x82\x02\xf9':
            raise Success

    @TestCase
    def test_base64_write():
        a = base64(testcert, '-----BEGIN', '-----END')
        a.seek(0)
        a.store('XXXXXX')
        if a.value.startswith('XXXXXX'.encode('base64').strip()):
            raise Success

if __name__ == '__main__' and 0:
    import ptype,parray
    import pstruct,parray,pint,provider

    a = provider.virtual()
    a.available = [0,6]
    a.data = {0:'hello',6:'world'}
    print a.available
    print a.data

    @TestCase
    def test_first():
        if a._find(0) == 0:
            raise Success

    @TestCase
    def test_first_2():
        if a._find(3) == 0:
            raise Success