Skip to content

Commit

Permalink
Added tests for adding and removing edges
Browse files Browse the repository at this point in the history
  • Loading branch information
Prathamesh Sonpatki committed Sep 17, 2012
1 parent 33e419c commit d4ed05c
Showing 1 changed file with 29 additions and 2 deletions.
31 changes: 29 additions & 2 deletions spec/ir/directed_graph/directed_graph_spec.rb
Expand Up @@ -5,8 +5,35 @@
# This is spec for Directed Graph Library

describe "Directed Graph Utility" do

before do
@graph = DirectedGraph.new
@graph.addEdge(1,2,'simple')
@graph.addEdge(2,3,'simple')
@graph.addEdge(3,4,'simple')
@graph.addEdge(4,1,'simple')
end

it "should create object of DirectedGraph" do
graph = DirectedGraph.new
graph.class.should == Java::OrgJrubyIrUtil::DirectedGraph
@graph.class.should == Java::OrgJrubyIrUtil::DirectedGraph
end

it "should add an edge to newly created graph" do
@graph.edges.size.should == 4
@graph.addEdge(4,5,'simple')
@graph.edges.size.should == 5
end

it "should remove an existing edge from a graph" do
@graph.edges.size.should == 4
@graph.removeEdge(1,2)
@graph.edges.size.should == 3
end

it "should not delete a non-existent edge from the graph" do
@graph.edges.size.should == 4
@graph.removeEdge(2,1)
@graph.edges.size.should == 4
end

end

0 comments on commit d4ed05c

Please sign in to comment.