public void verify() { super.verify(); AbstractTestMap.this.verify(); }
/** * Runs through the regular verifications, but also verifies that * the buffer contains the same elements in the same sequence as the * list. */ public void verify() { super.verify(); Iterator iterator1 = collection.iterator(); Iterator iterator2 = confirmed.iterator(); while (iterator2.hasNext()) { assertTrue(iterator1.hasNext()); Object o1 = iterator1.next(); Object o2 = iterator2.next(); assertEquals(o1, o2); } }
/** * Verifies that the ArrayList has the same elements in the same * sequence as the UnboundedFifoBuffer. */ public void verify() { super.verify(); Iterator iterator1 = collection.iterator(); Iterator iterator2 = confirmed.iterator(); while (iterator2.hasNext()) { assertTrue(iterator1.hasNext()); Object o1 = iterator1.next(); Object o2 = iterator2.next(); assertEquals(o1, o2); } }
/** * Verifies that the ArrayList has the same elements in the same * sequence as the UnboundedFifoBuffer. */ public void verify() { super.verify(); Iterator iterator1 = collection.iterator(); Iterator iterator2 = confirmed.iterator(); while (iterator2.hasNext()) { assertTrue(iterator1.hasNext()); Object o1 = iterator1.next(); Object o2 = iterator2.next(); assertEquals(o1, o2); } }
/** * Runs through the regular verifications, but also verifies that * the buffer contains the same elements in the same sequence as the * list. */ public void verify() { super.verify(); Iterator iterator1 = collection.iterator(); Iterator iterator2 = confirmed.iterator(); while (iterator2.hasNext()) { assertTrue(iterator1.hasNext()); Object o1 = iterator1.next(); Object o2 = iterator2.next(); assertEquals(o1, o2); } }
/** * Runs through the regular verifications, but also verifies that * the buffer contains the same elements in the same sequence as the * list. */ public void verify() { super.verify(); Iterator iterator1 = collection.iterator(); Iterator iterator2 = confirmed.iterator(); while (iterator2.hasNext()) { assertTrue(iterator1.hasNext()); Object o1 = iterator1.next(); Object o2 = iterator2.next(); assertEquals(o1, o2); } }
/** * Tests {@link Collection#isEmpty()}. */ public void testCollectionIsEmpty() { resetEmpty(); assertEquals("New Collection should be empty.", true, collection.isEmpty()); // make sure calls to "isEmpty() don't change anything verify(); resetFull(); assertEquals("Full collection shouldn't be empty", false, collection.isEmpty()); // make sure calls to "isEmpty() don't change anything verify(); }
/** * Provides additional verifications for sets. */ public void verify() { super.verify(); 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())); } }
public void verify() { super.verify(); BinaryHeap heap = (BinaryHeap) collection; Comparator c = heap.m_comparator; if (c == null) c = ComparatorUtils.naturalComparator(); if (!heap.m_isMinHeap) c = ComparatorUtils.reversedComparator(c); Object[] tree = heap.m_elements; for (int i = 1; i <= heap.m_size; i++) { Object parent = tree[i]; if (i * 2 <= heap.m_size) { assertTrue("Parent is less than or equal to its left child", c.compare(parent, tree[i * 2]) <= 0); } if (i * 2 + 1 < heap.m_size) { assertTrue("Parent is less than or equal to its right child", c.compare(parent, tree[i * 2 + 1]) <= 0); } } }
/** * Tests {@link Collection#add(Object)}. */ 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]); verify(); 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]); verify(); if (r) size++; assertEquals("Collection size should grow after add", size, collection.size()); assertTrue("Collection should contain added element", collection.contains(elements[i])); } }
public void verify() { super.verify(); PriorityBuffer heap = (PriorityBuffer) collection; Comparator c = heap.comparator; if (c == null) { c = ComparatorUtils.naturalComparator(); } if (!heap.ascendingOrder) { c = ComparatorUtils.reversedComparator(c); } Object[] tree = heap.elements; for (int i = 1; i <= heap.size; i++) { Object parent = tree[i]; if (i * 2 <= heap.size) { assertTrue("Parent is less than or equal to its left child", c.compare(parent, tree[i * 2]) <= 0); } if (i * 2 + 1 < heap.size) { assertTrue("Parent is less than or equal to its right child", c.compare(parent, tree[i * 2 + 1]) <= 0); } } }
boolean r = collection.addAll(Arrays.asList(elements)); confirmed.addAll(Arrays.asList(elements)); verify(); 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)); verify(); 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())); verify(); if (r) { assertTrue("Size should increase if addAll returns true",
/** * Verifies that the test list implementation matches the confirmed list * implementation. */ public void verify() { super.verify(); List list1 = getList(); List list2 = getConfirmedList(); assertEquals("List should equal confirmed", list1, list2); assertEquals("Confirmed should equal list", list2, list1); assertEquals("Hash codes should be equal", list1.hashCode(), list2.hashCode()); int i = 0; Iterator iterator1 = list1.iterator(); Iterator iterator2 = list2.iterator(); Object[] array = list1.toArray(); while (iterator2.hasNext()) { assertTrue("List iterator should have next", iterator1.hasNext()); Object o1 = iterator1.next(); Object o2 = iterator2.next(); assertEquals("Iterator elements should be equal", o1, o2); o2 = list1.get(i); assertEquals("get should return correct element", o1, o2); o2 = array[i]; assertEquals("toArray should have correct element", o1, o2); i++; } }