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
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
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
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
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
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