You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
92 lines
1.8 KiB
92 lines
1.8 KiB
package solution;
|
|
|
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
|
import org.junit.Test;
|
|
import org.junit.jupiter.api.BeforeEach;
|
|
|
|
public abstract class SimpleListTest90 {
|
|
|
|
ISimpleList<Integer> list;
|
|
ISimpleList<Node<Integer>> nodeList;
|
|
|
|
protected Node<Integer> nodeNull = new Node<Integer>(null);
|
|
protected Node<Integer> node0 = new Node<Integer>(0);
|
|
protected Node<Integer> node1 = new Node<Integer>(1);
|
|
protected Node<Integer> node2 = new Node<Integer>(2);
|
|
protected Node<Integer> node3 = new Node<Integer>(3);
|
|
protected Node<Integer> node4 = new Node<Integer>(4);
|
|
|
|
protected abstract ISimpleList<Integer> getInstance1();
|
|
|
|
protected abstract ISimpleList<Node<Integer>> getInstance2();
|
|
|
|
@BeforeEach
|
|
void setUp() throws Exception{
|
|
list = getInstance1();
|
|
nodeList = getInstance2();
|
|
}
|
|
|
|
@Test
|
|
void testAdd() {
|
|
|
|
boolean actual = nodeList.add(node1);
|
|
assertEquals(true, actual);
|
|
}
|
|
|
|
@Test
|
|
void testRemoveObject() {
|
|
nodeList.add(node1);
|
|
nodeList.add(node2);
|
|
nodeList.add(node3);
|
|
|
|
boolean actual = nodeList.remove(node2);
|
|
assertEquals(true, actual);
|
|
}
|
|
|
|
@Test
|
|
void testContainsTrue() {
|
|
nodeList.add(node1);
|
|
nodeList.add(node2);
|
|
|
|
boolean actual = nodeList.contains(node1);
|
|
assertEquals(true, actual);
|
|
}
|
|
|
|
@Test
|
|
void testContainsFalse() {
|
|
nodeList.add(node1);
|
|
nodeList.add(node2);
|
|
|
|
boolean actual = nodeList.contains(node3);
|
|
assertEquals(false, actual);
|
|
}
|
|
|
|
@Test
|
|
void getNodeIndex() {
|
|
nodeList.add(node1);
|
|
nodeList.add(node2);
|
|
|
|
Node<Integer> actual = nodeList.get(1);
|
|
assertEquals(node2, actual);
|
|
}
|
|
|
|
@Test
|
|
void setNodeIndex() {
|
|
//TODO
|
|
}
|
|
|
|
@Test
|
|
void testRemoveIndex() {
|
|
nodeList.add(node1);
|
|
nodeList.add(node2);
|
|
nodeList.add(node3);
|
|
|
|
boolean actual = nodeList.remove(1);
|
|
assertEquals(true, actual);
|
|
}
|
|
|
|
@Test
|
|
void testAddIndex() {
|
|
//TODO
|
|
}
|
|
}
|
|
|