### Question:
RoaringArray implements Cloneable, Externalizable, AppendableStorage<Container> { @Override public void append(char key, Container value) { if (size > 0 && key < keys[size - 1]) { throw new IllegalArgumentException("append only: " + (key) + " < " + (keys[size - 1])); } extendArray(1); keys[size] = key; values[size] = value; size++; } protected  RoaringArray();   RoaringArray(int initialCapacity);   RoaringArray(char[] keys, Container[] values, int size); @Override void append(char key, Container value); void trim(); @Override RoaringArray clone(); void deserialize(DataInput in); void deserialize(DataInput in, byte[] buffer); void deserialize(ByteBuffer bbf); @Override boolean equals(Object o); ContainerPointer getContainerPointer(); ContainerPointer getContainerPointer(final int startIndex); @Override int hashCode(); @Override void readExternal(ObjectInput in); void serialize(DataOutput out); void serialize(ByteBuffer buffer); int serializedSizeInBytes(); @Override void writeExternal(ObjectOutput out); int first(); int last();  }### Answer:
@Test public void whenAppendEmpty_ShouldBeUnchanged() { RoaringArray array = new RoaringArray(); array.keys = new char[2]; array.values = new Container[2]; array.size = 1; RoaringArray appendage = new RoaringArray(); appendage.size = 0; appendage.keys = new char[4]; appendage.values = new Container[4]; array.append(appendage); assertEquals(1, array.size); assertEquals(2, array.keys.length); }
@Test public void whenAppendToEmpty_ShouldEqualAppendage() { RoaringArray array = new RoaringArray(); array.size = 0; array.keys = new char[4]; array.values = new Container[4]; RoaringArray appendage = new RoaringArray(); appendage.size = 3; appendage.keys = new char[4]; appendage.values = new Container[4]; array.append(appendage); assertEquals(3, array.size); assertEquals(4, array.keys.length); }
@Test public void whenAppendNonEmpty_SizeShouldEqualSumOfSizes() { RoaringArray array = new RoaringArray(); array.size = 2; array.keys = new char[]{0, 2, 0, 0}; array.values = new Container[4]; RoaringArray appendage = new RoaringArray(); appendage.size = 3; appendage.keys = new char[]{5, 6, 7, 0}; appendage.values = new Container[4]; array.append(appendage); assertEquals(5, array.size); }
@Test public void whenAppendNonEmpty_ResultantKeysShouldBeMonotonic() { RoaringArray array = new RoaringArray(); array.size = 2; array.keys = new char[]{0, 2, 0, 0}; array.values = new Container[4]; RoaringArray appendage = new RoaringArray(); appendage.size = 3; appendage.keys = new char[]{5, 6, 7, 0}; appendage.values = new Container[4]; array.append(appendage); assertArrayEquals(new char[] {0, 2, 5, 6, 7}, array.keys); }