Sha256: d7464fd995061f11b1249ca97a19df2abd9a8e8a14edcd76f621e8624541c753

Contents?: true

Size: 882 Bytes

Versions: 12

Compression:

Stored size: 882 Bytes

Contents

require 'xml'
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

12 entries across 12 versions & 1 rubygems

Version Path
libxml-ruby-0.9.3-x86-mswin32-60 test/tc_node_copy.rb
libxml-ruby-0.9.1 test/tc_node_copy.rb
libxml-ruby-0.9.1-x86-mswin32-60 test/tc_node_copy.rb
libxml-ruby-0.9.2 test/tc_node_copy.rb
libxml-ruby-0.9.0 test/tc_node_copy.rb
libxml-ruby-0.9.2-x86-mswin32-60 test/tc_node_copy.rb
libxml-ruby-0.9.0-x86-mswin32-60 test/tc_node_copy.rb
libxml-ruby-0.9.5-x86-mswin32-60 test/tc_node_copy.rb
libxml-ruby-0.9.3 test/tc_node_copy.rb
libxml-ruby-0.9.4 test/tc_node_copy.rb
libxml-ruby-0.9.4-x86-mswin32-60 test/tc_node_copy.rb
libxml-ruby-0.9.5 test/tc_node_copy.rb