ShortList implements Serializable { public void addIfNotPresent(short key) { if (!contains(key)) { add(key); } } ShortList(int capacity); void add(short key); void addIfNotPresent(short key); int capacity(); void clear(); boolean contains(short key); void copyDataFrom(ShortList that); short get(int i); short removeLast(); short removeRandom(MersenneTwisterFast random); void set(int i, short key); int size(); @Override String toString(); String toString(CoordinateSystem coords); void addAll(ShortSet set);  }
@Test public void testAddIfNotPresent() { list.addIfNotPresent((short)23); list.addIfNotPresent((short)99); list.addIfNotPresent((short)99); list.addIfNotPresent((short)23); assertEquals(2, list.size()); assertEquals(2, list.size()); assertTrue(list.contains((short)23)); assertFalse(list.contains((short)0)); assertEquals("(23, 99)", list.toString()); }