/* * Function: BasicPQueueTest * Usage: BasicQueueTest(); * ------------------------ * Runs a test of the PQueue focusing on simple enqueue, dequeueMax. * Reports results of test to cout. */ void BasicPQueueTest() { PQueue pq; cout << boolalpha; // configure stream to print booleans as true/false instead of 1/0 cout << endl << "----------- Testing Basic PQueue functions -----------" << endl; cout << "The pqueue was just created. Is it empty? " << pq.isEmpty() << endl; cout << endl << "Now enqueuing integers from 1 to 10 (increasing order)" << endl; for (int i = 1; i <= 10; i++) pq.enqueue(i); cout << "Pqueue should not be empty. Is it empty? " << pq.isEmpty() << endl; cout << "Pqueue should have size = 10. What is size? " << pq.size() << endl; pq.printDebuggingInfo(); cout << "Dequeuing the top 5 elements: "; for (int j = 0; j < 5; j++) cout << pq.dequeueMax() << " "; cout << endl << "Pqueue should have size = 5. What is size? " << pq.size() << endl; pq.printDebuggingInfo(); cout << endl << "Dequeuing all the rest: "; while (!pq.isEmpty()) cout << pq.dequeueMax() << " "; cout << endl << "Pqueue should be empty. Is it empty? " << pq.isEmpty() << endl; pq.printDebuggingInfo(); cout << endl << "Hit return to continue: "; GetLine(); }