@Test
public void testOpcodes() throws IOException {

  byte[] oldBytes = new byte[] {
      (byte) 'A', (byte) 'B', (byte) 'C', (byte) 'D', (byte) 'E', (byte) 'F', (byte) 'G',
      (byte) 'H', (byte) 'I', (byte) 'J' };
  byte[] newBytes = new byte[] {
      (byte) 'X', (byte) 'Y', (byte) 'Z',
      (byte) 'A', (byte) 'B', (byte) 'B', (byte) 'C', (byte) 'C', (byte) 'D', (byte) 'D',
      (byte) 'E', (byte) 'E', (byte) 'F', (byte) 'F', (byte) 'G', (byte) 'G', (byte) 'H' };
  byte[] patch = new byte[] {
      (byte) 0xd1, (byte) 0xff, (byte) 0xd1, (byte) 0xff, (byte) 4,    // magic+version
      (byte) 1, (byte) 'X',                                            // DATA_MIN (DATA_1)
      (byte) 247, 0, 1, (byte) 'Y',                                    // DATA_USHORT
      (byte) 248, 0, 0, 0, 1, (byte) 'Z',                              // DATA_INT
      (byte) 249, 0, 0, 2,                                             // COPY_USHORT_UBYTE
      (byte) 250, 0, 1, 0, 2,                                          // COPY_USHORT_USHORT
      (byte) 251, 0, 2, 0, 0, 0, 2,                                    // COPY_USHORT_INT
      (byte) 252, 0, 0, 0, 3, 2,                                       // COPY_INT_UBYTE
      (byte) 253, 0, 0, 0, 4, 0, 2,                                    // COPY_INT_USHORT
      (byte) 254, 0, 0, 0, 5, 0, 0, 0, 2,                              // COPY_INT_INT
      (byte) 255, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 2,                  // COPY_LONG_INT
      0 };                                                             // EOF
  // Create "input file".
  File inputFile = File.createTempFile("testExample", null);
  FileOutputStream writeInputFile = new FileOutputStream(inputFile);
  writeInputFile.write(oldBytes);
  writeInputFile.close();
  RandomAccessFile readInputFile = new RandomAccessFile(inputFile, "r");
  // 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(newBytes.length);
  long outputLength = Gdiff.patch(readInputFile, patchStream, outputStream, newBytes.length);
  Assert.assertEquals(newBytes.length, outputLength);
  Assert.assertArrayEquals(newBytes, outputStream.toByteArray());
}