Skip to content
This repository

Specs for DirectedGraph Library #307

Merged
merged 3 commits into from over 1 year ago

2 participants

प्रथमेश Thomas E Enebo
प्रथमेश

Added more specs for DirectedGraph Library.
Added documentation for DirectedGraph#size method.

Thomas E Enebo enebo merged commit 99ce5c6 into from September 21, 2012
Thomas E Enebo enebo closed this September 21, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 3 unique commits by 1 author.

Sep 21, 2012
Added specs for vertexFor, findVertexFor and size methods 5ad27f5
Fixed the test for size of graph 76209e6
Added description for size method of DirectedGraph 7044c83
This page is out of date. Refresh to see the latest.
21  spec/ir/directed_graph/directed_graph_spec.rb
@@ -2,6 +2,7 @@
2 2
 require 'java'
3 3
 require 'rspec'
4 4
 import 'org.jruby.ir.util.DirectedGraph'
  5
+
5 6
 # This is spec for Directed Graph Library
6 7
 
7 8
 describe "Directed Graph Utility" do
@@ -40,4 +41,24 @@
40 41
     @graph.vertices.size.should == 2
41 42
   end
42 43
 
  44
+  it "should give vertex for given data" do
  45
+    @graph.vertexFor(2).getData().should == 2
  46
+  end
  47
+
  48
+  it "should create a new vertex if it is not present" do
  49
+    @graph.vertexFor(100).getData().should == 100
  50
+  end
  51
+
  52
+  it "should find already existing vertex" do
  53
+    @graph.findVertexFor(2).getData().should == 2
  54
+    @graph.findVertexFor(100).should == nil
  55
+  end
  56
+
  57
+  it "should give correct size of graph" do
  58
+    @graph.removeEdge(1,2)
  59
+    @graph.size.should == 4
  60
+    @graph.addEdge(5,6,'simple')
  61
+    @graph.size.should == 6
  62
+  end
  63
+
43 64
 end
3  src/org/jruby/ir/util/DirectedGraph.java
@@ -81,6 +81,9 @@ public void removeVertexFor(T data) {
81 81
         vertex.removeAllEdges();
82 82
     }
83 83
     
  84
+    /**
  85
+     * @return the number of vertices in the graph.
  86
+     */
84 87
     public int size() {
85 88
         return allData().size();
86 89
     }
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.