2 changed files with 107 additions and 59 deletions
			
			
		| @ -1,8 +1,11 @@ | |||||
| <?xml version="1.0" encoding="UTF-8"?> | <?xml version="1.0" encoding="UTF-8"?> | ||||
| <classpath> | <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="src" path="src"/> | ||||
| 	<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/5"/> | 	<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"/> | 	<classpathentry kind="output" path="bin"/> | ||||
| </classpath> | </classpath> | ||||
|  | |||||
| @ -1,92 +1,137 @@ | |||||
| package solution; | package solution; | ||||
| 
 | 
 | ||||
| import static org.junit.jupiter.api.Assertions.assertEquals; | 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.BeforeEach; | ||||
|  | import org.junit.jupiter.api.Test; | ||||
| 
 | 
 | ||||
| public abstract class SimpleListTest90 { | public abstract class SimpleListTest90 { | ||||
| 
 | 
 | ||||
| 	ISimpleList<Integer> list; | 	ISimpleList<String> list; | ||||
| 	ISimpleList<Node<Integer>> nodeList; |  | ||||
| 
 | 
 | ||||
| 	protected Node<Integer> nodeNull = new Node<Integer>(null); | 	protected String nodeNull = null; | ||||
| 	protected Node<Integer> node0 = new Node<Integer>(0); | 	protected String node0 = "0"; | ||||
| 	protected Node<Integer> node1 = new Node<Integer>(1); | 	protected String node1 = "1"; | ||||
| 	protected Node<Integer> node2 = new Node<Integer>(2); | 	protected String node2 = "2"; | ||||
| 	protected Node<Integer> node3 = new Node<Integer>(3); | 	protected String node3 = "3"; | ||||
| 	protected Node<Integer> node4 = new Node<Integer>(4); | 	protected String node4 = "4"; | ||||
| 
 | 
 | ||||
| 	protected abstract ISimpleList<Integer> getInstance1(); | 	protected abstract ISimpleList<String> getInstance1(); | ||||
| 
 | 
 | ||||
| 	protected abstract ISimpleList<Node<Integer>> getInstance2(); | 	protected void add2() { | ||||
|  | 		list.add(node1); | ||||
|  | 		list.add(node2); | ||||
|  | 	} | ||||
|  | 
 | ||||
|  | 	@BeforeAll | ||||
|  | 	static void setUpBeforeClass() throws Exception { | ||||
|  | 	} | ||||
| 
 | 
 | ||||
| 	@BeforeEach | 	@BeforeEach | ||||
| 	void setUp() throws Exception{ | 	void setUp() throws Exception { | ||||
| 		list = getInstance1(); | 		list = getInstance1(); | ||||
| 		nodeList = getInstance2(); |  | ||||
| 	} | 	} | ||||
| 
 | 
 | ||||
| 	@Test | 	@Test | ||||
| 	void testAdd() { | 	public void testAdd1() { | ||||
| 		 | 		boolean actual = list.add(node1); | ||||
| 		boolean actual = nodeList.add(node1); |  | ||||
| 		assertEquals(true, actual); | 		assertEquals(true, actual); | ||||
| 	} | 	} | ||||
| 
 | 
 | ||||
| 	@Test | 	@Test | ||||
| 	void testRemoveObject() { | 	public void testAdd2() { | ||||
| 		nodeList.add(node1); | 		add2(); | ||||
| 		nodeList.add(node2); | 		list.remove(node2); | ||||
| 		nodeList.add(node3); | 		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 = nodeList.remove(node2); | 		boolean actual = list.remove(node2); | ||||
| 		assertEquals(true, actual); | 		assertEquals(true, actual); | ||||
| 	} | 	} | ||||
| 
 | 
 | ||||
| 	@Test | 	@Test | ||||
| 	void testContainsTrue() { | 	public void testRemoveSize() { | ||||
| 		nodeList.add(node1); | 		add2(); | ||||
| 		nodeList.add(node2); | 		list.remove(1); | ||||
|  | 		int actual = list.size(); | ||||
|  | 		assertEquals(1, actual); | ||||
|  | 	} | ||||
| 
 | 
 | ||||
| 		boolean actual = nodeList.contains(node1); | 	@Test | ||||
|  | 	public void testContainsTrue() { | ||||
|  | 		add2(); | ||||
|  | 		boolean actual = list.contains(node1); | ||||
| 		assertEquals(true, actual); | 		assertEquals(true, actual); | ||||
| 	} | 	} | ||||
| 
 | 
 | ||||
| 	@Test | 	@Test | ||||
| 	void testContainsFalse() { | 	public void testContainsFalse() { | ||||
| 		nodeList.add(node1); | 		add2(); | ||||
| 		nodeList.add(node2); | 		boolean actual = list.contains(node3); | ||||
| 		 |  | ||||
| 		boolean actual = nodeList.contains(node3); |  | ||||
| 		assertEquals(false, actual); | 		assertEquals(false, actual); | ||||
| 	} | 	} | ||||
| 
 | 
 | ||||
| 	@Test | 	@Test | ||||
| 	void getNodeIndex() { | 	public void testForAll1() { | ||||
| 		nodeList.add(node1); | 		list.forAll(null); | ||||
| 		nodeList.add(node2); | 		assertEquals(true, true); | ||||
|  | 	} | ||||
| 
 | 
 | ||||
| 		Node<Integer> actual = nodeList.get(1); | 	@Test | ||||
|  | 	public void getNodeIndex() { | ||||
|  | 		add2(); | ||||
|  | 		String actual = list.get(1); | ||||
| 		assertEquals(node2, actual); | 		assertEquals(node2, actual); | ||||
| 	} | 	} | ||||
| 
 | 
 | ||||
| 	@Test | 	@Test | ||||
| 	void setNodeIndex() { | 	public void setNodeIndex() { | ||||
| 		//TODO
 | 		add2(); | ||||
|  | 		list.set(1, node3); | ||||
|  | 		String actual = list.get(1); | ||||
|  | 		assertEquals(node3, actual); | ||||
| 	} | 	} | ||||
| 
 | 
 | ||||
| 	@Test | 	@Test | ||||
| 	void testRemoveIndex() { | 	public void testRemoveIndex() { | ||||
| 		nodeList.add(node1); | 		add2(); | ||||
| 		nodeList.add(node2); | 		list.add(node3); | ||||
| 		nodeList.add(node3); | 		boolean actual = list.remove(1); | ||||
| 		 |  | ||||
| 		boolean actual = nodeList.remove(1); |  | ||||
| 		assertEquals(true, actual); | 		assertEquals(true, actual); | ||||
| 	} | 	} | ||||
| 
 | 
 | ||||
| 	@Test | 	@Test | ||||
| 	void testAddIndex() { | 	public void testAddIndexException() { | ||||
| 		//TODO
 | 		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 | ||||
|  | 	public void testAddIndexNewNode() { | ||||
|  | 		add2(); | ||||
|  | 		list.add(1, node3); | ||||
|  | 		String actual = list.get(1); | ||||
|  | 		assertEquals(node3, actual); | ||||
| 	} | 	} | ||||
| } | } | ||||
|  | |||||
					Loading…
					
					
				
		Reference in new issue