Code example for PriorityQueue

Methods: comparator, size

0
        assertNotNull(queue);
        assertEquals(0, queue.size());
        assertNull(queue.comparator());
 
        MockComparator<Object> comparator = new MockComparator<Object>();
        queue = new PriorityQueue<Object>(100, comparator);
        assertNotNull(queue);
        assertEquals(0, queue.size());
        assertEquals(comparator, queue.comparator());
    } 
 
    /** 
     * @tests java.util.PriorityQueue#PriorityQueue(int, Comparator<? super E>) 
     */ 
    public void test_ConstructorILjava_util_Comparator_illegalCapacity() { 
        try { 
            new PriorityQueue<Object>(0, new MockComparator<Object>());
            fail("should throw IllegalArgumentException");
        } catch (IllegalArgumentException e) {
            // expected 
        }