OrderedCode { public void writeNumIncreasing(long value) { byte[] bufer = new byte[9]; int len = 0; while (value != 0) { len++; bufer[9 - len] = (byte) (value & 0xff); value >>>= 8; } bufer[9 - len - 1] = (byte) len; len++; byte[] encodedArray = new byte[len]; System.arraycopy(bufer, 9 - len, encodedArray, 0, len); encodedArrays.add(encodedArray); } OrderedCode();  OrderedCode(byte[] encodedByteArray); void writeBytes(byte[] value); void writeBytesDecreasing(byte[] value); void writeNumIncreasing(long value); void writeNumIncreasing(UnsignedInteger unsignedInt); void writeNumDecreasing(long value); void writeNumDecreasing(UnsignedInteger unsignedInt); void writeSignedNumIncreasing(long val); void writeSignedNumDecreasing(long val); void writeInfinity(); void writeInfinityDecreasing(); void writeTrailingBytes(byte[] value); byte[] readBytes(); byte[] readBytesDecreasing(); long readNumIncreasing(); long readNumDecreasing(); long readSignedNumIncreasing(); long readSignedNumDecreasing(); boolean readInfinity(); boolean readInfinityDecreasing(); byte[] readTrailingBytes(); byte[] getEncodedBytes(); boolean hasRemainingEncodedBytes();  }
@Test public void testWriteNumIncreasing() { OrderedCode orderedCode = new OrderedCode(); orderedCode.writeNumIncreasing(0); orderedCode.writeNumIncreasing(1); orderedCode.writeNumIncreasing(Long.MIN_VALUE); orderedCode.writeNumIncreasing(Long.MAX_VALUE); assertEquals(0, orderedCode.readNumIncreasing()); assertEquals(1, orderedCode.readNumIncreasing()); assertEquals(Long.MIN_VALUE, orderedCode.readNumIncreasing()); assertEquals(Long.MAX_VALUE, orderedCode.readNumIncreasing()); }