01: /* TestDirected.java */
02:
03: package org.quilt.graph;
04:
05: import junit.framework.*;
06: import org.quilt.cl.GraphTalker;
07:
08: public class TestDirected extends TestCase {
09:
10: Directed graph = null;
11: Entry entry = null;
12: Exit exit = null;
13:
14: public TestDirected(String name) {
15: super (name);
16: }
17:
18: public void setUp() {
19: graph = new Directed();
20: entry = graph.getEntry();
21: exit = graph.getExit();
22: }
23:
24: public void testTwosome() {
25: assertEquals("wrong index on entry", 0, entry.getIndex());
26: assertEquals("wrong index on exit", 1, exit.getIndex());
27: assertEquals("wrong number of vertices in new graph", 2, graph
28: .size());
29: }
30:
31: public void testBasicSubgraph() {
32: Edge e = entry.getEdge();
33: Directed subgraph = graph.subgraph(e, 5);
34: Entry subEntry = subgraph.getEntry();
35:
36: assertEquals("wrong number of vertices in subgraph", 2,
37: subgraph.size());
38:
39: assertEquals("wrong number of vertices in nested graph", 4,
40: graph.size());
41:
42: // should return the size of the Multi part of the connector
43: assertEquals("size of subgraph ComplexConnector wrong", 5,
44: subEntry.getConnector().size());
45: }
46:
47: public void testThreesome() {
48: Edge e = entry.getEdge();
49: try {
50: graph.insertVertex(e);
51: } catch (Exception exc) {
52: fail("error inserting third vertex");
53: }
54: assertEquals("wrong number of vertices in new graph", 3, graph
55: .size());
56: }
57:
58: public void testLotsInARow() {
59: Edge e = entry.getEdge();
60:
61: Vertex A = graph.insertVertex(e);
62: Vertex B = graph.insertVertex(A.getEdge());
63: Vertex C = graph.insertVertex(B.getEdge());
64: Vertex D = graph.insertVertex(C.getEdge());
65: Vertex E = graph.insertVertex(D.getEdge());
66: assertEquals("wrong number of vertices in graph", 7, graph
67: .size());
68: }
69: }
|