//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //Queue Test //Description: Test suite for the Queue Class. //CS 284 //Programmed by Jonathan Voris //2/28/06 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ class queueTest { public static void main(String[] args) { Queue q = new Queue(); //test initial state System.out.println("Queue is size:" + q.getSize()); System.out.println("Is it empty?:" + q.isEmpty()); System.out.println(); String[] testVars = {"spam", "eggs", "ham", "bacon"}; //test insertions for (int x = 0; x < testVars.length; x++) { q.insert(testVars[x]); System.out.println("Current front:" + q.peek()); System.out.println("Queue is size:" + q.getSize()); System.out.println("Is it empty?:" + q.isEmpty()); System.out.println(); } //test removals, including ones that cause underflow for (int x = 0; x < testVars.length + 1; x++) { try { System.out.println("Just removed:" + (String)q.remove()); System.out.println("Current front:" + q.peek()); } catch (EmptyQueueException eqe) { System.out.println("Exception thrown:" + eqe); } System.out.println("Queue is size:" + q.getSize()); System.out.println("Is it empty?:" + q.isEmpty()); System.out.println(); } } }