Sha256: da5427161c5a0578a4573597fe5d6f5022a2d7ec84df6b43b20ed44be4428d07

Contents?: true

Size: 1.03 KB

Versions: 12

Compression:

Stored size: 1.03 KB

Contents

require 'test/unit'
$:.unshift("../lib")
require 'graphviz'

class GraphVizTest < Test::Unit::TestCase
  def setup
    @graph = GraphViz::new( :G )    
  end

  # def teardown
  # end

  def test_graph
    assert(@graph, 'Create graph faild.')
    
    assert_block 'Set attribut for graph faild.' do
      @graph['size'] = "10,10"
    end
    
    assert_equal( "\"10,10\"", @graph['size'].to_s, 'Get attribut for graph faild.' )
    
    assert_equal( "G", @graph.name, "Wrong graph name." )
  end

  def test_node
    n, m = nil, nil
    
    assert_block 'Create node failed.' do
      n = @graph.add_node( "n1" )
    end

    assert_block 'Get node failed.' do    
      m = @graph.get_node( "n1" )
    end

    assert_equal( m, n, "Node corrupted when get." )
    
    assert_equal( @graph.node_count, 1, "Wrong number of nodes" )
    
    assert_block 'Set attribut for node faild.' do
      n['label'] = "Hello\n\"world\"\\l"
    end
    
    assert_equal( "\"Hello\\n\\\"world\\\"\\l\"", n['label'].to_s, 'Get attribut for node faild.' )
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
ruby-graphviz-0.9.19 test/test_init.rb
ruby-graphviz-0.9.18 test/test_init.rb
ruby-graphviz-0.9.17 test/test_init.rb
ruby-graphviz-0.9.16 test/test_init.rb
ruby-graphviz-0.9.15 test/test_init.rb
ruby-graphviz-0.9.14 test/test_init.rb
ruby-graphviz-0.9.13 test/test_init.rb
ruby-graphviz-0.9.12 test/test_init.rb
ruby-graphviz-0.9.11 test/test_init.rb
ruby-graphviz-0.9.10 test/test_init.rb
ruby-graphviz-0.9.9 test/test_init.rb
ruby-graphviz-0.9.8 test/test_init.rb