package esimene; import static org.junit.Assert.*; import org.junit.Before; import org.junit.Test; public class PinuTest { Pinu p; @Before public void setUp() throws Exception { p=new Pinu(); } @Test public void testSize() { assertEquals(0, p.size()); p.push(4); assertEquals(1, p.size()); p.push(5); assertEquals(2, p.size()); p.pop(); assertEquals(1, p.size()); p.pop(); assertEquals(0, p.size()); } @Test public void testValues(){ p.push(6); p.push(3); assertEquals(new Integer(3), p.pop()); assertEquals(new Integer(6), p.pop()); } public void testPeek(){ p.push(7); assertEquals(new Integer(7), p.peek()); p.push(12); assertEquals(new Integer(12), p.peek()); assertEquals(2, p.size()); assertEquals(new Integer(12), p.peek()); } @Test(expected = IllegalStateException.class) public void testStatePop(){ p.pop(); } @Test(expected = IllegalStateException.class) public void testStatePeek(){ p.peek(); } }