Sha256: 6ab1a4a60dde89d9fe414c01f217326a71bbd37b80a5e71bccbe95df77cb554f

Contents?: true

Size: 1.05 KB

Versions: 17

Compression:

Stored size: 1.05 KB

Contents

require 'test_helper'

require 'rgl/base'

include RGL::Edge

class TestEdge < Test::Unit::TestCase

  def test_directed_edge
    assert_raises(ArgumentError) { DirectedEdge.new }
    e = DirectedEdge.new 1, 2
    assert_equal(1, e.source)
    assert_equal(2, e.target)
    assert_equal([1, 2], e.to_a)
    assert_equal("(1-2)", e.to_s)
    assert_equal("(2-1)", e.reverse.to_s)
    assert_equal([1, 2], [e[0], e[1]])
    assert(DirectedEdge[1, 2].eql?(DirectedEdge.new(1, 2)))
    assert(!DirectedEdge[1, 2].eql?(DirectedEdge.new(1, 3)))
    assert(!DirectedEdge[2, 1].eql?(DirectedEdge.new(1, 2)))
  end

  def test_undirected_edge
    assert_raises(ArgumentError) { UnDirectedEdge.new }
    e = UnDirectedEdge.new 1, 2
    assert_equal(1, e.source)
    assert_equal(2, e.target)
    assert_equal([1, 2], e.to_a)
    assert_equal("(1=2)", e.to_s)
    assert(UnDirectedEdge.new(1, 2).eql?(UnDirectedEdge.new(2, 1)))
    assert(!UnDirectedEdge.new(1, 3).eql?(UnDirectedEdge.new(2, 1)))
    assert_equal(UnDirectedEdge.new(1, 2).hash, UnDirectedEdge.new(1, 2).hash)
  end

end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
rgl-0.6.6 test/edge_test.rb
rgl-0.6.5 test/edge_test.rb
rgl-0.6.4 test/edge_test.rb
rgl-0.6.3 test/edge_test.rb
rgl-0.6.2 test/edge_test.rb
rgl-0.6.1 test/edge_test.rb
rgl-0.6.0 test/edge_test.rb
rgl-0.5.10 test/edge_test.rb
rgl-0.5.9 test/edge_test.rb
rgl-0.5.8 test/edge_test.rb
rgl-0.5.7 test/edge_test.rb
rgl-0.5.6 test/edge_test.rb
rgl-0.5.4 test/edge_test.rb
rgl-0.5.3 test/edge_test.rb
rgl-0.5.2 test/edge_test.rb
rgl-0.5.1 test/edge_test.rb
rgl-0.5.0 test/edge_test.rb