Sha256: ec3d9afbe042f22d122cfc5a521037c383081e6a4c1a347f0ea2a31e71211dec

Contents?: true

Size: 1007 Bytes

Versions: 3

Compression:

Stored size: 1007 Bytes

Contents

# $Id: tc_xml_node_set2.rb 107 2006-11-20 01:22:08Z roscopeco $
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')
    @emptyset = doc.find('/fixnum')
    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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
libxml-ruby-0.5.0 tests/tc_xml_node_set2.rb
libxml-ruby-0.5.0.1 tests/tc_xml_node_set2.rb
libxml-ruby-0.5.1.0 tests/tc_xml_node_set2.rb