Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import junit.framework.TestCase;
- public class StackTest extends TestCase {
- public void test_empty() {
- Stack<?> stack = new Stack<Object>();
- assertNotNull(stack);
- assertTrue(stack.isEmpty());
- assertEquals(0, stack.size());
- }
- public void test_simple() {
- Stack<Integer> stack = new Stack<Integer>();
- stack.push(1);
- stack.push(2);
- stack.push(3);
- assertFalse(stack.isEmpty());
- assertEquals(3, stack.size());
- assertEquals(new Integer(3), stack.top());
- assertEquals(3, stack.size());
- assertEquals(new Integer(3), stack.pop());
- assertEquals(2, stack.size());
- assertEquals(new Integer(2), stack.pop());
- assertEquals(1, stack.size());
- assertEquals(new Integer(1), stack.pop());
- assertEquals(0, stack.size());
- }
- }
Add Comment
Please, Sign In to add comment