示例#1
0
def test_read_write_string_length():
    img = Image(Section(data=bytearray(32), start_address=0x1000))
    img.write_string(0x1000, 'hello world!!!')
    assert img.read_string(0x1000, length=5) == "hello"
示例#2
0
def test_read_unterminated_string_raises():
    img = Image(Section(data=bytearray(b"\x0a" * 32), start_address=0x1000))
    img.write(0x1000, b'hello')
    with pytest.raises(TypeError):
        data = img.read_string(0x1000)
示例#3
0
def test_read_write_string():
    img = Image(Section(data=bytearray(32), start_address=0x1000))
    img.write_string(0x1000, 'hello')
    assert img.read_string(0x1000) == "hello"