01: /* TestSortedBlocks.java */
02: package org.quilt.cl;
03:
04: import junit.framework.*;
05: import org.apache.bcel.generic.*;
06: import org.quilt.graph.*;
07:
08: /**
09: */
10: public class TestSortedBlocks extends TestCase {
11:
12: private SortedBlocks blox;
13: private ControlFlowGraph graph;
14:
15: public TestSortedBlocks(String name) {
16: super (name);
17: }
18:
19: public void setUp() {
20: blox = new SortedBlocks();
21: graph = new ControlFlowGraph();
22: }
23:
24: public void testNewIndex() {
25: assertEquals("empty index has something in it", 0, blox.size());
26: Edge e = graph.getEntry().getEdge();
27: CodeVertex v1 = blox.find(0, graph, e);
28: assertEquals("wrong number of vertices in index", 1, blox
29: .size());
30: CodeVertex v1b = blox.find(0, graph, e);
31: assertEquals("index has two vertices at position 0?", v1, v1b);
32: assertEquals("wrong number of vertices in index", 1, blox
33: .size());
34:
35: e = v1.getEdge();
36: CodeVertex v2 = blox.find(2, graph, e);
37: e = v2.getEdge();
38: CodeVertex v3 = blox.find(4, graph, e);
39: assertEquals("wrong number of vertices in index", 3, blox
40: .size());
41:
42: assertEquals("vertex is at wrong position", 0, v1.getPosition());
43: assertEquals("vertex is at wrong position", 2, v2.getPosition());
44: assertEquals("vertex is at wrong position", 4, v3.getPosition());
45:
46: }
47:
48: }
|