committed by
chris
2 changed files with 107 additions and 59 deletions
@ -1,8 +1,11 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<classpath> |
|||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/> |
|||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"> |
|||
<attributes> |
|||
<attribute name="module" value="true"/> |
|||
</attributes> |
|||
</classpathentry> |
|||
<classpathentry kind="src" path="src"/> |
|||
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/5"/> |
|||
<classpathentry kind="lib" path="C:/Users/planuser/Downloads/2017_WS_OOP_90.jar"/> |
|||
<classpathentry kind="output" path="bin"/> |
|||
</classpath> |
|||
|
@ -1,92 +1,137 @@ |
|||
package solution; |
|||
|
|||
import static org.junit.jupiter.api.Assertions.assertEquals; |
|||
import org.junit.Test; |
|||
import org.junit.jupiter.api.BeforeAll; |
|||
import org.junit.jupiter.api.BeforeEach; |
|||
import org.junit.jupiter.api.Test; |
|||
|
|||
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(); |
|||
ISimpleList<String> list; |
|||
|
|||
protected abstract ISimpleList<Node<Integer>> getInstance2(); |
|||
protected String nodeNull = null; |
|||
protected String node0 = "0"; |
|||
protected String node1 = "1"; |
|||
protected String node2 = "2"; |
|||
protected String node3 = "3"; |
|||
protected String node4 = "4"; |
|||
|
|||
protected abstract ISimpleList<String> getInstance1(); |
|||
|
|||
protected void add2() { |
|||
list.add(node1); |
|||
list.add(node2); |
|||
} |
|||
|
|||
@BeforeAll |
|||
static void setUpBeforeClass() throws Exception { |
|||
} |
|||
|
|||
@BeforeEach |
|||
void setUp() throws Exception{ |
|||
void setUp() throws Exception { |
|||
list = getInstance1(); |
|||
nodeList = getInstance2(); |
|||
} |
|||
|
|||
|
|||
@Test |
|||
void testAdd() { |
|||
|
|||
boolean actual = nodeList.add(node1); |
|||
public void testAdd1() { |
|||
boolean actual = list.add(node1); |
|||
assertEquals(true, actual); |
|||
} |
|||
|
|||
|
|||
@Test |
|||
void testRemoveObject() { |
|||
nodeList.add(node1); |
|||
nodeList.add(node2); |
|||
nodeList.add(node3); |
|||
|
|||
boolean actual = nodeList.remove(node2); |
|||
public void testAdd2() { |
|||
add2(); |
|||
list.remove(node2); |
|||
list.add(node3); |
|||
list.add(node4); |
|||
String actual = list.get(2); |
|||
assertEquals(node3, actual); |
|||
} |
|||
|
|||
@Test |
|||
public void testRemoveObject() { |
|||
list.add(node1); |
|||
list.add(node2); |
|||
list.add(node3); |
|||
|
|||
boolean actual = list.remove(node2); |
|||
assertEquals(true, actual); |
|||
} |
|||
|
|||
|
|||
@Test |
|||
public void testRemoveSize() { |
|||
add2(); |
|||
list.remove(1); |
|||
int actual = list.size(); |
|||
assertEquals(1, actual); |
|||
} |
|||
|
|||
@Test |
|||
void testContainsTrue() { |
|||
nodeList.add(node1); |
|||
nodeList.add(node2); |
|||
|
|||
boolean actual = nodeList.contains(node1); |
|||
public void testContainsTrue() { |
|||
add2(); |
|||
boolean actual = list.contains(node1); |
|||
assertEquals(true, actual); |
|||
} |
|||
|
|||
|
|||
@Test |
|||
void testContainsFalse() { |
|||
nodeList.add(node1); |
|||
nodeList.add(node2); |
|||
|
|||
boolean actual = nodeList.contains(node3); |
|||
public void testContainsFalse() { |
|||
add2(); |
|||
boolean actual = list.contains(node3); |
|||
assertEquals(false, actual); |
|||
} |
|||
|
|||
|
|||
@Test |
|||
void getNodeIndex() { |
|||
nodeList.add(node1); |
|||
nodeList.add(node2); |
|||
|
|||
Node<Integer> actual = nodeList.get(1); |
|||
public void testForAll1() { |
|||
list.forAll(null); |
|||
assertEquals(true, true); |
|||
} |
|||
|
|||
@Test |
|||
public void getNodeIndex() { |
|||
add2(); |
|||
String actual = list.get(1); |
|||
assertEquals(node2, actual); |
|||
} |
|||
|
|||
|
|||
@Test |
|||
void setNodeIndex() { |
|||
//TODO
|
|||
public void setNodeIndex() { |
|||
add2(); |
|||
list.set(1, node3); |
|||
String actual = list.get(1); |
|||
assertEquals(node3, actual); |
|||
} |
|||
|
|||
|
|||
@Test |
|||
void testRemoveIndex() { |
|||
nodeList.add(node1); |
|||
nodeList.add(node2); |
|||
nodeList.add(node3); |
|||
|
|||
boolean actual = nodeList.remove(1); |
|||
public void testRemoveIndex() { |
|||
add2(); |
|||
list.add(node3); |
|||
boolean actual = list.remove(1); |
|||
assertEquals(true, actual); |
|||
} |
|||
|
|||
|
|||
@Test |
|||
public void testAddIndexException() { |
|||
try { |
|||
list.add(-1, node1); |
|||
list.get(0); |
|||
} catch (Exception e) { |
|||
assertEquals(true, e instanceof IndexOutOfBoundsException); |
|||
} |
|||
} |
|||
|
|||
@Test |
|||
public void testAddIndexSameSize() { |
|||
add2(); |
|||
list.add(2, node4); |
|||
String actual = list.get(2); |
|||
assertEquals(node4, actual); |
|||
} |
|||
|
|||
@Test |
|||
void testAddIndex() { |
|||
//TODO
|
|||
public void testAddIndexNewNode() { |
|||
add2(); |
|||
list.add(1, node3); |
|||
String actual = list.get(1); |
|||
assertEquals(node3, actual); |
|||
} |
|||
} |
|||
|
Loading…
Reference in new issue