Advertisement
andrei_gavrila

MIP-02-Tema-03-GenericStackJUnit-Annotation

Oct 26th, 2019
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.16 KB | None | 0 0
  1. package net.forlornly.mip.genericstack;
  2.  
  3. import static org.junit.Assert.assertEquals;
  4. import static org.junit.Assert.assertFalse;
  5. import static org.junit.Assert.assertTrue;
  6.  
  7. import org.junit.Before;
  8. import org.junit.BeforeClass;
  9. import org.junit.Test;
  10.  
  11. /**
  12.  *
  13.  *
  14.  */
  15. public class AppTest {
  16.     private static GenericStack<Integer> gsi;
  17.  
  18.     @BeforeClass
  19.     public static void beforeClass() {
  20.         gsi = new GenericStack<Integer>();
  21.  
  22.     }
  23.  
  24.     @Before
  25.     public void before() {
  26.         gsi.clear();
  27.     }
  28.  
  29.     @Test
  30.     public void testTop() {
  31.         gsi.push(1);
  32.         gsi.push(2);
  33.         gsi.push(3);
  34.  
  35.         assertEquals(new Integer(3), gsi.top());
  36.     }
  37.  
  38.     @Test
  39.     public void testPop() {
  40.         gsi.push(1);
  41.         gsi.push(2);
  42.         gsi.push(3);
  43.  
  44.         assertEquals(new Integer(3), gsi.pop());
  45.         assertEquals(new Integer(2), gsi.pop());
  46.         assertEquals(new Integer(1), gsi.pop());
  47.     }
  48.  
  49.     @Test
  50.     public void testIsEmpty() {
  51.         assertTrue(gsi.isEmpty());
  52.  
  53.         gsi.push(1);
  54.         gsi.push(2);
  55.         gsi.push(3);
  56.  
  57.         assertFalse(gsi.isEmpty());
  58.     }
  59.  
  60.     @Test
  61.     public void testClear() {
  62.         assertTrue(gsi.isEmpty());
  63.  
  64.         gsi.push(1);
  65.         gsi.push(2);
  66.         gsi.push(3);
  67.  
  68.         gsi.clear();
  69.  
  70.         assertTrue(gsi.isEmpty());
  71.     }
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement