Sha256: 566a212895df0a01d0334bfd1709bc60478fc22c12b8efd6fce505e006e4b081

Contents?: true

Size: 906 Bytes

Versions: 4

Compression:

Stored size: 906 Bytes

Contents

# encoding: UTF-8

require './test_helper'

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

class TestNodeCopy < Minitest::Test
  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 << c
    end
    assert @div1.to_s =~ /foo/
  end

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

end # TC_XML_Node_Copy

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
libxml-ruby-3.0.0-x64-mingw32 test/tc_node_copy.rb
libxml-ruby-3.0.0 test/tc_node_copy.rb
libxml-ruby-2.9.0-x64-mingw32 test/tc_node_copy.rb
libxml-ruby-2.9.0 test/tc_node_copy.rb