OrderedCode { public void writeBytesDecreasing(byte[] value) { writeBytes(value, true); } 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 testWriteBytesDecreasing() { byte[] first = {'a', 'b', 'c'}; byte[] second = {'d', 'e', 'f'}; byte[] last = {'x', 'y', 'z'}; OrderedCode orderedCode = new OrderedCode(); orderedCode.writeBytesDecreasing(first); byte[] firstEncoded = orderedCode.getEncodedBytes(); assertArrayEquals(orderedCode.readBytesDecreasing(), first); orderedCode.writeBytesDecreasing(first); orderedCode.writeBytesDecreasing(second); orderedCode.writeBytesDecreasing(last); byte[] allEncoded = orderedCode.getEncodedBytes(); assertArrayEquals(orderedCode.readBytesDecreasing(), first); assertArrayEquals(orderedCode.readBytesDecreasing(), second); assertArrayEquals(orderedCode.readBytesDecreasing(), last); orderedCode = new OrderedCode(firstEncoded); orderedCode.writeBytesDecreasing(second); orderedCode.writeBytesDecreasing(last); assertArrayEquals(orderedCode.getEncodedBytes(), allEncoded); assertArrayEquals(orderedCode.readBytesDecreasing(), first); assertArrayEquals(orderedCode.readBytesDecreasing(), second); assertArrayEquals(orderedCode.readBytesDecreasing(), last); orderedCode = new OrderedCode(allEncoded); assertArrayEquals(orderedCode.readBytesDecreasing(), first); assertArrayEquals(orderedCode.readBytesDecreasing(), second); assertArrayEquals(orderedCode.readBytesDecreasing(), last); }