libxml-ruby 0.6.0-x86-mswin32-60
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +122 -0
- data/LICENSE +23 -0
- data/README +144 -0
- data/ext/libxml/cbg.c +76 -0
- data/ext/libxml/extconf.rb +308 -0
- data/ext/libxml/libxml.c +62 -0
- data/ext/libxml/ruby_libxml.h +93 -0
- data/ext/libxml/ruby_xml_attr.c +405 -0
- data/ext/libxml/ruby_xml_attr.h +19 -0
- data/ext/libxml/ruby_xml_document.c +1111 -0
- data/ext/libxml/ruby_xml_document.h +27 -0
- data/ext/libxml/ruby_xml_dtd.c +168 -0
- data/ext/libxml/ruby_xml_dtd.h +17 -0
- data/ext/libxml/ruby_xml_html_parser.c +449 -0
- data/ext/libxml/ruby_xml_html_parser.h +29 -0
- data/ext/libxml/ruby_xml_input_cbg.c +158 -0
- data/ext/libxml/ruby_xml_input_cbg.h +20 -0
- data/ext/libxml/ruby_xml_node.c +2410 -0
- data/ext/libxml/ruby_xml_node.h +27 -0
- data/ext/libxml/ruby_xml_node_set.c +170 -0
- data/ext/libxml/ruby_xml_node_set.h +20 -0
- data/ext/libxml/ruby_xml_ns.c +153 -0
- data/ext/libxml/ruby_xml_ns.h +21 -0
- data/ext/libxml/ruby_xml_parser.c +1425 -0
- data/ext/libxml/ruby_xml_parser.h +31 -0
- data/ext/libxml/ruby_xml_parser_context.c +750 -0
- data/ext/libxml/ruby_xml_parser_context.h +22 -0
- data/ext/libxml/ruby_xml_reader.c +900 -0
- data/ext/libxml/ruby_xml_reader.h +14 -0
- data/ext/libxml/ruby_xml_sax_parser.c +485 -0
- data/ext/libxml/ruby_xml_sax_parser.h +56 -0
- data/ext/libxml/ruby_xml_schema.c +146 -0
- data/ext/libxml/ruby_xml_schema.h +16 -0
- data/ext/libxml/ruby_xml_state.c +113 -0
- data/ext/libxml/ruby_xml_state.h +12 -0
- data/ext/libxml/ruby_xml_tree.c +43 -0
- data/ext/libxml/ruby_xml_tree.h +12 -0
- data/ext/libxml/ruby_xml_xinclude.c +20 -0
- data/ext/libxml/ruby_xml_xinclude.h +13 -0
- data/ext/libxml/ruby_xml_xpath.c +243 -0
- data/ext/libxml/ruby_xml_xpath.h +23 -0
- data/ext/libxml/ruby_xml_xpath_context.c +118 -0
- data/ext/libxml/ruby_xml_xpath_context.h +20 -0
- data/ext/libxml/ruby_xml_xpath_object.c +293 -0
- data/ext/libxml/ruby_xml_xpath_object.h +28 -0
- data/ext/libxml/ruby_xml_xpointer.c +100 -0
- data/ext/libxml/ruby_xml_xpointer.h +27 -0
- data/ext/libxml/ruby_xml_xpointer_context.c +21 -0
- data/ext/libxml/ruby_xml_xpointer_context.h +18 -0
- data/ext/libxml/sax_parser_callbacks.inc +213 -0
- data/ext/libxml/version.h +9 -0
- data/lib/libxml.rb +125 -0
- data/lib/libxml_ruby.so +0 -0
- data/lib/xml/libxml.rb +5 -0
- data/mingw/libiconv-2.dll +0 -0
- data/mingw/libxml2-2.dll +0 -0
- data/mingw/libxml_ruby.so +0 -0
- data/mingw/mingw.rake +36 -0
- data/test/dtd-test.rb +24 -0
- data/test/etc_doc_to_s.rb +19 -0
- data/test/ets_copy_bug.rb +21 -0
- data/test/ets_copy_bug2.rb +32 -0
- data/test/ets_copy_bug3.rb +38 -0
- data/test/ets_doc_file.rb +15 -0
- data/test/ets_doc_to_s.rb +21 -0
- data/test/ets_gpx.rb +26 -0
- data/test/ets_node_gc.rb +21 -0
- data/test/ets_test.xml +2 -0
- data/test/ets_tsr.rb +9 -0
- data/test/gc.log +0 -0
- data/test/merge_bug.rb +55 -0
- data/test/schema-test.rb +74 -0
- data/test/tc_well_formed.rb +11 -0
- data/test/tc_xml_document.rb +52 -0
- data/test/tc_xml_document_write.rb +24 -0
- data/test/tc_xml_document_write2.rb +54 -0
- data/test/tc_xml_document_write3.rb +96 -0
- data/test/tc_xml_html_parser.rb +63 -0
- data/test/tc_xml_node.rb +59 -0
- data/test/tc_xml_node2.rb +25 -0
- data/test/tc_xml_node3.rb +27 -0
- data/test/tc_xml_node4.rb +86 -0
- data/test/tc_xml_node5.rb +52 -0
- data/test/tc_xml_node6.rb +27 -0
- data/test/tc_xml_node7.rb +35 -0
- data/test/tc_xml_node8.rb +32 -0
- data/test/tc_xml_node9.rb +32 -0
- data/test/tc_xml_node_copy.rb +40 -0
- data/test/tc_xml_node_set.rb +24 -0
- data/test/tc_xml_node_set2.rb +37 -0
- data/test/tc_xml_node_text.rb +17 -0
- data/test/tc_xml_node_xlink.rb +28 -0
- data/test/tc_xml_parser.rb +190 -0
- data/test/tc_xml_parser2.rb +16 -0
- data/test/tc_xml_parser3.rb +23 -0
- data/test/tc_xml_parser4.rb +33 -0
- data/test/tc_xml_parser5.rb +27 -0
- data/test/tc_xml_parser6.rb +23 -0
- data/test/tc_xml_parser7.rb +28 -0
- data/test/tc_xml_parser8.rb +32 -0
- data/test/tc_xml_parser9.rb +11 -0
- data/test/tc_xml_parser_context.rb +88 -0
- data/test/tc_xml_reader.rb +112 -0
- data/test/tc_xml_sax_parser.rb +104 -0
- data/test/tc_xml_sax_parser2.rb +51 -0
- data/test/tc_xml_xinclude.rb +30 -0
- data/test/tc_xml_xpath.rb +38 -0
- data/test/tc_xml_xpath2.rb +14 -0
- data/test/tc_xml_xpointer.rb +78 -0
- data/vc/libxml.sln +20 -0
- data/vc/libxml.vcproj +389 -0
- data/work/Rakefile +247 -0
- data/work/task/make +26 -0
- data/work/task/memory +37 -0
- data/work/task/rdoc +39 -0
- data/work/task/setup +1616 -0
- data/work/task/test +29 -0
- data/work/test/ets_runner.rb +33 -0
- data/work/test/libxml_test.rb +3 -0
- data/work/test/runner.rb +0 -0
- data/work/test/runner_ets.rb +33 -0
- data/work/vc/debug/libxml.exp +0 -0
- data/work/vc/debug/libxml.ilk +0 -0
- data/work/vc/debug/libxml.lib +0 -0
- data/work/vc/debug/libxml.pdb +0 -0
- data/work/vc/debug/libxml.so +0 -0
- metadata +224 -0
@@ -0,0 +1,52 @@
|
|
1
|
+
require "libxml"
|
2
|
+
require 'test/unit'
|
3
|
+
|
4
|
+
class TC_XML_Node5 < Test::Unit::TestCase
|
5
|
+
def setup()
|
6
|
+
xp = XML::Parser.new()
|
7
|
+
str = '<test><num>one</num><num>two</num><num>three</num></test>'
|
8
|
+
assert_equal(str, xp.string = str)
|
9
|
+
@doc = xp.parse
|
10
|
+
assert_instance_of(XML::Document, @doc)
|
11
|
+
@root = @doc.root
|
12
|
+
@num1 = @root.child
|
13
|
+
@num2 = @num1.next
|
14
|
+
@num3 = @num2.next
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_libxml_node_add_next_01
|
18
|
+
@num1.next = XML::Node.new('num', 'one-and-a-half')
|
19
|
+
assert_equal '<test><num>one</num><num>one-and-a-half</num><num>two</num><num>three</num></test>',
|
20
|
+
@root.to_s.gsub(/\n\s*/,'')
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_libxml_node_add_next_02
|
24
|
+
@num2.next = XML::Node.new('num', 'two-and-a-half')
|
25
|
+
assert_equal '<test><num>one</num><num>two</num><num>two-and-a-half</num><num>three</num></test>',
|
26
|
+
@root.to_s.gsub(/\n\s*/,'')
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_libxml_node_add_next_03
|
30
|
+
@num3.next = XML::Node.new('num', 'four')
|
31
|
+
assert_equal '<test><num>one</num><num>two</num><num>three</num><num>four</num></test>',
|
32
|
+
@root.to_s.gsub(/\n\s*/,'')
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_libxml_node_add_prev_01
|
36
|
+
@num1.prev = XML::Node.new('num', 'half')
|
37
|
+
assert_equal '<test><num>half</num><num>one</num><num>two</num><num>three</num></test>',
|
38
|
+
@root.to_s.gsub(/\n\s*/,'')
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_libxml_node_add_prev_02
|
42
|
+
@num2.prev = XML::Node.new('num', 'one-and-a-half')
|
43
|
+
assert_equal '<test><num>one</num><num>one-and-a-half</num><num>two</num><num>three</num></test>',
|
44
|
+
@root.to_s.gsub(/\n\s*/,'')
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_libxml_node_add_prev_03
|
48
|
+
@num3.prev = XML::Node.new('num', 'two-and-a-half')
|
49
|
+
assert_equal '<test><num>one</num><num>two</num><num>two-and-a-half</num><num>three</num></test>',
|
50
|
+
@root.to_s.gsub(/\n\s*/,'')
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require "libxml"
|
2
|
+
require 'test/unit'
|
3
|
+
|
4
|
+
class TC_XML_Node6 < Test::Unit::TestCase
|
5
|
+
def setup()
|
6
|
+
xp = XML::Parser.string('<ruby_array uga="booga" foo="bar"><fixnum>one</fixnum><fixnum>two</fixnum></ruby_array>')
|
7
|
+
doc = xp.parse
|
8
|
+
@root = doc.root
|
9
|
+
assert_equal 'bar', @root['foo']
|
10
|
+
end
|
11
|
+
|
12
|
+
def teardown()
|
13
|
+
@root = nil
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_xml_node_prop_get_str_sym()
|
17
|
+
assert_equal @root['foo'], @root[:foo]
|
18
|
+
assert_equal @root['uga'], @root[:uga]
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_xml_node_prop_set_str_sym()
|
22
|
+
@root[:foo] = 'boo'
|
23
|
+
@root[:uga] = 'zoo'
|
24
|
+
assert_equal 'boo', @root['foo']
|
25
|
+
assert_equal 'zoo', @root['uga']
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require "libxml"
|
2
|
+
require 'test/unit'
|
3
|
+
|
4
|
+
class TC_XML_Node7 < Test::Unit::TestCase
|
5
|
+
def setup()
|
6
|
+
xp = XML::Parser.string('<ruby_array uga="booga" foo="bar"><fixnum>one</fixnum><fixnum>two</fixnum></ruby_array>')
|
7
|
+
doc = xp.parse
|
8
|
+
@root = doc.root
|
9
|
+
assert_equal 'bar', @root['foo']
|
10
|
+
end
|
11
|
+
|
12
|
+
def teardown()
|
13
|
+
@root = nil
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_xml_node_properties_traversal_bug()
|
17
|
+
prop = @root.properties
|
18
|
+
assert_instance_of XML::Attr, prop
|
19
|
+
assert_equal 'uga', prop.name
|
20
|
+
assert_equal 'booga', prop.value
|
21
|
+
|
22
|
+
prop = prop.next
|
23
|
+
assert_instance_of XML::Attr, prop
|
24
|
+
assert_equal 'foo', prop.name
|
25
|
+
assert_equal 'bar', prop.value
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_xml_node_properties_when_no_attributes
|
29
|
+
xp = XML::Parser.string("<root></root>")
|
30
|
+
doc = xp.parse
|
31
|
+
root = doc.root
|
32
|
+
|
33
|
+
assert_nil root.properties
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require "libxml"
|
2
|
+
require 'test/unit'
|
3
|
+
|
4
|
+
class TC_XML_Node8 < Test::Unit::TestCase
|
5
|
+
def setup()
|
6
|
+
xp = XML::Parser.new()
|
7
|
+
str = '<root></root>'
|
8
|
+
assert_equal(str, xp.string = str)
|
9
|
+
@doc = xp.parse
|
10
|
+
assert_instance_of(XML::Document, @doc)
|
11
|
+
@root = @doc.root
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_libxml_node_add_cdata_01
|
15
|
+
@root << XML::Node.new_cdata('mycdata')
|
16
|
+
assert_equal '<root><![CDATA[mycdata]]></root>',
|
17
|
+
@root.to_s.gsub(/\n\s*/,'')
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_libxml_node_add_cdata_02
|
21
|
+
@root << XML::Node.new_cdata('mycdata')
|
22
|
+
assert_equal 'cdata',
|
23
|
+
@root.child.node_type_name
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_libxml_node_add_cdata_03
|
27
|
+
@root << el = XML::Node.new_cdata('mycdata')
|
28
|
+
el << "_this_is_added"
|
29
|
+
assert_equal '<root><![CDATA[mycdata_this_is_added]]></root>',
|
30
|
+
@root.to_s.gsub(/\n\s*/,'')
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require "libxml"
|
2
|
+
require 'test/unit'
|
3
|
+
|
4
|
+
class TC_XML_Node9 < Test::Unit::TestCase
|
5
|
+
def setup()
|
6
|
+
xp = XML::Parser.new()
|
7
|
+
str = '<root></root>'
|
8
|
+
assert_equal(str, xp.string = str)
|
9
|
+
@doc = xp.parse
|
10
|
+
assert_instance_of(XML::Document, @doc)
|
11
|
+
@root = @doc.root
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_libxml_node_add_comment_01
|
15
|
+
@root << XML::Node.new_comment('mycomment')
|
16
|
+
assert_equal '<root><!--mycomment--></root>',
|
17
|
+
@root.to_s.gsub(/\n\s*/,'')
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_libxml_node_add_comment_02
|
21
|
+
@root << XML::Node.new_comment('mycomment')
|
22
|
+
assert_equal 'comment',
|
23
|
+
@root.child.node_type_name
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_libxml_node_add_comment_03
|
27
|
+
@root << el = XML::Node.new_comment('mycomment')
|
28
|
+
el << "_this_is_added"
|
29
|
+
assert_equal '<root><!--mycomment_this_is_added--></root>',
|
30
|
+
@root.to_s.gsub(/\n\s*/,'')
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require "libxml"
|
2
|
+
require 'test/unit'
|
3
|
+
|
4
|
+
# see mailing list archive
|
5
|
+
# [libxml-devel] Segmentation fault when add the cloned/copied node
|
6
|
+
# 2007/11/27 20:51
|
7
|
+
|
8
|
+
class TC_XML_Node_Copy < Test::Unit::TestCase
|
9
|
+
def setup
|
10
|
+
str = <<-STR
|
11
|
+
<html><body>
|
12
|
+
<div class="textarea" id="t1" style="STATIC">foo</div>
|
13
|
+
<div class="textarea" id="t2" style="STATIC">bar</div>
|
14
|
+
</body></html>
|
15
|
+
STR
|
16
|
+
|
17
|
+
doc = XML::Parser.string(str).parse
|
18
|
+
|
19
|
+
xpath = "//div"
|
20
|
+
@div1 = doc.find(xpath).to_a[0]
|
21
|
+
@div2 = doc.find(xpath).to_a[1]
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_libxml_node_copy_not_segv
|
25
|
+
@div2.each do |child|
|
26
|
+
c = child.copy(false)
|
27
|
+
@div1.child_add(c)
|
28
|
+
end
|
29
|
+
assert @div1.to_s =~ /foo/
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_libxml_node_clone_not_segv
|
33
|
+
@div2.each do |child|
|
34
|
+
c = child.clone
|
35
|
+
@div1.child_add(c)
|
36
|
+
end
|
37
|
+
assert @div1.to_s =~ /foo/
|
38
|
+
end
|
39
|
+
|
40
|
+
end # TC_XML_Node_Copy
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require "libxml"
|
2
|
+
require 'test/unit'
|
3
|
+
|
4
|
+
class TC_XML_Node_Set < Test::Unit::TestCase
|
5
|
+
def setup()
|
6
|
+
xp = XML::Parser.new()
|
7
|
+
str = '<ruby_array uga="booga" foo="bar"><fixnum>one</fixnum><fixnum>two</fixnum></ruby_array>'
|
8
|
+
assert_equal(str, xp.string = str)
|
9
|
+
doc = xp.parse
|
10
|
+
assert_instance_of(XML::Document, doc)
|
11
|
+
@set = doc.find('/ruby_array/fixnum').set
|
12
|
+
assert_instance_of(XML::Node::Set, @set)
|
13
|
+
end
|
14
|
+
|
15
|
+
def teardown()
|
16
|
+
@set = nil
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_libxml_nodeset_each()
|
20
|
+
@set.each do |n|
|
21
|
+
assert_instance_of(XML::Node, n)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end # TC_XML_Document
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require "libxml"
|
2
|
+
require 'test/unit'
|
3
|
+
|
4
|
+
class TC_XML_Node_Set2 < Test::Unit::TestCase
|
5
|
+
def setup()
|
6
|
+
xp = XML::Parser.new()
|
7
|
+
str = '<ruby_array uga="booga" foo="bar"><fixnum>one</fixnum><fixnum>two</fixnum></ruby_array>'
|
8
|
+
assert_equal(str, xp.string = str)
|
9
|
+
doc = xp.parse
|
10
|
+
assert_instance_of(XML::Document, doc)
|
11
|
+
@one = doc.root.child
|
12
|
+
@two = @one.next
|
13
|
+
@set = doc.find('/ruby_array/fixnum').set
|
14
|
+
@emptyset = doc.find('/fixnum').set
|
15
|
+
assert_instance_of(XML::Node::Set, @set)
|
16
|
+
end
|
17
|
+
|
18
|
+
def teardown()
|
19
|
+
@set, @emptyset, @one, @two = [nil] * 4
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_libxml_nodeset_to_a()
|
23
|
+
assert_equal [@one, @two], @set.to_a
|
24
|
+
assert_equal [], @emptyset.to_a
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_libxml_nodeset_empty?()
|
28
|
+
assert ! @set.empty?
|
29
|
+
assert @emptyset.empty?
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_libxml_nodeset_first()
|
33
|
+
assert_equal @one.to_s, @set.first.to_s
|
34
|
+
assert_equal nil, @emptyset.first
|
35
|
+
end
|
36
|
+
|
37
|
+
end # TC_XML_Document
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'libxml'
|
2
|
+
require 'test/unit'
|
3
|
+
|
4
|
+
class TC_XML_Node_text < Test::Unit::TestCase
|
5
|
+
def setup
|
6
|
+
@t=XML::Node.new_text("testdata")
|
7
|
+
assert_instance_of(XML::Node,@t)
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_content
|
11
|
+
assert_equal("testdata",@t.content)
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_type
|
15
|
+
assert_equal(true,@t.text?)
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# $Id: tc_xml_node_xlink.rb 251 2008-01-22 18:12:00Z transami $
|
2
|
+
require "libxml"
|
3
|
+
require 'test/unit'
|
4
|
+
|
5
|
+
class TC_XML_Node_XLink < Test::Unit::TestCase
|
6
|
+
def setup()
|
7
|
+
xp = XML::Parser.new()
|
8
|
+
str = '<ruby_array xmlns:xlink="http://www.w3.org/1999/xlink/namespace/"><fixnum xlink:type="simple">one</fixnum></ruby_array>'
|
9
|
+
assert_equal(str, xp.string = str)
|
10
|
+
doc = xp.parse
|
11
|
+
assert_instance_of(XML::Document, doc)
|
12
|
+
@root = doc.root
|
13
|
+
assert_instance_of(XML::Node, @root)
|
14
|
+
end
|
15
|
+
|
16
|
+
def teardown()
|
17
|
+
@root = nil
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_xml_node_xlink()
|
21
|
+
for elem in @root.find('fixnum')
|
22
|
+
assert_instance_of(XML::Node, elem)
|
23
|
+
assert_instance_of(TrueClass, elem.xlink?)
|
24
|
+
assert_equal("simple", elem.xlink_type_name)
|
25
|
+
assert_equal(XML::Node::XLINK_TYPE_SIMPLE, elem.xlink_type)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,190 @@
|
|
1
|
+
require "libxml"
|
2
|
+
require 'test/unit'
|
3
|
+
|
4
|
+
class TC_XML_Parser < Test::Unit::TestCase
|
5
|
+
def setup()
|
6
|
+
@xp = XML::Parser.new()
|
7
|
+
assert_not_nil(@xp)
|
8
|
+
end
|
9
|
+
|
10
|
+
def teardown()
|
11
|
+
@xp = nil
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_libxml_parser_string()
|
15
|
+
str = '<ruby_array uga="booga" foo="bar"><fixnum>one</fixnum><fixnum>two</fixnum></ruby_array>'
|
16
|
+
assert_equal(str, @xp.string = str)
|
17
|
+
assert_instance_of(XML::Document, @xp.parse)
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_libxml_parser_bad_xml()
|
21
|
+
@xp.string = '<ruby_array uga="booga" foo="bar"<fixnum>one</fixnum><fixnum>two</fixnum></ruby_array>'
|
22
|
+
assert_raise(XML::Parser::ParseError) do
|
23
|
+
assert_not_nil(@xp.parse)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_libxml_parser_empty_string
|
28
|
+
assert_raise(XML::Parser::ParseError) do
|
29
|
+
@xp.string = ''
|
30
|
+
end
|
31
|
+
|
32
|
+
assert_raise(TypeError) do
|
33
|
+
@xp.string = nil
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_ruby_xml_parser_check_lib_versions()
|
38
|
+
assert(XML::Parser::check_lib_versions)
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_ruby_xml_parser_debug_entities()
|
42
|
+
XML::Parser::debug_entities = false
|
43
|
+
assert(!XML::Parser::debug_entities)
|
44
|
+
|
45
|
+
XML::Parser::debug_entities = true
|
46
|
+
assert(XML::Parser::debug_entities)
|
47
|
+
|
48
|
+
XML::Parser::debug_entities = false
|
49
|
+
assert(!XML::Parser::debug_entities)
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_ruby_xml_parser_default_compression()
|
53
|
+
0.upto(9) do |i|
|
54
|
+
XML::Parser::default_compression = i
|
55
|
+
assert_equal(i, XML::Parser::default_compression)
|
56
|
+
end
|
57
|
+
|
58
|
+
9.downto(0) do |i|
|
59
|
+
assert_equal(i, XML::Parser::default_compression = i)
|
60
|
+
assert_equal(i, XML::Parser::default_compression)
|
61
|
+
end
|
62
|
+
|
63
|
+
0.downto(-10) do |i|
|
64
|
+
assert_equal(i, XML::Parser::default_compression = i)
|
65
|
+
assert_equal(0, XML::Parser::default_compression)
|
66
|
+
end
|
67
|
+
|
68
|
+
10.upto(20) do |i|
|
69
|
+
assert_equal(i, XML::Parser::default_compression = i)
|
70
|
+
assert_equal(9, XML::Parser::default_compression)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def test_ruby_xml_parser_default_keep_blanks()
|
75
|
+
XML::Parser::default_keep_blanks = false
|
76
|
+
assert(!XML::Parser::default_keep_blanks)
|
77
|
+
|
78
|
+
XML::Parser::default_keep_blanks = true
|
79
|
+
assert(XML::Parser::default_keep_blanks)
|
80
|
+
|
81
|
+
XML::Parser::default_keep_blanks = false
|
82
|
+
assert(!XML::Parser::default_keep_blanks)
|
83
|
+
|
84
|
+
# other tests depend on keeping blanks by default,
|
85
|
+
# which is the default default behaviour anyway.
|
86
|
+
XML::Parser::default_keep_blanks = true
|
87
|
+
end
|
88
|
+
|
89
|
+
def test_ruby_xml_parser_default_line_numbers()
|
90
|
+
XML::Parser::default_line_numbers = false
|
91
|
+
assert(!XML::Parser::default_line_numbers)
|
92
|
+
|
93
|
+
XML::Parser::default_line_numbers = true
|
94
|
+
assert(XML::Parser::default_line_numbers)
|
95
|
+
|
96
|
+
XML::Parser::default_line_numbers = false
|
97
|
+
assert(!XML::Parser::default_line_numbers)
|
98
|
+
end
|
99
|
+
|
100
|
+
def test_ruby_xml_parser_default_substitute_entities()
|
101
|
+
XML::Parser::default_substitute_entities = false
|
102
|
+
assert(!XML::Parser::default_substitute_entities)
|
103
|
+
|
104
|
+
XML::Parser::default_substitute_entities = true
|
105
|
+
assert(XML::Parser::default_substitute_entities)
|
106
|
+
|
107
|
+
XML::Parser::default_substitute_entities = false
|
108
|
+
assert(!XML::Parser::default_substitute_entities)
|
109
|
+
end
|
110
|
+
|
111
|
+
def test_ruby_xml_parser_default_tree_indent_string()
|
112
|
+
s = XML::Parser::default_tree_indent_string()
|
113
|
+
assert_instance_of(String, s)
|
114
|
+
assert_equal(' ', s)
|
115
|
+
XML::Parser::default_tree_indent_string = 'uga'
|
116
|
+
s = XML::Parser::default_tree_indent_string()
|
117
|
+
assert_instance_of(String, s)
|
118
|
+
assert_equal('uga', s)
|
119
|
+
XML::Parser::default_tree_indent_string = ' '
|
120
|
+
s = XML::Parser::default_tree_indent_string()
|
121
|
+
assert_instance_of(String, s)
|
122
|
+
assert_equal(' ', s)
|
123
|
+
end
|
124
|
+
|
125
|
+
def test_ruby_xml_parser_default_validity_checking()
|
126
|
+
XML::Parser::default_validity_checking = false
|
127
|
+
assert(!XML::Parser::default_validity_checking)
|
128
|
+
|
129
|
+
XML::Parser::default_validity_checking = true
|
130
|
+
assert(XML::Parser::default_validity_checking)
|
131
|
+
|
132
|
+
XML::Parser::default_validity_checking = false
|
133
|
+
assert(!XML::Parser::default_validity_checking)
|
134
|
+
end
|
135
|
+
|
136
|
+
def test_ruby_xml_parser_default_warnings()
|
137
|
+
XML::Parser::default_warnings = false
|
138
|
+
assert(!XML::Parser::default_warnings)
|
139
|
+
|
140
|
+
XML::Parser::default_warnings = true
|
141
|
+
assert(XML::Parser::default_warnings)
|
142
|
+
|
143
|
+
XML::Parser::default_warnings = false
|
144
|
+
assert(!XML::Parser::default_warnings)
|
145
|
+
end
|
146
|
+
|
147
|
+
def test_ruby_xml_parser_intent_tree_output()
|
148
|
+
assert(TrueClass, XML::Parser::indent_tree_output)
|
149
|
+
|
150
|
+
XML::Parser::indent_tree_output = false
|
151
|
+
assert(FalseClass, XML::Parser::indent_tree_output)
|
152
|
+
|
153
|
+
XML::Parser::indent_tree_output = true
|
154
|
+
assert(TrueClass, XML::Parser::indent_tree_output)
|
155
|
+
end
|
156
|
+
|
157
|
+
def test_ruby_xml_parser_version()
|
158
|
+
assert_instance_of(String, XML::Parser::VERSION)
|
159
|
+
end
|
160
|
+
|
161
|
+
def test_ruby_xml_parser_vernum()
|
162
|
+
assert_instance_of(Fixnum, XML::Parser::VERNUM)
|
163
|
+
end
|
164
|
+
|
165
|
+
def test_ruby_xml_parser_context()
|
166
|
+
@xp = XML::Parser.string('<rubynet><testing>uga</testing><uga>foo</uga></rubynet>')
|
167
|
+
doc = @xp.parse
|
168
|
+
assert_instance_of(XML::Document, doc)
|
169
|
+
assert_instance_of(XML::Parser::Context, @xp.context)
|
170
|
+
end
|
171
|
+
|
172
|
+
def test_libxml_parser_file()
|
173
|
+
file = File.expand_path('model/rubynet.xml')
|
174
|
+
|
175
|
+
assert_equal(file, @xp.filename = file)
|
176
|
+
assert_instance_of(XML::Document, @xp.parse)
|
177
|
+
end
|
178
|
+
|
179
|
+
def test_libxml_parser_io()
|
180
|
+
File.open('model/rubynet.xml') do |f|
|
181
|
+
assert_kind_of(IO, f)
|
182
|
+
assert_kind_of(IO, @xp.io = f)
|
183
|
+
assert_instance_of(XML::Document, @xp.parse)
|
184
|
+
end # File.open
|
185
|
+
end # def test_libxml_parser_io()
|
186
|
+
|
187
|
+
def test_libxml_parser_features()
|
188
|
+
assert_instance_of(Array, XML::Parser::features)
|
189
|
+
end
|
190
|
+
end # TC_XML_Parser
|