Sha256: 8961bc6f2df3f16726daba291a860afb6cb8358ea85379415528ba045329dd37

Contents?: true

Size: 1.2 KB

Versions: 12

Compression:

Stored size: 1.2 KB

Contents

# frozen_string_literal: true

require 'test_helper'

require 'rgl/adjacency'
require 'rgl/path'

class TestPath < Test::Unit::TestCase
  include RGL

  def setup
    edges = [[1, 2], [2, 3], [2, 4], [4, 5], [6, 4], [1, 6]]
    @directed_graph, @undirected_graph =
      [DirectedAdjacencyGraph, AdjacencyGraph].map do |klass|
        graph = klass.new
        graph.add_edges(*edges)
        graph
      end
  end

  def test_path_for_directed_graph
    assert(@directed_graph.path?(1, 5))
  end

  def test_path_for_undirected_graph
    assert(@undirected_graph.path?(1, 5))
  end

  def test_inverse_path_for_directed_graph
    assert_equal(@directed_graph.path?(3, 1), false)
  end

  def test_inverse_path_for_undirected_graph
    assert(@undirected_graph.path?(3, 1))
  end

  def test_path_for_directed_graph_wrong_source
    assert_equal(@directed_graph.path?(0, 1), false)
  end

  def test_path_for_undirected_graph_wrong_source
    assert_equal(@undirected_graph.path?(0, 1), false)
  end

  def test_path_for_directed_graph_wrong_target
    assert_equal(@directed_graph.path?(4, 0), false)
  end

  def test_path_for_undirected_graph_wrong_target
    assert_equal(@undirected_graph.path?(4, 0), false)
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
rgl-0.6.6 test/path_test.rb
rgl-0.6.5 test/path_test.rb
rgl-0.6.4 test/path_test.rb
rgl-0.6.3 test/path_test.rb
rgl-0.6.2 test/path_test.rb
rgl-0.6.1 test/path_test.rb
rgl-0.6.0 test/path_test.rb
rgl-0.5.10 test/path_test.rb
rgl-0.5.9 test/path_test.rb
rgl-0.5.8 test/path_test.rb
rgl-0.5.7 test/path_test.rb
rgl-0.5.6 test/path_test.rb