Ein bisschen testen...
This commit is contained in:
parent
ed08dfd060
commit
2b5543b279
2 changed files with 45 additions and 1 deletions
|
|
@ -1,5 +1,48 @@
|
|||
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 {
|
||||
|
||||
@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