Sha256: 5eccc4c01b28b605f1850b103c260866233daf246eec4e9518b75e36f2af6c5d

Contents?: true

Size: 885 Bytes

Versions: 10

Compression:

Stored size: 885 Bytes

Contents

require "libxml"
require 'test/unit'

# see mailing list archive
# [libxml-devel] Segmentation fault when add the cloned/copied node
# 2007/11/27 20:51

class TC_XML_Node_Copy < Test::Unit::TestCase
  def setup
    str = <<-STR
      <html><body>
        <div class="textarea" id="t1" style="STATIC">foo</div>
        <div class="textarea" id="t2" style="STATIC">bar</div>
      </body></html>
    STR

    doc = XML::Parser.string(str).parse

    xpath = "//div"
    @div1 = doc.find(xpath).to_a[0]
    @div2 = doc.find(xpath).to_a[1]
  end

  def test_libxml_node_copy_not_segv
    @div2.each do |child|
      c = child.copy(false)
      @div1.child_add(c)
    end
    assert @div1.to_s =~ /foo/
  end

  def test_libxml_node_clone_not_segv
    @div2.each do |child|
      c = child.clone
      @div1.child_add(c)
    end
    assert @div1.to_s =~ /foo/
  end

end # TC_XML_Node_Copy

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
libxml-ruby-0.5.3 test/tc_xml_node_copy.rb
libxml-ruby-0.5.4 test/tc_xml_node_copy.rb
libxml-ruby-0.7.0-x86-mswin32-60 test/tc_xml_node_copy.rb
libxml-ruby-0.6.0 test/tc_xml_node_copy.rb
libxml-ruby-0.6.0-x86-mswin32-60 test/tc_xml_node_copy.rb
libxml-ruby-0.7.0 test/tc_xml_node_copy.rb
libxml-ruby-0.8.1-x86-mswin32-60 test/tc_xml_node_copy.rb
libxml-ruby-0.8.0 test/tc_xml_node_copy.rb
libxml-ruby-0.8.0-x86-mswin32-60 test/tc_xml_node_copy.rb
libxml-ruby-0.8.1 test/tc_xml_node_copy.rb