Skip to content
Browse files

Added test for Graph#get_neighbours on directed graphs.

  • Loading branch information...
1 parent 5f01af9 commit 624b464c262356d76f40d818407cd9e18941fbde @bfontaine committed Feb 13, 2013
Showing with 23 additions and 1 deletion.
  1. +23 −1 tests/graph_tests.rb
View
24 tests/graph_tests.rb
@@ -36,6 +36,16 @@ def setup
)
@@empty = Graph.new
+
+ @@directed = Graph.new(
+ [
+ {'label' => 'foo'},
+ {'label' => 'bar'}
+ ],
+ [ { 'node1' => 'foo', 'node2' => 'bar' }]
+ )
+
+ @@directed.attrs[:directed] = true
end
# == Graph#attrs == #
@@ -588,7 +598,7 @@ def test_graph_get_neighbours_unexisting_node_object
end
- def test_graph_get_neighbours
+ def test_graph_get_neighbours_undirected_graph
g = @@sample_graph
@@ -598,4 +608,16 @@ def test_graph_get_neighbours
end
+ def test_graph_get_neighbours_directed_graph
+
+ g = @@directed
+
+ n = g.get_neighbours 'foo'
+ assert_equal([ 'bar' ], n.map { |m| m.label })
+
+ n = g.get_neighbours 'bar'
+ assert_equal([], n.map { |m| m.label })
+
+ end
+
end

0 comments on commit 624b464

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