ArrayEncoders { public static int[] deltaEncode(int[] intArray) { int[] out = new int[intArray.length]; System.arraycopy(intArray, 0, out, 0, intArray.length); for (int i = out.length-1; i > 0; i--) { out[i] = out[i] - out[i-1]; } return out; }  static int[] deltaEncode(int[] intArray); static int[] runlengthEncode(int[] intArray);  }
@Test public void deltaDecodeTest() { int[] inputData = {15,18,118,117,128,132}; int[] outputDataTest = {15,3,100,-1,11,4}; int[] outputData = ArrayEncoders.deltaEncode(inputData); assertArrayEquals(outputDataTest, outputData); }
@Test public void emptyDeltaDecodeTest() { int[] inputData = {}; int[] outputDataTest = {}; int[] outputData = ArrayEncoders.deltaEncode(inputData); assertArrayEquals(outputDataTest, outputData); }