File: tc_xml_node_set2.rb

package info (click to toggle)
libxml-ruby 0.5.2.0-3%2Blenny1
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 652 kB
  • ctags: 875
  • sloc: ansic: 5,874; ruby: 1,524; xml: 144; makefile: 9
file content (38 lines) | stat: -rw-r--r-- 1,010 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# $Id: tc_xml_node_set2.rb 183 2007-09-21 14:09:52Z danj $
require "libxml_test"
require 'test/unit'

class TC_XML_Node_Set2 < Test::Unit::TestCase
  def setup()
    xp = XML::Parser.new()
    str = '<ruby_array uga="booga" foo="bar"><fixnum>one</fixnum><fixnum>two</fixnum></ruby_array>'
    assert_equal(str, xp.string = str)
    doc = xp.parse
    assert_instance_of(XML::Document, doc)
    @one = doc.root.child
    @two = @one.next    
    @set = doc.find('/ruby_array/fixnum').set
    @emptyset = doc.find('/fixnum').set
    assert_instance_of(XML::Node::Set, @set)    
  end

  def teardown()
    @set, @emptyset, @one, @two = [nil] * 4
  end

  def test_libxml_nodeset_to_a()
    assert_equal [@one, @two], @set.to_a
    assert_equal [], @emptyset.to_a
  end

  def test_libxml_nodeset_empty?()
    assert ! @set.empty?
    assert @emptyset.empty?
  end

  def test_libxml_nodeset_first()
    assert_equal @one.to_s, @set.first.to_s
    assert_equal nil, @emptyset.first
  end
  
end # TC_XML_Document