#include #include "QueueT.h" using namespace std; void RandomTest(); void PrintQueue(QueueT q); void CopyTest(); bool Same(QueueT a, QueueT b); int main() { QueueT q; int i; for(i =0; i < 10; i++) { q.Enqueue(i); } while (q.Size() > 0) { cout << "The queue size is " << q.Size() << endl; cout << "The front of the queue is " << q.Front() << endl; q.Dequeue(); cout << endl << endl; } cout << "Out of the loop, the queue size is " << q.Size() << endl; RandomTest(); CopyTest(); return 0; } void CopyTest(){ QueueT a; QueueT b; int i; for(i = 0; i < 10; i++) { b = a; if (not Same(a,b) ) { cout << "Error in assignment operator for queue of size " << a.Size() << endl; } a.Enqueue(i); } while (b.Size() > 0) { b.Dequeue(); a = b; if (not Same(a,b) ) { cout << "Error in assignment operator for queue of size " << b.Size() << endl; } } } bool Same(QueueT a, QueueT b){ bool final{true}; int data1, data2; cout << "Comparing " ; PrintQueue(a); cout << endl; cout << "To " ; PrintQueue(b); cout << endl; if (a.Size() != b.Size() ) { cout << "Error, the size is not the same " << endl; final = false; } else { while (a.Size() > 0) { data1 = a.Front(); data2 = b.Front(); if (data1 != data2) { cout << "Error, the data is not the same " << endl; final = false; } a.Dequeue(); b.Dequeue(); } } return final; } void PrintQueue(QueueT q){ int data; if (q.Size() != 0) { data= q.Front(); q.Dequeue(); PrintQueue(q); cout << " " << data; } return; } void RandomTest(){ int i; int die; QueueT q; for(i = 0; i < 10; i++) { die = rand() % 2; if (die == 0 and q.Size() > 0) { cout << "Removing " << q.Front() << endl; q.Dequeue(); } else { cout << "Enqueueing " << i << endl; q.Enqueue(i); } cout << "The Queue is now : "; PrintQueue(q); cout << endl; } }