package fr.lifl.stc.stan.test; import fr.lifl.stc.stan.execution.stack.ExecutionStack; import fr.lifl.stc.stan.execution.stack.MultiObject; import junit.framework.TestCase; public class TestExecutionStack extends TestCase { private ExecutionStack stack; protected void setUp() throws Exception { super.setUp(); stack = new ExecutionStack(); } public void testExecutionStack() { ExecutionStack st = new ExecutionStack(); int size = st.size(); assertEquals(0, size); } public void testPush() { int size = stack.size(); stack.push(new MultiObject()); size = stack.size() - size; assertEquals(1, size); } public void testPop() { int size = stack.size(); MultiObject obj = new MultiObject(); stack.push(obj); MultiObject o = stack.pop(); assertEquals(o, obj); assertEquals(size, stack.size()); } public void testPeek() { MultiObject obj = new MultiObject(); stack.push(obj); MultiObject o1 = stack.peek(); MultiObject o2 = stack.pop(); assertEquals(o1, o2); } public void testPeekInt() { MultiObject obj = new MultiObject(); stack.push(obj); for (int i = 0; i < 5; i++) { stack.push(new MultiObject()); } assertEquals(obj, stack.peek(5)); } public void testClone() { for (int i = 0; i < 5; i++) { stack.push(new MultiObject()); } ExecutionStack st = (ExecutionStack)stack.clone(); for (int i = 0; i < stack.size(); i++) { assertEquals(st.peek(i), stack.peek(i)); } } public void testSize() { assertTrue(stack.size() >= 0); } public void testClear() { for (int i = 0; i < 5; i++) { stack.push(new MultiObject()); } stack.clear(); assertEquals(0, stack.size()); } public void testMerge() { for (int i = 0; i < 5; i++) { stack.push(new MultiObject()); } ExecutionStack st = (ExecutionStack)stack.clone(); stack.merge(st); assertTrue(stack.equals(st)); } public void testEqualsObject() { ExecutionStack st = (ExecutionStack)stack.clone(); assertTrue(stack.equals(st)); } }