Ejemplo n.º 1
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)
Ejemplo n.º 2
0
def test_write_boundary_case1():
    img = Image(Section(data=bytearray(5), start_address=0x1000))
    img.write(0x1000, b'hello')
Ejemplo n.º 3
0
def test_write_boundary_case3():
    img = Image(Section(data=bytearray(5), start_address=0x1000))
    with pytest.raises(InvalidAddressError):
        img.write(0x0fff, b'hello')
Ejemplo n.º 4
0
def test_read_write():
    img = Image(Section(data=bytearray(32), start_address=0x1000))
    img.write(0x1000, b'hello')
    assert img.read(0x1000, 5) == b"hello"