public void verifyAll() { super.verifyAll(); MapAbstractTest.this.verifyAll(); }
/** * Provides additional verifications for sets. */ public void verifyAll() { super.verifyAll(); assertEquals("Sets should be equal", confirmed, collection); assertEquals("Sets should have equal hashCodes", confirmed.hashCode(), collection.hashCode()); Collection set = makeConfirmedCollection(); Iterator iterator = collection.iterator(); while (iterator.hasNext()) { assertTrue("Set.iterator should only return unique elements", set.add(iterator.next())); } }
/** * Tests {@link Collection#isEmpty()}. */ @Test public void testCollectionIsEmpty() { resetEmpty(); assertEquals("New Collection should be empty.", true, collection.isEmpty()); // make sure calls to "isEmpty() don't change anything verifyAll(); resetFull(); assertEquals("Full collection shouldn't be empty", false, collection.isEmpty()); // make sure calls to "isEmpty() don't change anything verifyAll(); }
/** * Tests {@link Collection#add(Object)}. */ @Test public void testCollectionAdd() { if (!isAddSupported()) return; Object[] elements = getFullElements(); for (int i = 0; i < elements.length; i++) { resetEmpty(); boolean r = collection.add(elements[i]); confirmed.add(elements[i]); verifyAll(); assertTrue("Empty collection changed after add", r); assertEquals("Collection size is 1 after first add", 1, collection.size()); } resetEmpty(); int size = 0; for (int i = 0; i < elements.length; i++) { boolean r = collection.add(elements[i]); confirmed.add(elements[i]); verifyAll(); if (r) size++; assertEquals("Collection size should grow after add", size, collection.size()); assertTrue("Collection should contain added element", collection.contains(elements[i])); } }
boolean r = collection.addAll(Arrays.asList(elements)); confirmed.addAll(Arrays.asList(elements)); verifyAll(); assertTrue("Empty collection should change after addAll", r); for (int i = 0; i < elements.length; i++) { r = collection.addAll(Arrays.asList(elements)); confirmed.addAll(Arrays.asList(elements)); verifyAll(); assertTrue("Full collection should change after addAll", r); for (int i = 0; i < elements.length; i++) { r = collection.addAll(Arrays.asList(getFullElements())); confirmed.addAll(Arrays.asList(getFullElements())); verifyAll(); if (r) { assertTrue("Size should increase if addAll returns true",
verifyAll(); verifyAll(); collection.retainAll(Collections.EMPTY_SET)); confirmed.retainAll(Collections.EMPTY_SET); verifyAll(); collection.retainAll(other)); confirmed.retainAll(other); verifyAll(); assertTrue("Collection shouldn't change from retainAll elements", !collection.retainAll(elements)); verifyAll(); assertEquals("Collection size shouldn't change", size, collection.size()); collection.retainAll(elements.subList(min, max))); confirmed.retainAll(elements.subList(min, max)); verifyAll(); assertTrue("Collection shouldn't change from retainAll without " + "duplicate elements", !collection.retainAll(set)); verifyAll(); assertEquals("Collection size didn't change from nonduplicate " + "retainAll", size, collection.size());
public void verifyAll() { super.verifyAll(); MapAbstractTest.this.verifyAll(); }
/** * Tests {@link Collection#isEmpty()}. */ @Test public void testCollectionIsEmpty() { resetEmpty(); assertEquals("New Collection should be empty.", true, collection.isEmpty()); // make sure calls to "isEmpty() don't change anything verifyAll(); resetFull(); assertEquals("Full collection shouldn't be empty", false, collection.isEmpty()); // make sure calls to "isEmpty() don't change anything verifyAll(); }