class TestDotDigraph
Tests for DOT::Digraph
Public Instance Methods
test_digraph_statement()
click to toggle source
# File test/rdot_test.rb, line 534 def test_digraph_statement digraph = DOT::Digraph.new() dot = digraph.to_s assert_match(dot, /^\s*digraph /) end
test_element_containment()
click to toggle source
# File test/rdot_test.rb, line 678 def test_element_containment node1 = DOT::Node.new('name' => 'test_node1') node2 = DOT::Node.new('name' => 'test_node2') graph = DOT::Digraph.new('name' => 'test_graph') assert_nil(graph.pop) assert_equal(graph, graph.push(node1)) assert_equal(graph, graph << node2) graph.each_element do |element| assert([node1, node2].include?(element)) end assert_equal(node2, graph.pop) assert_equal(node1, graph.pop) assert_nil(graph.pop) graph = DOT::Digraph.new('name' => 'test_graph', 'elements' => [node1]) assert_equal(node1, graph.pop) assert_nil(graph.pop) end
test_label_quoting()
click to toggle source
# File test/rdot_test.rb, line 586 def test_label_quoting node = DOT::Digraph.new({ "name" => "test_name", "label" => "Label with spaces" }) dot = node.to_s assert_match(dot, /label\s*=\s*"Label with spaces"/) node = DOT::Digraph.new({ "name" => "test_name", "label" => "Label with \"quotes\"" }) dot = node.to_s assert_match(dot, /label\s*=\s*"Label with \\"quotes\\""/) node = DOT::Digraph.new({ "name" => "test_name", "label" => "Label with \\backslashes\\" }) dot = node.to_s assert_match(dot, /label\s*=\s*"Label with \\\\backslashes\\\\"/) node = DOT::Digraph.new({ "name" => "test_name", "label" => "Label with\nembedded\nnewlines" }) dot = node.to_s assert_match(dot, /label\s*=\s*"Label with\\nembedded\\nnewlines"/) node = DOT::Digraph.new({ "name" => "test_name", "label" => "Label_with_a_trailing_newline\n" }) dot = node.to_s assert_match(dot, /label\s*=\s*"Label_with_a_trailing_newline\\n"/) node = DOT::Digraph.new({ "name" => "test_name", "label" => "Left justified label\\l" }) dot = node.to_s assert_match(dot, /label\s*=\s*"Left justified label\\l"/) node = DOT::Digraph.new({ "name" => "test_name", "label" => "Right justified label\\r" }) dot = node.to_s assert_match(dot, /label\s*=\s*"Right justified label\\r"/) node = DOT::Digraph.new({ "name" => "test_name", "label" => "123.456" }) dot = node.to_s assert_match(dot, /label\s*=\s*123.456/) node = DOT::Digraph.new({ "name" => "test_name", "label" => ".456" }) dot = node.to_s assert_match(dot, /label\s*=\s*.456/) node = DOT::Digraph.new({ "name" => "test_name", "label" => "-.456" }) dot = node.to_s assert_match(dot, /label\s*=\s*-.456/) node = DOT::Digraph.new({ "name" => "test_name", "label" => "-456" }) dot = node.to_s assert_match(dot, /label\s*=\s*-456/) node = DOT::Digraph.new({ "name" => "test_name", "label" => "-123.456" }) dot = node.to_s assert_match(dot, /label\s*=\s*-123.456/) node = DOT::Digraph.new({ "name" => "test_name", "label" => "<html><head><title>test</title></head>\n<body>text</body></html>" }) dot = node.to_s assert_match(dot, /label\s*=\s*<html><head><title>test<\/title><\/head>\n<body>text<\/body><\/html>/) end
test_name_quoting()
click to toggle source
# File test/rdot_test.rb, line 540 def test_name_quoting node = DOT::Digraph.new({ "name" => "Name with spaces" }) dot = node.to_s assert_match(dot, /^digraph "Name with spaces" \{$/) node = DOT::Digraph.new({ "name" => "Name with \"quotes\"" }) dot = node.to_s assert_match(dot, /^digraph "Name with \\"quotes\\"" \{$/) node = DOT::Digraph.new({ "name" => "Name with \\backslashes\\" }) dot = node.to_s assert_match(dot, /^digraph "Name with \\\\backslashes\\\\" \{$/) node = DOT::Digraph.new({ "name" => "Name with\nembedded\nnewlines" }) dot = node.to_s assert_match(dot, /\A.*"Name with\nembedded\nnewlines".*\Z/m) node = DOT::Digraph.new({ "name" => "Name_with_trailing_newline\n" }) dot = node.to_s assert_match(dot, /\A.*"Name_with_trailing_newline\n".*\Z/m) node = DOT::Digraph.new({ "name" => "123.456" }) dot = node.to_s assert_match(dot, /^digraph 123.456 \{$/) node = DOT::Digraph.new({ "name" => ".456" }) dot = node.to_s assert_match(dot, /^digraph .456 \{$/) node = DOT::Digraph.new({ "name" => "-.456" }) dot = node.to_s assert_match(dot, /^digraph -.456 \{$/) node = DOT::Digraph.new({ "name" => "-456" }) dot = node.to_s assert_match(dot, /^digraph -456 \{$/) node = DOT::Digraph.new({ "name" => "-123.456" }) dot = node.to_s assert_match(dot, /^digraph -123.456 \{$/) node = DOT::Digraph.new({ "name" => "<html><head><title>test</title></head>\n<body>text</body></html>" }) dot = node.to_s assert_match(dot, /^digraph <html><head><title>test<\/title><\/head>\n<body>text<\/body><\/html> \{$/) end
test_option_quoting()
click to toggle source
# File test/rdot_test.rb, line 640 def test_option_quoting node = DOT::Digraph.new({ "name" => "test_name", "comment" => "Comment with spaces" }) dot = node.to_s assert_match(dot, /comment\s*=\s*"Comment with spaces"/) node = DOT::Digraph.new({ "name" => "test_name", "comment" => "Comment with \"quotes\"" }) dot = node.to_s assert_match(dot, /comment\s*=\s*"Comment with \\"quotes\\""/) node = DOT::Digraph.new({ "name" => "test_name", "comment" => "Comment with \\backslashes\\" }) dot = node.to_s assert_match(dot, /comment\s*=\s*"Comment with \\\\backslashes\\\\"/) node = DOT::Digraph.new({ "name" => "test_name", "comment" => "123.456" }) dot = node.to_s assert_match(dot, /comment\s*=\s*123.456/) node = DOT::Digraph.new({ "name" => "test_name", "comment" => ".456" }) dot = node.to_s assert_match(dot, /comment\s*=\s*.456/) node = DOT::Digraph.new({ "name" => "test_name", "comment" => "-.456" }) dot = node.to_s assert_match(dot, /comment\s*=\s*-.456/) node = DOT::Digraph.new({ "name" => "test_name", "comment" => "-456" }) dot = node.to_s assert_match(dot, /comment\s*=\s*-456/) node = DOT::Digraph.new({ "name" => "test_name", "comment" => "-123.456" }) dot = node.to_s assert_match(dot, /comment\s*=\s*-123.456/) node = DOT::Digraph.new({ "name" => "test_name", "comment" => "<html><head><title>test</title></head>\n<body>text</body></html>" }) dot = node.to_s assert_match(dot, /comment\s*=\s*<html><head><title>test<\/title><\/head>\n<body>text<\/body><\/html>/) end