2015-12-16 00:07:31 -05:00
|
|
|
# frozen_string_literal: false
|
2010-09-17 09:14:14 -04:00
|
|
|
# ISSUE 32
|
|
|
|
require 'test/unit'
|
|
|
|
require 'rexml/document'
|
|
|
|
|
2014-05-27 08:07:40 -04:00
|
|
|
module REXMLTests
|
2014-05-27 09:10:55 -04:00
|
|
|
# daz - for report by Dan Kohn in:
|
|
|
|
# http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/156328
|
|
|
|
class XPathTesterDd < Test::Unit::TestCase
|
|
|
|
include REXML
|
2010-09-17 09:14:14 -04:00
|
|
|
|
2014-05-27 09:10:55 -04:00
|
|
|
def setup
|
|
|
|
@@docDd = Document.new(<<-EOS, :ignore_whitespace_nodes => :all)
|
|
|
|
<a>
|
|
|
|
<b x='ab01A'>
|
|
|
|
<c y='abc01A'>Success</c>
|
|
|
|
</b>
|
|
|
|
<b x='ab02A' y='ab02B'>
|
|
|
|
<c>abc02C</c>
|
|
|
|
</b>
|
|
|
|
</a>
|
|
|
|
EOS
|
|
|
|
end
|
2010-09-17 09:14:14 -04:00
|
|
|
|
2014-05-27 09:10:55 -04:00
|
|
|
def test_Dd_preceding_sibling_children
|
|
|
|
arr = []
|
|
|
|
XPath.each(@@docDd, "//b[@x='ab02A']/preceding-sibling::b/child::*") do |cell|
|
|
|
|
arr << cell.texts.join
|
|
|
|
end
|
|
|
|
assert_equal( 'Success', arr.join )
|
2010-09-17 09:14:14 -04:00
|
|
|
end
|
|
|
|
|
2014-05-27 09:10:55 -04:00
|
|
|
def test_Dd_preceding_sibling_all
|
|
|
|
arr = []
|
|
|
|
XPath.each(@@docDd, "//b[@x='ab02A']/preceding-sibling::*") do |cell|
|
|
|
|
arr << cell.to_s
|
|
|
|
end
|
|
|
|
assert_equal( "<b x='ab01A'><c y='abc01A'>Success</c></b>", arr.join )
|
2010-09-17 09:14:14 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|