Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #728 from prathamesh-sonpatki/directed_graph_specs

Refactored directed graph specs
  • Loading branch information...
commit 7d2e27c02e42478f7b1a3c632e0e6982116d1846 2 parents a66de22 + a9ce79d
@enebo enebo authored
Showing with 10 additions and 18 deletions.
  1. +10 −18 spec/ir/directed_graph/directed_graph_spec.rb
View
28 spec/ir/directed_graph/directed_graph_spec.rb
@@ -1,6 +1,3 @@
-require 'jruby'
-require 'java'
-require 'rspec'
import 'org.jruby.ir.util.DirectedGraph'
# This is spec for Directed Graph Library
@@ -11,17 +8,14 @@
@graph = DirectedGraph.new
end
- it "should add an edge to newly created graph" do
+ it "adds an edge to newly created graph" do
@graph.edges.size.should be 0
@graph.addEdge(1,2,'foo')
@graph.addEdge(4,5,'bar')
@graph.edges.size.should be 2
end
- it "should remove an existing edge from a graph" do
- @graph.edges.size.should be 0
- @graph.removeEdge(1,2)
- @graph.edges.size.should be 0
+ it "removes an existing edge from a graph" do
@graph.addEdge(1,2,'foo')
@graph.addEdge(4,5,'bar')
@graph.removeEdge(4,5)
@@ -30,15 +24,13 @@
@graph.edges.size.should be 0
end
- it "should not delete a non-existent edge from the graph" do
- @graph.edges.size.should be 0
+ it "does not delete a non-existent edge from the graph" do
@graph.removeEdge(2,1)
@graph.edges.size.should be 0
end
- it "should remove a vertex and its associated edges" do
+ it "removes a vertex and its associated edges" do
@graph.removeVertexFor(3)
- @graph.edges.size.should be 0
@graph.vertices.size.should be 0
@graph.addEdge(1,2,'foo')
@graph.addEdge(4,5,'bar')
@@ -47,23 +39,23 @@
@graph.edges.size.should be 1
end
- it "should give vertex for given data" do
+ it "gives vertex for given data" do
@graph.addEdge(1,2,'foo')
@graph.vertexFor(2).getData().should be 2
end
- it "should create a new vertex if it is not present" do
+ it "creates a new vertex if it is not present" do
@graph.vertexFor(100).getData().should be 100
end
- it "should find already existing vertex" do
+ it "finds already existing vertex" do
@graph.findVertexFor(100).should be_nil
@graph.addEdge(1,2,'foo')
@graph.findVertexFor(1).getData().should be 1
@graph.findVertexFor(1).data.should be 1
end
- it "should give correct size of graph" do
+ it "gives correct size of graph" do
@graph.removeEdge(1,2)
@graph.size.should be 0
@graph.addEdge(5,6,'baz')
@@ -72,7 +64,7 @@
@graph.size.should be 4
end
- it "should give all data in the graph" do
+ it "gives all data in the graph" do
@graph.allData.size.should be 0
@graph.addEdge(1,2,'baz')
@graph.allData.each do |key|
@@ -84,7 +76,7 @@
end
end
- it "should give data in the graph in the order in which it was inserted" do
+ it "gives data in the graph in the order in which it was inserted" do
@graph.getInorderData.to_a.size.should be 0
@graph.vertexFor(1)
@graph.getInorderData.to_a.should eq [1]
Please sign in to comment.
Something went wrong with that request. Please try again.