Ein bisschen testen...
This commit is contained in:
parent
ed08dfd060
commit
2b5543b279
2 changed files with 45 additions and 1 deletions
|
|
@ -131,7 +131,8 @@ public class Graph<T> {
|
||||||
* @return true, wenn alle Knoten erreichbar sind
|
* @return true, wenn alle Knoten erreichbar sind
|
||||||
*/
|
*/
|
||||||
public boolean allNodesConnected() {
|
public boolean allNodesConnected() {
|
||||||
// TODO: Graph<T>#allNodesConnected()
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,48 @@
|
||||||
package tests.student;
|
package tests.student;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import base.*;
|
||||||
|
|
||||||
public class GraphConnectionTest {
|
public class GraphConnectionTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCorrectGraph() {
|
||||||
|
|
||||||
|
Graph<String> testGraph = new Graph<String>();
|
||||||
|
|
||||||
|
Node<String> a = testGraph.addNode("A");
|
||||||
|
Node<String> b = testGraph.addNode("B");
|
||||||
|
Node<String> c = testGraph.addNode("C");
|
||||||
|
Node<String> d = testGraph.addNode("D");
|
||||||
|
|
||||||
|
testGraph.addEdge(a, b);
|
||||||
|
testGraph.addEdge(a, c);
|
||||||
|
testGraph.addEdge(c, d);
|
||||||
|
|
||||||
|
assertTrue(testGraph.allNodesConnected());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testIncorrectGraph() {
|
||||||
|
|
||||||
|
Graph<Integer> testGraph = new Graph<Integer>();
|
||||||
|
|
||||||
|
Node<Integer> one = testGraph.addNode(1);
|
||||||
|
Node<Integer> two = testGraph.addNode(2);
|
||||||
|
Node<Integer> four = testGraph.addNode(4);
|
||||||
|
Node<Integer> seven = testGraph.addNode(7);
|
||||||
|
Node<Integer> nine = testGraph.addNode(9);
|
||||||
|
|
||||||
|
testGraph.addEdge(one, seven);
|
||||||
|
testGraph.addEdge(two, nine);
|
||||||
|
|
||||||
|
assertFalse(testGraph.allNodesConnected());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue