class TestDotNode
Tests for DOT::Node
Public Instance Methods
test_1prop_0comma()
click to toggle source
bug 16125
# File test/rdot_test.rb, line 64 def test_1prop_0comma node = DOT::Node.new({ "label" => "the_label" }) dot = node.to_s assert_no_match(dot, /,/) end
test_2prop_1comma()
click to toggle source
# File test/rdot_test.rb, line 70 def test_2prop_1comma node = DOT::Node.new({ "label" => "the_label", "shape" => "ellipse" }) dot = node.to_s assert_match(dot, /\[[^,]*,[^,]*\]/) end
test_Mrecord_label_no_ports()
click to toggle source
# File test/rdot_test.rb, line 95 def test_Mrecord_label_no_ports node = DOT::Node.new({ "name" => "test_name", "label" => "test_label", "shape" => "Mrecord" }) dot = node.to_s assert_match(dot, /shape\s*=\s*Mrecord/) assert_match(dot, /label\s*=\s*test_label/) end
test_Mrecord_label_with_ports()
click to toggle source
# File test/rdot_test.rb, line 102 def test_Mrecord_label_with_ports node = DOT::Node.new({ "name" => "test_name", "label" => "test_label", "shape" => "Mrecord" }) node.ports << DOT::Port.new(nil, "a") node.ports << DOT::Port.new(nil, "b") dot = node.to_s assert_match(dot, /shape\s*=\s*Mrecord/) assert_match(dot, /label\s*=\s*"a\s*|\s*b"/) end
test_Mrecord_no_label_no_ports()
click to toggle source
# File test/rdot_test.rb, line 88 def test_Mrecord_no_label_no_ports node = DOT::Node.new({ "name" => "test_name", "shape" => "Mrecord" }) dot = node.to_s assert_match(dot, /shape\s*=\s*Mrecord/) assert_no_match(dot, /label/) end
test_Mrecord_no_label_with_ports()
click to toggle source
# File test/rdot_test.rb, line 111 def test_Mrecord_no_label_with_ports node = DOT::Node.new({ "name" => "test_name", "shape" => "Mrecord" }) node.ports << DOT::Port.new(nil, "a") node.ports << DOT::Port.new(nil, "b") dot = node.to_s assert_match(dot, /shape\s*=\s*Mrecord/) assert_match(dot, /label\s*=\s*"a\s*|\s*b"/) end
test_label_quoting()
click to toggle source
# File test/rdot_test.rb, line 216 def test_label_quoting node = DOT::Node.new({ "name" => "test_name", "label" => "Label with spaces" }) dot = node.to_s assert_match(dot, /label\s*=\s*"Label with spaces"/) node = DOT::Node.new({ "name" => "test_name", "label" => "Label with \"quotes\"" }) dot = node.to_s assert_match(dot, /label\s*=\s*"Label with \"quotes\""/) node = DOT::Node.new({ "name" => "test_name", "label" => "Label with \\backslashes\\" }) dot = node.to_s assert_match(dot, /label\s*=\s*"Label with \\backslashes\\"/) node = DOT::Node.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::Node.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::Node.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::Node.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::Node.new({ "name" => "test_name", "label" => "123.456" }) dot = node.to_s assert_match(dot, /label\s*=\s*123.456/) node = DOT::Node.new({ "name" => "test_name", "label" => ".456" }) dot = node.to_s assert_match(dot, /label\s*=\s*.456/) node = DOT::Node.new({ "name" => "test_name", "label" => "-.456" }) dot = node.to_s assert_match(dot, /label\s*=\s*-.456/) node = DOT::Node.new({ "name" => "test_name", "label" => "-456" }) dot = node.to_s assert_match(dot, /label\s*=\s*-456/) node = DOT::Node.new({ "name" => "test_name", "label" => "-123.456" }) dot = node.to_s assert_match(dot, /label\s*=\s*-123.456/) node = DOT::Node.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 170 def test_name_quoting node = DOT::Node.new({ "name" => "Name with spaces" }) dot = node.to_s assert_match(dot, /^"Name with spaces"$/) node = DOT::Node.new({ "name" => "Name with \"quotes\"" }) dot = node.to_s assert_match(dot, /^"Name with \"quotes\""$/) node = DOT::Node.new({ "name" => "Name with \\backslashes\\" }) dot = node.to_s assert_match(dot, /^"Name with \\backslashes\\"$/) node = DOT::Node.new({ "name" => "Name with\nembedded\nnewlines" }) dot = node.to_s assert_match(dot, /\A.*"Name with\nembedded\nnewlines".*\Z/m) node = DOT::Node.new({ "name" => "Name_with_trailing_newline\n" }) dot = node.to_s assert_match(dot, /\A.*"Name_with_trailing_newline\n".*\Z/m) node = DOT::Node.new({ "name" => "123.456" }) dot = node.to_s assert_match(dot, /^123.456$/) node = DOT::Node.new({ "name" => ".456" }) dot = node.to_s assert_match(dot, /^.456$/) node = DOT::Node.new({ "name" => "-.456" }) dot = node.to_s assert_match(dot, /^-.456$/) node = DOT::Node.new({ "name" => "-456" }) dot = node.to_s assert_match(dot, /^-456$/) node = DOT::Node.new({ "name" => "-123.456" }) dot = node.to_s assert_match(dot, /^-123.456$/) node = DOT::Node.new({ "name" => "<html><head><title>test</title></head>\n<body>text</body></html>" }) dot = node.to_s assert_match(dot, /^<html><head><title>test<\/title><\/head>\n<body>text<\/body><\/html>$/) end
test_name_without_label()
click to toggle source
# File test/rdot_test.rb, line 76 def test_name_without_label node = DOT::Node.new({ "name" => "test_name" }) dot = node.to_s assert_no_match(dot, /label/) end
test_no_label()
click to toggle source
# File test/rdot_test.rb, line 82 def test_no_label node = DOT::Node.new({ "shape" => "ellipse" }) dot = node.to_s assert_no_match(dot, /label/) end
test_no_name()
click to toggle source
# File test/rdot_test.rb, line 57 def test_no_name node = DOT::Node.new() dot = node.to_s assert_nil(dot) end
test_no_shape_no_label_no_ports()
click to toggle source
# File test/rdot_test.rb, line 152 def test_no_shape_no_label_no_ports node = DOT::Node.new({ "name" => "test_name" }) node.ports << DOT::Port.new(nil, "a") node.ports << DOT::Port.new(nil, "b") dot = node.to_s assert_no_match(dot, /shape\s*=\s/) assert_no_match(dot, /label\s*=\s*/) end
test_no_shape_no_label_with_ports()
click to toggle source
# File test/rdot_test.rb, line 161 def test_no_shape_no_label_with_ports node = DOT::Node.new({ "name" => "test_name" }) node.ports << DOT::Port.new(nil, "a") node.ports << DOT::Port.new(nil, "b") dot = node.to_s assert_no_match(dot, /shape\s*=\s*record/) assert_no_match(dot, /label\s*=\s*/) end
test_option_quoting()
click to toggle source
# File test/rdot_test.rb, line 270 def test_option_quoting node = DOT::Node.new({ "name" => "test_name", "comment" => "Comment with spaces" }) dot = node.to_s assert_match(dot, /comment\s*=\s*"Comment with spaces"/) node = DOT::Node.new({ "name" => "test_name", "comment" => "Comment with \"quotes\"" }) dot = node.to_s assert_match(dot, /comment\s*=\s*"Comment with \"quotes\""/) node = DOT::Node.new({ "name" => "test_name", "comment" => "Comment with \\backslashes\\" }) dot = node.to_s assert_match(dot, /comment\s*=\s*"Comment with \\backslashes\\"/) node = DOT::Node.new({ "name" => "test_name", "comment" => "123.456" }) dot = node.to_s assert_match(dot, /comment\s*=\s*123.456/) node = DOT::Node.new({ "name" => "test_name", "comment" => ".456" }) dot = node.to_s assert_match(dot, /comment\s*=\s*.456/) node = DOT::Node.new({ "name" => "test_name", "comment" => "-.456" }) dot = node.to_s assert_match(dot, /comment\s*=\s*-.456/) node = DOT::Node.new({ "name" => "test_name", "comment" => "-456" }) dot = node.to_s assert_match(dot, /comment\s*=\s*-456/) node = DOT::Node.new({ "name" => "test_name", "comment" => "-123.456" }) dot = node.to_s assert_match(dot, /comment\s*=\s*-123.456/) node = DOT::Node.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
test_record_label_no_ports()
click to toggle source
# File test/rdot_test.rb, line 127 def test_record_label_no_ports node = DOT::Node.new({ "name" => "test_name", "label" => "test_label", "shape" => "record" }) dot = node.to_s assert_match(dot, /shape\s*=\s*record/) assert_match(dot, /label\s*=\s*test_label/) end
test_record_label_with_ports()
click to toggle source
# File test/rdot_test.rb, line 134 def test_record_label_with_ports node = DOT::Node.new({ "name" => "test_name", "label" => "test_label", "shape" => "record" }) node.ports << DOT::Port.new(nil, "a") node.ports << DOT::Port.new(nil, "b") dot = node.to_s assert_match(dot, /shape\s*=\s*record/) assert_match(dot, /label\s*=\s*"a\s*|\s*b"/) end
test_record_no_label_no_ports()
click to toggle source
# File test/rdot_test.rb, line 120 def test_record_no_label_no_ports node = DOT::Node.new({ "name" => "test_name", "shape" => "record" }) dot = node.to_s assert_match(dot, /shape\s*=\s*record/) assert_no_match(dot, /label/) end
test_record_no_label_with_ports()
click to toggle source
# File test/rdot_test.rb, line 143 def test_record_no_label_with_ports node = DOT::Node.new({ "name" => "test_name", "shape" => "record" }) node.ports << DOT::Port.new(nil, "a") node.ports << DOT::Port.new(nil, "b") dot = node.to_s assert_match(dot, /shape\s*=\s*record/) assert_match(dot, /label\s*=\s*"a\s*|\s*b"/) end