1 package jodd.util; 2 3 import junit.framework.TestCase; 4 5 public class TestStackQueue extends TestCase { 6 7 public void testQueue() { 8 SimpleQueue sq = new SimpleQueue(); 9 sq.put("Hallo!"); sq.put("Tschuss!"); 11 sq.put("End"); 12 assertEquals("Hallo!", sq.get()); assertEquals("Tschuss!", sq.peek()); 14 assertEquals("Tschuss!", sq.get()); 15 assertFalse(sq.isEmpty()); 16 assertEquals("End", sq.get()); 17 assertTrue(sq.isEmpty()); 18 } 19 20 public void testStack() { 21 SimpleStack ss = new SimpleStack(); 22 ss.push("Start"); 23 ss.push("Hallo!"); 24 ss.push("Tschuss!"); assertEquals("Tschuss!", ss.pop()); assertEquals("Hallo!", ss.peek()); 27 assertEquals("Hallo!", ss.pop()); 28 assertFalse(ss.isEmpty()); 29 assertEquals("Start", ss.pop()); 30 assertTrue(ss.isEmpty()); 31 } 32 33 } 34 | Popular Tags |