@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();
assertTrue(Arrays.equals(orderedCode.readBytesDecreasing(), first));
orderedCode.writeBytesDecreasing(first);
orderedCode.writeBytesDecreasing(second);
orderedCode.writeBytesDecreasing(last);
byte[] allEncoded = orderedCode.getEncodedBytes();
assertTrue(Arrays.equals(orderedCode.readBytesDecreasing(), first));
assertTrue(Arrays.equals(orderedCode.readBytesDecreasing(), second));
assertTrue(Arrays.equals(orderedCode.readBytesDecreasing(), last));
orderedCode = new OrderedCode(firstEncoded);
orderedCode.writeBytesDecreasing(second);
orderedCode.writeBytesDecreasing(last);
assertTrue(Arrays.equals(orderedCode.getEncodedBytes(), allEncoded));
assertTrue(Arrays.equals(orderedCode.readBytesDecreasing(), first));
assertTrue(Arrays.equals(orderedCode.readBytesDecreasing(), second));
assertTrue(Arrays.equals(orderedCode.readBytesDecreasing(), last));
orderedCode = new OrderedCode(allEncoded);
assertTrue(Arrays.equals(orderedCode.readBytesDecreasing(), first));
assertTrue(Arrays.equals(orderedCode.readBytesDecreasing(), second));
assertTrue(Arrays.equals(orderedCode.readBytesDecreasing(), last));
}