public void testHeap() {
        try {
            new FibonacciHeap(null);
            fail("FibonacciHeap should not allow creation with null comparator");
        } catch(IllegalArgumentException iae) {
            // pass
        }
        
        FibonacciHeap heap = new FibonacciHeap(new IntegerComparator());
        assertTrue(heap.isEmpty()); // should be empty when created
        assertNull(heap.findHighestPrio());
        assertNull(heap.removeHighestPrio());
        
        // test insert, first with something that cannot be comparated
        try {
            heap.insert(new Float(1.0));
            fail("FibonacciHeap should not allow insertion of non-comparable values");
        } catch(IllegalArgumentException iae) {
            // pass
        }
        
        // now with real values
        // first smallest -> biggest
        final int nbrOfValues = 20;
        int expectedSize = 0;
        for (int i = 1; i <= nbrOfValues/2; i++) {
            heap.insert(new Integer(i));
            assertFalse(heap.isEmpty());
            assertEquals(++expectedSize, heap.size());
        }
        // now biggest -> smallest
        for (int i = nbrOfValues; i > nbrOfValues/2; i--) {
            heap.insert(new Integer(i));
            assertFalse(heap.isEmpty());
            assertEquals(++expectedSize, heap.size());
        }
        
        // test peek
        assertEquals(nbrOfValues, ((Integer)heap.findHighestPrio()).intValue());
        
        // test extraction
        for (int i = nbrOfValues; i > 0; i--) {
            Integer intObj = (Integer) heap.removeHighestPrio();
            assertEquals(i, intObj.intValue());
        }
        assertTrue(heap.isEmpty());
        
        // test clear
        for (int i = 0; i < nbrOfValues; i++) {
            heap.insert(new Integer(i));
            assertFalse(heap.isEmpty());
            assertEquals(1, heap.size());
            heap.clear();
            assertTrue(heap.isEmpty());
            assertEquals(0, heap.size());
        }
    }