Skip to content
Browse files

Nodes & Edges tests added (100% coverage)

  • Loading branch information...
1 parent 18b0d04 commit a6d30790b139ecaa303778505f489a687b95a8ec @bfontaine committed Feb 13, 2013
Showing with 76 additions and 0 deletions.
  1. +38 −0 tests/edge_tests.rb
  2. +38 −0 tests/node_tests.rb
View
38 tests/edge_tests.rb
@@ -52,3 +52,41 @@ def test_edge_init_with_another_edge
end
end
+
+class EdgeArray_test < Test::Unit::TestCase
+
+ def test_edgearray_push_edge
+
+ e = Graph::Edge.new({ :foo => 42 })
+ ea = Graph::EdgeArray.new([])
+
+ ea.push(e)
+
+ assert_equal(e, ea[0])
+
+ end
+
+ def test_edgearray_push_hash
+
+ e = { :foo => 42 }
+ ea = Graph::EdgeArray.new([])
+
+ ea.push(e)
+
+ assert_equal(Graph::Edge.new(e), ea[0])
+
+ end
+
+ def test_edgearray_push_no_edge_nor_hash
+
+ ea = Graph::EdgeArray.new([])
+
+ assert_raise(TypeError) do
+
+ ea.push(42)
+
+ end
+
+ end
+
+end
View
38 tests/node_tests.rb
@@ -101,3 +101,41 @@ def test_node_init_with_another_node
end
end
+
+class NodeArray_test < Test::Unit::TestCase
+
+ def test_nodearray_push_node
+
+ n = Graph::Node.new({ :foo => 42 })
+ na = Graph::NodeArray.new([])
+
+ na.push(n)
+
+ assert_equal(n, na[0])
+
+ end
+
+ def test_nodearray_push_hash
+
+ n = { :foo => 42 }
+ na = Graph::NodeArray.new([])
+
+ na.push(n)
+
+ assert_equal(Graph::Node.new(n), na[0])
+
+ end
+
+ def test_nodearray_push_no_node_nor_hash
+
+ na = Graph::NodeArray.new([])
+
+ assert_raise(TypeError) do
+
+ na.push(42)
+
+ end
+
+ end
+
+end

0 comments on commit a6d3079

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