コード例 #1
0
ファイル: test_image.py プロジェクト: guillermoarb/objutils
def test_read_write_uint64_array():
    img = Image(Section(data=bytearray(128), start_address=0x1000))
    img.write_numeric_array(0x1000, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
                            "uint64_be")
    assert img[0].length == 128
    assert img.read_numeric_array(0x1000, 10, "uint64_be") == (1, 2, 3, 4, 5,
                                                               6, 7, 8, 9, 10)
    img.write_numeric_array(0x1000, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
                            "uint64_le")
    assert img[0].length == 128
    assert img.read_numeric_array(0x1000, 10, "uint64_le") == (1, 2, 3, 4, 5,
                                                               6, 7, 8, 9, 10)
コード例 #2
0
ファイル: test_image.py プロジェクト: guillermoarb/objutils
def test_read_write_int64_array():
    img = Image(Section(data=bytearray(128), start_address=0x1000))
    img.write_numeric_array(0x1000, [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],
                            "int64_be")
    assert img[0].length == 128
    assert img.read_numeric_array(0x1000, 10,
                                  "int64_be") == (-1, -2, -3, -4, -5, -6, -7,
                                                  -8, -9, -10)
    img.write_numeric_array(0x1000, [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],
                            "int64_le")
    assert img[0].length == 128
    assert img.read_numeric_array(0x1000, 10,
                                  "int64_le") == (-1, -2, -3, -4, -5, -6, -7,
                                                  -8, -9, -10)
コード例 #3
0
ファイル: test_image.py プロジェクト: guillermoarb/objutils
def test_read_write_float64_array():
    img = Image(Section(data=bytearray(128), start_address=0x1000))
    img.write_numeric_array(
        0x1000, [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0],
        "float64_be")
    assert img[0].length == 128
    assert img.read_numeric_array(0x1000, 10,
                                  "float64_be") == (1.0, 2.0, 3.0, 4.0, 5.0,
                                                    6.0, 7.0, 8.0, 9.0, 10.0)
    img.write_numeric_array(
        0x1000, [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0],
        "float64_le")
    assert img[0].length == 128
    assert img.read_numeric_array(0x1000, 10,
                                  "float64_le") == (1.0, 2.0, 3.0, 4.0, 5.0,
                                                    6.0, 7.0, 8.0, 9.0, 10.0)
コード例 #4
0
ファイル: test_image.py プロジェクト: guillermoarb/objutils
def test_write_uint8_array_boundary_case4():
    img = Image(Section(data=bytearray(10), start_address=0x1000))
    with pytest.raises(InvalidAddressError):
        img.write_numeric_array(0x0fff, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
                                "uint8_be")
コード例 #5
0
ファイル: test_image.py プロジェクト: guillermoarb/objutils
def test_write_uint8_array_boundary_case2():
    img = Image(Section(data=bytearray(10), start_address=0x1000))
    img.write_numeric_array(0x1005, [1, 2, 3, 4, 5], "uint8_be")
    assert img[0].length == 10
コード例 #6
0
ファイル: test_image.py プロジェクト: guillermoarb/objutils
def test_write_array_data_must_be_iterable():
    img = Image(Section(data=bytearray(32), start_address=0x1000))
    with pytest.raises(TypeError):
        img.write_numeric_array(0x1000, 0x55, "uint8_be")
コード例 #7
0
ファイル: test_image.py プロジェクト: guillermoarb/objutils
def test_write_uint8_array_boundary_case1():
    img = Image(Section(data=bytearray(10), start_address=0x1000))
    img.write_numeric_array(0x1000, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
                            "uint8_be")