Sha256: 81c461c7a90cb15df21db29504c04dbbd36f31f1d6864b4fc6cc0b45be4d422a

Contents?: true

Size: 1.06 KB

Versions: 1

Compression:

Stored size: 1.06 KB

Contents

require 'test/unit'
$:.unshift(File.expand_path('../../lib',__FILE__))
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

1 entries across 1 versions & 1 rubygems

Version Path
ruby-graphviz-1.0.1 test/test_graph.rb