@Test public void testEqualCosts2() { testEqualCosts2(createMinHeap(true)); testEqualCosts2(createMinHeap(false)); testEqualCosts2(createWrappedMinHeap(true)); testEqualCosts2(createWrappedMinHeap(false)); }
@Test public void testAdd() { testAdd(createMinHeap(true)); testAdd(createMinHeap(false)); testAdd(createWrappedMinHeap(true)); testAdd(createWrappedMinHeap(false)); }
@Test public void testAdd_Null() { testAdd_Null(createMinHeap(true)); testAdd_Null(createMinHeap(false)); testAdd_Null(createWrappedMinHeap(true)); testAdd_Null(createWrappedMinHeap(false)); }
@Test public void testIterator_ConcurrentModification_poll() { testIterator_ConcurrentModification_poll(createMinHeap(true)); testIterator_ConcurrentModification_poll(createMinHeap(false)); testIterator_ConcurrentModification_poll(createWrappedMinHeap(true)); testIterator_ConcurrentModification_poll(createWrappedMinHeap(false)); }
@Test public void testIterator_ConcurrentModification_remove() { testIterator_ConcurrentModification_remove(createMinHeap(true)); testIterator_ConcurrentModification_remove(createMinHeap(false)); testIterator_ConcurrentModification_remove(createWrappedMinHeap(true)); testIterator_ConcurrentModification_remove(createWrappedMinHeap(false)); }
@Test public void testOddOrder() { testOddOrder(createMinHeap(true)); testOddOrder(createMinHeap(false)); testOddOrder(createWrappedMinHeap(true)); testOddOrder(createWrappedMinHeap(false)); }
@Test public void testExceedCapacity() { testExceedCapacity(createMinHeap(true)); testExceedCapacity(createMinHeap(false)); testExceedCapacity(createWrappedMinHeap(true)); testExceedCapacity(createWrappedMinHeap(false)); }
@Test public void testEqualCosts() { testEqualCosts(createMinHeap(true)); testEqualCosts(createMinHeap(false)); testEqualCosts(createWrappedMinHeap(true)); testEqualCosts(createWrappedMinHeap(false)); }
@Test public void testIterator_ConcurrentModification_add() { testIterator_ConcurrentModification_add(createMinHeap(true)); testIterator_ConcurrentModification_add(createMinHeap(false)); testIterator_ConcurrentModification_add(createWrappedMinHeap(true)); testIterator_ConcurrentModification_add(createWrappedMinHeap(false)); }
@Test public void testRemoveAndAdd_LowerPriority() { testRemoveAndAdd_LowerPriority(createMinHeap(true)); testRemoveAndAdd_LowerPriority(createMinHeap(false)); testRemoveAndAdd_LowerPriority(createWrappedMinHeap(true)); testRemoveAndAdd_LowerPriority(createWrappedMinHeap(false)); }
@Test // increase priority -> decrease key since it is a min-heap public void testIncreasePriority() { testIncreasePriority(createMinHeap(true)); testIncreasePriority(createMinHeap(false)); testIncreasePriority(createWrappedMinHeap(true)); testIncreasePriority(createWrappedMinHeap(false)); }
@Test public void testRemoveAndAdd_HigherPriority() { testRemoveAndAdd_HigherPriority(createMinHeap(true)); testRemoveAndAdd_HigherPriority(createMinHeap(false)); testRemoveAndAdd_HigherPriority(createWrappedMinHeap(true)); testRemoveAndAdd_HigherPriority(createWrappedMinHeap(false)); }
@Test public void testPoll() { testPoll(createMinHeap(true)); testPoll(createMinHeap(false)); testPoll(createWrappedMinHeap(true)); testPoll(createWrappedMinHeap(false)); }
@Test public void testPoll2() { testPoll2(createMinHeap(true)); testPoll2(createMinHeap(false)); testPoll2(createWrappedMinHeap(true)); testPoll2(createWrappedMinHeap(false)); }
@Test public void testIterator_RemoveUnsupported() { testIterator_RemoveUnsupported(createMinHeap(true)); testIterator_RemoveUnsupported(createMinHeap(false)); testIterator_RemoveUnsupported(createWrappedMinHeap(true)); testIterator_RemoveUnsupported(createWrappedMinHeap(false)); }
@Test public void testIterator() { testIterator(createMinHeap(true)); testIterator(createMinHeap(false)); testIterator(createWrappedMinHeap(true)); testIterator(createWrappedMinHeap(false)); }
@Test public void testRemove() { testRemove(createMinHeap(true)); testRemove(createMinHeap(false)); testRemove(createWrappedMinHeap(true)); testRemove(createWrappedMinHeap(false)); }
private void testOddOrder(MinHeap<HasIndex> pq) { DummyHeapEntry entry0 = new DummyHeapEntry(0); DummyHeapEntry entry1 = new DummyHeapEntry(1); DummyHeapEntry entry2 = new DummyHeapEntry(2); DummyHeapEntry entry3 = new DummyHeapEntry(3); pq.add(entry0, 0.0); pq.add(entry3, 3.0); pq.add(entry1, 1.0); pq.add(entry2, 2.0); assertEqualsHE(entry0, pq.poll()); assertEqualsHE(entry1, pq.poll()); assertEqualsHE(entry2, pq.poll()); assertEqualsHE(entry3, pq.poll()); Assert.assertNull(pq.poll()); }
pq.add(entry2, 6.0); Collection<?> coll = getIteratorCollection(pq.iterator()); Assert.assertEquals(3, coll.size()); Assert.assertTrue(coll.contains(entry0)); coll = getIteratorCollection(pq.iterator()); Assert.assertEquals(2, coll.size()); Assert.assertFalse(coll.contains(entry0)); coll = getIteratorCollection(pq.iterator()); Assert.assertEquals(2, coll.size()); coll = getIteratorCollection(pq.iterator()); Assert.assertEquals(2, coll.size()); Assert.assertTrue(coll.contains(entry1)); assertEqualsHE(entry1, pq.poll()); assertEqualsHE(entry2, pq.poll()); Assert.assertNull(pq.poll());
private void testAdd_Null(MinHeap<HasIndex> pq) { try { pq.add(null, 1.0); Assert.fail("missing NullPointerException."); } catch (NullPointerException e) { log.info("catched expected exception. ", e); } Assert.assertEquals(0, pq.size()); Assert.assertEquals(0, iteratorElementCount(pq.iterator())); }