@Test
public void testInlineDataCommands() throws IOException {

  // We never read "input" so create an single, empty one.
  File inputFile = File.createTempFile("testExample", null);
  FileOutputStream writeInputFile = new FileOutputStream(inputFile);
  writeInputFile.close();
  RandomAccessFile readInputFile = new RandomAccessFile(inputFile, "r");
  // First 5 bytes for copying into each patch
  byte[] magicAndVersion = new byte[] {
      (byte) 0xd1, (byte) 0xff, (byte) 0xd1, (byte) 0xff, (byte) 4 };
  // Use a pseudo random source to fill each data stream differently
  Random random = new Random();
  for (int spanLength = 1; spanLength <= 246; spanLength++) {
    // Generate data array (save for later to compare against output)
    byte[] data = new byte[spanLength];
    random.setSeed(spanLength);
    random.nextBytes(data);
    // The patch will consist of the following data:
    //  magic+version
    //  command "n"
    //  "n" bytes
    //  EOF
    int patchLength = 5 + 1 + spanLength + 1;
    byte[] patch = new byte[patchLength];
    System.arraycopy(magicAndVersion, 0, patch, 0, magicAndVersion.length);
    patch[5] = (byte) spanLength;
    System.arraycopy(data, 0, patch, 6, spanLength);
    patch[6 + spanLength] = 0;  // EOF
    // Create "patch" file - this is just a stream
    ByteArrayInputStream patchStream = new ByteArrayInputStream(patch);
    // Create "output" file - this is just a stream
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream(data.length);
    // Run the patch and check the output file
    long outputLength = Gdiff.patch(readInputFile, patchStream, outputStream, data.length);
    Assert.assertEquals(spanLength, outputLength);
    Assert.assertArrayEquals(data, outputStream.toByteArray());
  }
}