Beispiel #1
0
def test_write_float64_negative_offset():
    img = Image(Section(data=bytearray(10), start_address=0x1000))
    with pytest.raises(InvalidAddressError):
        img.write_numeric(0x0fff, 3.14159, "float64_le")
Beispiel #2
0
def test_write_int32_negative_offset():
    img = Image(Section(data=bytearray(10), start_address=0x1000))
    with pytest.raises(InvalidAddressError):
        img.write_numeric(0x0fff, 0xff, "int32_le")
Beispiel #3
0
def test_read_write_int64():
    img = Image(Section(data=bytearray(32), start_address=0x1000))
    img.write_numeric(0x1000, -200000000000, "int64_be")
    assert img.read_numeric(0x1000, "int64_be") == -200000000000
    img.write_numeric(0x1000, -200000000000, "int64_le")
    assert img.read_numeric(0x1000, "int64_le") == -200000000000
Beispiel #4
0
def test_read_write_float64():
    img = Image(Section(data=bytearray(32), start_address=0x1000))
    img.write_numeric(0x1000, 1234.5678, "float64_be")
    assert img.read_numeric(0x1000, "float64_be") == 1234.5678
    img.write_numeric(0x1000, 1234.5678, "float64_le")
    assert img.read_numeric(0x1000, "float64_le") == 1234.5678
Beispiel #5
0
def test_read_write_uint32():
    img = Image(Section(data=bytearray(32), start_address=0x1000))
    img.write_numeric(0x1000, 0x55555555, "uint32_be")
    assert img.read_numeric(0x1000, "uint32_be") == 0x55555555
    img.write_numeric(0x1000, 0x55555555, "uint32_le")
    assert img.read_numeric(0x1000, "uint32_le") == 0x55555555