Sha256: e6cedd85abeee920a0a58f5a17657b2561acc7904e1ab8d77eb4573ba1de8510

Contents?: true

Size: 914 Bytes

Versions: 2

Compression:

Stored size: 914 Bytes

Contents

# encoding: UTF-8

require File.expand_path('../test_helper', __FILE__)

# 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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
libxml-ruby-3.1.0-x64-mingw32 test/test_node_copy.rb
libxml-ruby-3.1.0 test/test_node_copy.rb