Example #1
0
 def test_str_append_data():
     global x
     x = pstr.string(length=5).a
     data = 'hola mundo'
     [x.append(pstr.char_t().set(by)) for by in data]
     if x[5:].serialize() == data.encode('ascii'):
         raise Success
Example #2
0
 def test_str_string():
     x = pstr.string()
     string = "helllo world ok, i'm hungry for some sushi\x00"
     x.length = len(string)/2
     x.source = provider.string(string)
     x.load()
     if x.str() == string[:len(string)/2]:
         raise Success
Example #3
0
 def test_str_set_default():
     data = 'hola'
     x = pstr.string(length=10).a
     if x.serialize() != b'\0\0\0\0\0\0\0\0\0\0':
         raise Failure
     x.set(data)
     if x.serialize() == b'hola\0\0\0\0\0\0':
         raise Success
Example #4
0
 def test_str_set_resized():
     data = 'hola'
     x = pstr.string(length=10).a
     if x.serialize() != b'\0\0\0\0\0\0\0\0\0\0':
         raise Failure
     x.set(data, retain=False)
     if x.serialize() == b'hola':
         raise Success
Example #5
0
 def test_str_string():
     x = pstr.string()
     string = b'helllo world ok, i\'m hungry for some sushi\0'
     x.length = len(string) // 2
     x.source = provider.bytes(string)
     x.load()
     if x.str() == string[:len(string) // 2].decode(x[0].encoding.name):
         raise Success
Example #6
0
 def test_str_string():
     x = pstr.string()
     string = "helllo world ok, i'm hungry for some sushi\x00"
     x.length = len(string)/2
     x.source = provider.string(string)
     x.load()
     if x.str() == string[:len(string)/2]:
         raise Success
Example #7
0
 def test_str_append_data_getoffset():
     x = pstr.string(length=5, offset=0x10).a
     offset = x.append(pstr.char_t().set('F'))
     if offset == x.getoffset() + 5:
         raise Success