#include #include "queue.h" using namespace std; void QueueInfo(QueueT q); bool QueueTest(QueueT q, int size, ItemT compare[]); // a bad alternative implementation of a queue. void Add(ItemT l[], int & size, ItemT i); void Delete(ItemT l[], int & size); int main() { ItemT compareData[QUEUE_MAX]; int compareSize = 0; int i; QueueT q; // test the empty queue InitQueue(q); QueueTest(q,compareSize, compareData); //QueueInfo(q); // check a single item Enqueue(q,1); Add(compareData, compareSize, 1); QueueTest(q,compareSize, compareData); // check after the item has been removed again Dequeue(q); Delete(compareData, compareSize); QueueTest(q,compareSize, compareData); // try filling the queue. for(i=0;i 0) { Dequeue(q); Delete(compareData, compareSize); QueueTest(q,compareSize, compareData); } // should not be able to dequeue at this point. cout << "The next thing you see should be an error message " << endl; if (ITEM_DEFAULT != Dequeue(q)) { cout << "Error, default item from empty queue is bad " << endl; } QueueTest(q,compareSize, compareData); cout << endl; return 0; } bool QueueTest(QueueT q, int size, ItemT compare[]){ bool fail = false; QueueT tmp; int i; tmp = q; // check the status values. if (size != Size(q)) { cout << "The size is wrong" << endl; fail = true; } if ((size==0) != IsEmpty(q)) { cout << "The empty status is wrong " << endl; fail = true; } if ((size==QUEUE_MAX) != IsFull(q)) { cout << "The full status is wrong " << endl; fail = true; } for(i=0;i