1 3 package jodd.util; 4 5 import junit.framework.TestCase; 6 import jodd.util.collection.SimpleQueue; 7 import jodd.util.collection.SimpleStack; 8 9 public class StackQueueTest extends TestCase { 10 11 public void testQueue() { 12 SimpleQueue sq = new SimpleQueue(); 13 assertEquals(0, sq.size()); 14 sq.put("Hallo!"); assertEquals(1, sq.size()); 16 sq.put("Tschuss!"); 17 assertEquals(2, sq.size()); 18 sq.put("End"); 19 assertEquals(3, sq.size()); 20 assertEquals("Hallo!", sq.get()); assertEquals(2, sq.size()); 22 assertEquals("Tschuss!", sq.peek()); 23 assertEquals(2, sq.size()); 24 assertEquals("Tschuss!", sq.get()); 25 assertEquals(1, sq.size()); 26 assertFalse(sq.isEmpty()); 27 assertEquals("End", sq.get()); 28 assertEquals(0, sq.size()); 29 assertTrue(sq.isEmpty()); 30 } 31 32 public void testStack() { 33 SimpleStack ss = new SimpleStack(); 34 assertEquals(0, ss.size()); 35 ss.push("Start"); 36 assertEquals(1, ss.size()); 37 ss.push("Hallo!"); 38 assertEquals(2, ss.size()); 39 ss.push("Tschuss!"); assertEquals(3, ss.size()); 41 assertEquals("Tschuss!", ss.pop()); assertEquals(2, ss.size()); 43 assertEquals("Hallo!", ss.peek()); 44 assertEquals(2, ss.size()); 45 assertEquals("Hallo!", ss.pop()); 46 assertEquals(1, ss.size()); 47 assertFalse(ss.isEmpty()); 48 assertEquals("Start", ss.pop()); 49 assertEquals(0, ss.size()); 50 assertTrue(ss.isEmpty()); 51 } 52 53 } 54 | Popular Tags |