@Test
public void testApplyPatch_NewLengthTooLarge() throws Exception {

  createEmptyOldFile(10);
  InputStream patchIn =
      makePatch(
          SIGNATURE,
          Integer.MAX_VALUE + 1, // newLength (max supported is Integer.MAX_VALUE)
          10, // diffSegmentLength
          0, // copySegmentLength
          0, // offsetToNextInput
          new byte[10] // addends
          );
  ByteArrayOutputStream newData = new ByteArrayOutputStream();
  try {
    BsPatch.applyPatch(
        new RandomAccessFile(oldFile, "r"), newData, patchIn);
    Assert.fail("Read patch with excessive newLength");
  } catch (PatchFormatException expected) {
    // No way to mock the internal logic, so resort to testing exception string for coverage
    String actual = expected.getMessage();
    Assert.assertEquals("bad newSize", actual);
  }
}