JavaAlgorithms
Elementary and no so elementary Java algorithms
|
00001 00009 package listAlgorithms; 00010 00011 import static org.junit.Assert.*; 00012 00013 import org.junit.Test; 00014 00026 public class TestQueue { 00027 00028 @Test 00029 public void test() { 00030 Character vals[] = new Character[] { 'A', 'B', 'C', 'D', 'E' }; 00031 TwoStackQueue<Character> queue = new TwoStackQueue<Character>(); 00032 for (Character ch : vals) { 00033 queue.enqueue(ch); 00034 } 00035 boolean OK = true; 00036 int ix = 0; 00037 while (queue.peek() != null) { 00038 Character ch = queue.dequeue(); 00039 if (!ch.equals(vals[ix])) { 00040 OK = false; 00041 break; 00042 } 00043 ix++; 00044 } 00045 assertTrue("Queue failed", OK); 00046 } 00047 00048 }