root / test / test_xpath_msw.rb

Revision 549:e07d72733cae, 1.0 kB (checked in by Sean Russell <ser@…>, 5 months ago)

Moved and renamed files to conform to Ruby's test suite.

Line 
1require "test/unit/testcase"
2require "test/unit/ui/console/testrunner"
3require "rexml/document"
4
5class XPathAxesTester < Test::Unit::TestCase
6        include REXML
7        SOURCE = <<-EOF
8    <a id='1'>
9      <e id='2'>
10        <f id='3'/>
11        <f id='4'/>
12        <f id='5'/>
13        <f id='6'/>
14      </e>
15    </a>
16    EOF
17
18        def setup
19          @@doc = Document.new(SOURCE) unless defined? @@doc
20        end
21
22  def test_preceding_sibling_axis
23    context = XPath.first(@@doc,"/a/e/f[last()]")
24    assert_equal "6", context.attributes["id"]
25
26    prev = XPath.first(context, "preceding-sibling::f")
27    assert_equal "5", prev.attributes["id"]
28
29    prev = XPath.first(context, "preceding-sibling::f[1]")
30    assert_equal "5", prev.attributes["id"]
31
32    prev = XPath.first(context, "preceding-sibling::f[2]")
33    assert_equal "4", prev.attributes["id"]
34
35    prev = XPath.first(context, "preceding-sibling::f[3]")
36    assert_equal "3", prev.attributes["id"]
37  end
38end
39
40
41#Test::Unit::UI::Console::TestRunner.run(XPathAxesTester.suite)
42
Note: See TracBrowser for help on using the browser.