KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > quilt > cl > TestSortedBlocks


1 /* TestSortedBlocks.java */
2 package org.quilt.cl;
3
4 import junit.framework.*;
5 import org.apache.bcel.generic.*;
6 import org.quilt.graph.*;
7 /**
8  */

9 public class TestSortedBlocks extends TestCase {
10
11     private SortedBlocks blox;
12     private ControlFlowGraph graph;
13     
14     public TestSortedBlocks (String JavaDoc name) {
15         super(name);
16     }
17
18     public void setUp () {
19         blox = new SortedBlocks ();
20         graph = new ControlFlowGraph();
21     }
22
23     public void testNewIndex() {
24         assertEquals("empty index has something in it", 0, blox.size() );
25         Edge e = graph.getEntry().getEdge();
26         CodeVertex v1 = blox.find(0, graph, e);
27         assertEquals("wrong number of vertices in index", 1, blox.size() );
28         CodeVertex v1b = blox.find(0, graph, e);
29         assertEquals("index has two vertices at position 0?", v1, v1b);
30         assertEquals("wrong number of vertices in index", 1, blox.size() );
31
32         e = v1.getEdge();
33         CodeVertex v2 = blox.find(2, graph, e);
34         e = v2.getEdge();
35         CodeVertex v3 = blox.find(4, graph, e);
36         assertEquals("wrong number of vertices in index", 3, blox.size() );
37
38         assertEquals("vertex is at wrong position", 0, v1.getPosition() );
39         assertEquals("vertex is at wrong position", 2, v2.getPosition() );
40         assertEquals("vertex is at wrong position", 4, v3.getPosition() );
41
42     }
43     
44 }
45
Popular Tags