/** * Tests {@link Collection#size()}. */ @Test public void testCollectionSize() { resetEmpty(); assertEquals("Size of new Collection is 0.", 0, collection.size()); resetFull(); assertTrue("Size of full collection should be greater than zero", collection.size() > 0); }
/** * Tests {@code toString} on a collection. */ @Test public void testCollectionToString() { resetEmpty(); assertTrue("toString shouldn't return null", collection.toString() != null); resetFull(); assertTrue("toString shouldn't return null", collection.toString() != null); }
/** * Test {@link Collection#clear()}. */ @Test public void testCollectionClear() { if (!isRemoveSupported()) return; resetEmpty(); collection.clear(); // just to make sure it doesn't raise anything verifyAll(); resetFull(); collection.clear(); confirmed.clear(); 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])); } }
resetEmpty(); Iterator it1 = collection.iterator(); assertEquals("Iterator for empty Collection shouldn't have 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(); }
resetEmpty(); Object[] a = new Object[] { new Object(), null, null }; Object[] array = collection.toArray(a);
resetEmpty(); assertEquals("Empty Collection should return empty array for toArray", 0, collection.toArray().length);
if (!isAddSupported()) return; resetEmpty(); Object[] elements = getFullElements(); boolean r = collection.addAll(Arrays.asList(elements));
if (!isRemoveSupported()) return; resetEmpty(); try { collection.iterator().remove();
resetEmpty(); Collection col = new HashSet(); assertTrue("Every Collection should contain all elements of an " +
if (!isRemoveSupported()) return; resetEmpty(); assertTrue("Emtpy collection removeAll should return false for " + "empty input",
if (isAddSupported()) return; resetEmpty(); try { collection.add(new Object());
if (!isRemoveSupported()) return; resetEmpty(); List elements = Arrays.asList(getFullElements()); List other = Arrays.asList(getOtherElements());
if (isRemoveSupported()) return; resetEmpty(); try { collection.clear();
if (!isRemoveSupported()) return; resetEmpty(); Object[] elements = getFullElements(); for (int i = 0; i < elements.length; i++) {
Object[] elements; resetEmpty(); elements = getFullElements(); for(int i = 0; i < elements.length; i++) {
/** * Tests {@link Collection#size()}. */ @Test public void testCollectionSize() { resetEmpty(); assertEquals("Size of new Collection is 0.", 0, collection.size()); resetFull(); assertTrue("Size of full collection should be greater than zero", collection.size() > 0); }
/** * Tests {@code toString} on a collection. */ @Test public void testCollectionToString() { resetEmpty(); assertTrue("toString shouldn't return null", collection.toString() != null); resetFull(); assertTrue("toString shouldn't return null", collection.toString() != null); }
/** * Test {@link Collection#clear()}. */ @Test public void testCollectionClear() { if (!isRemoveSupported()) return; resetEmpty(); collection.clear(); // just to make sure it doesn't raise anything verifyAll(); resetFull(); collection.clear(); confirmed.clear(); verifyAll(); }