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)
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)
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)
def test_read_uint8_array_boundary_case4(): img = Image(Section(data=bytearray(10), start_address=0x1000)) with pytest.raises(InvalidAddressError): img.read_numeric_array(0x0fff, 5, "uint8_be") == (0, 0, 0, 0, 0)
def test_read_uint8_array_boundary_case2(): img = Image(Section(data=bytearray(10), start_address=0x1000)) assert img.read_numeric_array(0x1005, 5, "uint8_be") == (0, 0, 0, 0, 0)