Add tests for the ListStack
class
This commit is contained in:
parent
8aa71b1ee5
commit
0f808a371b
1 changed files with 52 additions and 0 deletions
52
app/src/test/java/ch/nuth/zhaw/exbox/ADS1_2_test.java
Normal file
52
app/src/test/java/ch/nuth/zhaw/exbox/ADS1_2_test.java
Normal file
|
@ -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());
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue