public void testAdd_Null() { PseudoRemovePriorityQueue<Integer> pq = new PseudoRemovePriorityQueue<Integer>(10); try { pq.add(null, 1.0); fail("missing NullPointerException."); } catch (NullPointerException e) { log.info("catched expected exception. ", e); } assertEquals(0, pq.size()); assertEquals(0, iteratorElementCount(pq.iterator())); }
public void testAdd() { PseudoRemovePriorityQueue<Integer> pq = new PseudoRemovePriorityQueue<Integer>(10); assertEquals(0, pq.size()); pq.add(Integer.valueOf(1), 1.0); assertEquals(1, pq.size()); pq.add(Integer.valueOf(2), 2.0); assertEquals(2, pq.size()); pq.add(Integer.valueOf(3), 2.0); // different element with same priority assertEquals(3, pq.size()); pq.add(Integer.valueOf(3), 3.0); // same element with different priority assertEquals(3, pq.size()); // should not be added! assertEquals(3, iteratorElementCount(pq.iterator())); }