diff --git a/app/src/test/java/ch/nuth/zhaw/exbox/ADS1_2_test.java b/app/src/test/java/ch/nuth/zhaw/exbox/ADS1_2_test.java new file mode 100644 index 0000000..0b23b8a --- /dev/null +++ b/app/src/test/java/ch/nuth/zhaw/exbox/ADS1_2_test.java @@ -0,0 +1,52 @@ +package ch.nuth.zhaw.exbox; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +public class ADS1_2_test { + ListStack stack; + + @BeforeEach + public void setUp() { + stack = new ListStack(); + } + + @Test + public void testPush1() { + stack.push("A"); + Object o = stack.pop(); + assertEquals("A", o); + } + + @Test + public void testPush2() { + stack.push("A"); + stack.push("B"); + assertEquals("B", stack.pop()); + assertEquals("A", stack.pop()); + } + + @Test + public void testIsEmpty() { + assertTrue(stack.isEmpty()); + stack.push("A"); + assertFalse(stack.isEmpty()); + stack.pop(); + assertTrue(stack.isEmpty()); + } + + @Test + public void testIsFull() { + assertFalse(stack.isFull()); + } + + @Test + public void testEmptyPop() { + assertNull(stack.pop()); + } +}