KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jodd > util > TestStackQueue


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!"); // first in
10
sq.put("Tschuss!");
11         sq.put("End");
12         assertEquals("Hallo!", sq.get()); // first out
13
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!"); // last in
25
assertEquals("Tschuss!", ss.pop()); // first out
26
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