@Test
public void testFirmwareBlocksInvalid() throws ImageParsingException {

    // This test expects the last "invalid" block to be padded with zeros
    FirmwareImage image = new FirmwareImage(rawImageData_invalid, "");
    assertThat(image.block(0)).isEqualTo(intArrayToByteArray(new int[]{
            // Block index (0x0000 little endian)
            0x00, 0x00,
            // Header data
            0x2B, 0x65, 0xFF, 0xFF,
            0x64, 0x00, 0x00, 0x7C,
            0x41, 0x41, 0x41, 0x41,
            0xFF, 0xFF, 0xFF, 0xFF
    }));
    assertThat(image.block(1)).isEqualTo(intArrayToByteArray(new int[]{
            // Block index (0x0001 little endian)
            0x01, 0x00,
            // Block 1 data
            0xFF, 0xFF, 0xFF, 0xFF,
            0xFF, 0xFF, 0xFF, 0xFF,
            0xFF, 0xFF, 0xFF, 0xFF,
            0xFF, 0xFF, 0xFF, 0xFF
    }));
    assertThat(image.block(2)).isEqualTo(intArrayToByteArray(new int[]{
            // Block index (0x0002 little endian)
            0x02, 0x00,
            // 10 Bytes of valid block data
            0xFF, 0xFF,
            0xFF, 0xFF,
            0xFF, 0xFF,
            0xFF, 0xFF,
            0xFF, 0xFF,
            // 6 bytes of zeros because the image is "invalid"
            0x00, 0x00, 0x00, 0x00, 0x00, 0x00
    }));
    // There is no block 3, this should fail
    try {
        image.block(3);
        fail("Shouldn't have worked");
    } catch (Exception e) {
        assertThat(e).isNotNull();
    }
}