### Question:
HashSet extends Set<E> { @Override public int size() { return backingMap.size(); } HashSet();  HashSet(int capacity);  HashSet(int capacity, float loadFactor);  HashSet(Collection<E> collection);  HashSet(E... args);   HashSet(HashMap<E, HashSet<E>> backingMap); @Override boolean add(E object); @Override void clear(); @Override boolean contains(E object); @Override boolean isEmpty(); @Override Iterator<E> iterator(); @Override boolean remove(E object); @Override int size();  }### Answer:
@Test public void testConstructor() { HashSet<Object> hs2 = new HashSet<Object>(); assertEquals("Created incorrect HashSet", 0, hs2.size()); }
@Test public void testConstructorSize() { HashSet<Object> hs2 = new HashSet<Object>(5); assertEquals("Created incorrect HashSet", 0, hs2.size()); try { new HashSet<Object>(-1); fail("Failed to throw IllegalArgumentException for capacity < 0"); } catch (ProgrammerError e) { } }
@Test public void testConstructorLoadFactor() { HashSet<Object> hs2 = new HashSet<Object>(5, (float) 0.5); assertEquals("Created incorrect HashSet", 0, hs2.size()); try { new HashSet<Object>(0, 0); fail("Failed to throw IllegalArgumentException for initial load factor <= 0"); } catch (ProgrammerError e) { } }
@Test public void testSize() { assertTrue("Returned incorrect size", hs.size() == objArray.length); hs.clear(); assertEquals("Cleared set returned non-zero size", 0, hs.size()); }