Sha256: 7eea6730a5a9bb856bbfec8cb56a5189b15ca76ef564ee51ceb802d5353413e2

Contents?: true

Size: 1.46 KB

Versions: 3

Compression:

Stored size: 1.46 KB

Contents

# $Id: tc_xml_node.rb,v 1.3 2006/04/17 13:30:19 roscopeco Exp $
require "libxml_test"
require 'test/unit'

class TC_XML_Node < 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)
    @root = doc.root
    assert_instance_of(XML::Node, @root)
    set = doc.find('/ruby_array/fixnum')
    assert_instance_of(XML::Node::Set, set)
    xpt = set.xpath
    assert_instance_of(XML::XPath, xpt)
    @nodes = []
    set.each do |n|
      @nodes.push(n)
    end
  end

  def teardown()
    @nodes = nil
    @root = nil
  end

  def test_libxml_node_class()
    for n in @nodes
      assert_instance_of(XML::Node, n)
    end
  end

  def test_libxml_node_child_get()
    assert_instance_of(TrueClass, @root.child?)
    assert_instance_of(XML::Node, @root.child)
    assert_equal('fixnum', @root.child.name)
  end

  def test_libxml_node_doc()
    for n in @nodes
      assert_instance_of(XML::Document, n.doc) if n.document?
    end
  end

  def test_libxml_node_type_name()
    assert_equal('element', @nodes[0].node_type_name)
    assert_equal('element', @nodes[1].node_type_name)
  end

  def test_libxml_node_find()
    set = @root.find('./fixnum')
    assert_instance_of(XML::Node::Set, set)
    for node in set
      assert_instance_of(XML::Node, node)
    end
  end
end # TC_XML_Document

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
libxml-ruby-0.3.8 tests/tc_xml_node.rb
libxml-ruby-0.3.8.2 tests/tc_xml_node.rb
libxml-ruby-0.3.8.4 tests/tc_xml_node.rb