Permalink
Browse files

Added tests for adding and removing edges

  • Loading branch information...
1 parent 33e419c commit d4ed05c5ed338fda51d5fc110b433d829117f7c1 Prathamesh Sonpatki committed Sep 17, 2012
Showing with 29 additions and 2 deletions.
  1. +29 −2 spec/ir/directed_graph/directed_graph_spec.rb
@@ -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.