Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Added specs for vertexFor, findVertexFor and size methods

  • Loading branch information...
commit 5ad27f54b79b4d5734a4ac47708f0af122cb77b4 1 parent b1fec0d
authored September 20, 2012
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         # Passes ?
  60
+    @graph.addEdge(5,6,'simple')
  61
+    @graph.size.should == 4         # Fails; Because size of graph is actually number of vertices according to implementation
  62
+  end
  63
+
43 64
 end

0 notes on commit 5ad27f5

Please sign in to comment.
Something went wrong with that request. Please try again.