Sha256: cf62d18ba9976cb5431b5404a7120ff60f2fd66ceda8044aa69f97e6302b773e

Contents?: true

Size: 882 Bytes

Versions: 9

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

9 entries across 9 versions & 5 rubygems

Version Path
libxml-jruby-modified-1.0.2-jruby test/tc_node_copy.rb
libxml-jruby-modified-1.0.1-jruby test/tc_node_copy.rb
libxml-fixed-jruby-1.0.0-jruby test/tc_node_copy.rb
libxml-jruby-fixed-1.0.0-jruby test/tc_node_copy.rb
libxml-jruby-1.0.0 test/tc_node_copy.rb
libxml-ruby-0.8.2 test/tc_node_copy.rb
libxml-ruby-0.8.2-x86-mswin32-60 test/tc_node_copy.rb
libxml-ruby-0.8.3-x86-mswin32-60 test/tc_node_copy.rb
libxml-ruby-0.8.3 test/tc_node_copy.rb