libxml-ruby 4.1.1-x64-mingw-ucrt → 5.0.0-x64-mingw-ucrt
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/HISTORY +22 -0
- data/ext/libxml/extconf.rb +67 -61
- data/ext/libxml/ruby_libxml.h +43 -44
- data/ext/libxml/ruby_xml.c +0 -343
- data/ext/libxml/ruby_xml.h +9 -10
- data/ext/libxml/ruby_xml_attr_decl.c +154 -153
- data/ext/libxml/ruby_xml_attributes.c +276 -275
- data/ext/libxml/ruby_xml_attributes.h +2 -0
- data/ext/libxml/ruby_xml_document.c +6 -6
- data/ext/libxml/ruby_xml_document.h +11 -11
- data/ext/libxml/ruby_xml_dtd.c +3 -3
- data/ext/libxml/ruby_xml_encoding.h +20 -18
- data/ext/libxml/ruby_xml_error.c +9 -6
- data/ext/libxml/ruby_xml_error.h +2 -2
- data/ext/libxml/ruby_xml_html_parser_context.c +35 -21
- data/ext/libxml/ruby_xml_namespace.c +0 -3
- data/ext/libxml/ruby_xml_node.c +1394 -1398
- data/ext/libxml/ruby_xml_parser.h +1 -1
- data/ext/libxml/ruby_xml_parser_context.c +47 -39
- data/ext/libxml/ruby_xml_parser_options.c +9 -1
- data/ext/libxml/ruby_xml_parser_options.h +1 -1
- data/ext/libxml/ruby_xml_reader.c +1244 -1242
- data/ext/libxml/ruby_xml_relaxng.c +113 -112
- data/ext/libxml/ruby_xml_sax2_handler.c +1 -1
- data/ext/libxml/ruby_xml_sax_parser.c +1 -9
- data/ext/libxml/ruby_xml_schema.c +422 -420
- data/ext/libxml/ruby_xml_schema_attribute.c +108 -107
- data/ext/libxml/ruby_xml_schema_element.c +70 -69
- data/ext/libxml/ruby_xml_schema_type.c +252 -251
- data/ext/libxml/ruby_xml_version.h +5 -5
- data/ext/libxml/ruby_xml_writer.c +1138 -1137
- data/ext/libxml/ruby_xml_xpath.c +1 -1
- data/ext/libxml/ruby_xml_xpath_context.c +2 -2
- data/ext/libxml/ruby_xml_xpath_expression.c +81 -81
- data/ext/libxml/ruby_xml_xpath_object.c +340 -339
- data/lib/3.2/libxml_ruby.so +0 -0
- data/lib/3.3/libxml_ruby.so +0 -0
- data/lib/libxml/document.rb +13 -13
- data/lib/libxml/html_parser.rb +23 -23
- data/lib/libxml/parser.rb +26 -24
- data/lib/libxml/schema/element.rb +27 -19
- data/test/test.rb +5 -0
- data/test/test_document_write.rb +1 -4
- data/test/test_dtd.rb +1 -4
- data/test/test_encoding.rb +1 -4
- data/test/test_helper.rb +9 -2
- data/test/test_html_parser.rb +162 -162
- data/test/test_namespace.rb +1 -3
- data/test/test_node.rb +1 -3
- data/test/test_node_write.rb +1 -4
- data/test/test_parser.rb +26 -17
- data/test/test_reader.rb +4 -4
- data/test/test_sax_parser.rb +1 -1
- data/test/test_schema.rb +237 -231
- data/test/test_xml.rb +0 -99
- metadata +5 -4
- data/lib/3.1/libxml_ruby.so +0 -0
data/test/test_html_parser.rb
CHANGED
@@ -1,162 +1,162 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
require_relative './test_helper'
|
4
|
-
require 'stringio'
|
5
|
-
|
6
|
-
class HTMLParserTest < Minitest::Test
|
7
|
-
def html_file
|
8
|
-
File.expand_path(File.join(File.dirname(__FILE__), 'model/ruby-lang.html'))
|
9
|
-
end
|
10
|
-
|
11
|
-
# ----- Sources ------
|
12
|
-
def test_file
|
13
|
-
xp = LibXML::XML::HTMLParser.file(html_file)
|
14
|
-
assert_instance_of(LibXML::XML::HTMLParser, xp)
|
15
|
-
doc = xp.parse
|
16
|
-
refute_nil(doc)
|
17
|
-
end
|
18
|
-
|
19
|
-
def test_noexistent_file
|
20
|
-
error = assert_raises(LibXML::XML::Error) do
|
21
|
-
LibXML::XML::HTMLParser.file('i_dont_exist.xml')
|
22
|
-
end
|
23
|
-
|
24
|
-
assert_equal('Warning: failed to load external entity "i_dont_exist.xml".', error.to_s)
|
25
|
-
end
|
26
|
-
|
27
|
-
def test_nil_file
|
28
|
-
error = assert_raises(TypeError) do
|
29
|
-
LibXML::XML::HTMLParser.file(nil)
|
30
|
-
end
|
31
|
-
|
32
|
-
assert_match(/nil into String/, error.to_s)
|
33
|
-
end
|
34
|
-
|
35
|
-
def test_io
|
36
|
-
File.open(html_file) do |io|
|
37
|
-
xp = LibXML::XML::HTMLParser.io(io)
|
38
|
-
assert_instance_of(LibXML::XML::HTMLParser, xp)
|
39
|
-
|
40
|
-
doc = xp.parse
|
41
|
-
assert_instance_of(LibXML::XML::Document, doc)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
def test_io_gc
|
46
|
-
# Test that the reader keeps a reference
|
47
|
-
# to the io object
|
48
|
-
file = File.open(html_file)
|
49
|
-
parser = LibXML::XML::HTMLParser.io(file)
|
50
|
-
file = nil
|
51
|
-
GC.start
|
52
|
-
assert(parser.parse)
|
53
|
-
end
|
54
|
-
|
55
|
-
def test_nil_io
|
56
|
-
error = assert_raises(TypeError) do
|
57
|
-
LibXML::XML::HTMLParser.io(nil)
|
58
|
-
end
|
59
|
-
|
60
|
-
assert_equal("Must pass in an IO object", error.to_s)
|
61
|
-
end
|
62
|
-
|
63
|
-
def test_string_io
|
64
|
-
data = File.read(html_file)
|
65
|
-
io = StringIO.new(data)
|
66
|
-
xp = LibXML::XML::HTMLParser.io(io)
|
67
|
-
assert_instance_of(LibXML::XML::HTMLParser, xp)
|
68
|
-
|
69
|
-
doc = xp.parse
|
70
|
-
assert_instance_of(LibXML::XML::Document, doc)
|
71
|
-
end
|
72
|
-
|
73
|
-
def test_string
|
74
|
-
str = '<html><body><p>hi</p></body></html>'
|
75
|
-
xp = LibXML::XML::HTMLParser.string(str)
|
76
|
-
|
77
|
-
assert_instance_of(LibXML::XML::HTMLParser, xp)
|
78
|
-
assert_instance_of(LibXML::XML::HTMLParser, xp)
|
79
|
-
|
80
|
-
doc = xp.parse
|
81
|
-
assert_instance_of(LibXML::XML::Document, doc)
|
82
|
-
end
|
83
|
-
|
84
|
-
def test_nil_string
|
85
|
-
error = assert_raises(TypeError) do
|
86
|
-
LibXML::XML::HTMLParser.string(nil)
|
87
|
-
end
|
88
|
-
|
89
|
-
assert_equal("wrong argument type nil (expected String)", error.to_s)
|
90
|
-
end
|
91
|
-
|
92
|
-
def test_parse
|
93
|
-
html = <<-EOS
|
94
|
-
<html>
|
95
|
-
<head>
|
96
|
-
<meta name=keywords content=nasty>
|
97
|
-
</head>
|
98
|
-
<body>Hello<br>World</html>
|
99
|
-
EOS
|
100
|
-
|
101
|
-
parser = LibXML::XML::HTMLParser.string(html, :options => LibXML::XML::HTMLParser::Options::NOBLANKS)
|
102
|
-
doc = parser.parse
|
103
|
-
assert_instance_of LibXML::XML::Document, doc
|
104
|
-
|
105
|
-
root = doc.root
|
106
|
-
assert_instance_of LibXML::XML::Node, root
|
107
|
-
assert_equal 'html', root.name
|
108
|
-
|
109
|
-
head = root.child
|
110
|
-
assert_instance_of LibXML::XML::Node, head
|
111
|
-
assert_equal 'head', head.name
|
112
|
-
|
113
|
-
meta = head.child
|
114
|
-
assert_instance_of LibXML::XML::Node, meta
|
115
|
-
assert_equal 'meta', meta.name
|
116
|
-
assert_equal 'keywords', meta[:name]
|
117
|
-
assert_equal 'nasty', meta[:content]
|
118
|
-
|
119
|
-
body = head.next
|
120
|
-
assert_instance_of LibXML::XML::Node, body
|
121
|
-
assert_equal 'body', body.name
|
122
|
-
|
123
|
-
hello = body.child
|
124
|
-
# It appears that some versions of libxml2 add a layer of <p>
|
125
|
-
# cant figure our why or how, so this skips it if there
|
126
|
-
hello = hello.child if hello.name == "p"
|
127
|
-
|
128
|
-
assert_instance_of LibXML::XML::Node, hello
|
129
|
-
assert_equal 'Hello', hello.content
|
130
|
-
|
131
|
-
br = hello.next
|
132
|
-
assert_instance_of LibXML::XML::Node, br
|
133
|
-
assert_equal 'br', br.name
|
134
|
-
|
135
|
-
world = br.next
|
136
|
-
assert_instance_of LibXML::XML::Node, world
|
137
|
-
assert_equal 'World', world.content
|
138
|
-
end
|
139
|
-
|
140
|
-
def test_no_implied
|
141
|
-
html = "hello world"
|
142
|
-
parser = LibXML::XML::HTMLParser.string(html, :options => LibXML::XML::HTMLParser::Options::NOIMPLIED)
|
143
|
-
doc = parser.parse
|
144
|
-
assert_equal("<p>#{html}</p>", doc.root.to_s)
|
145
|
-
end
|
146
|
-
|
147
|
-
def test_comment
|
148
|
-
doc = LibXML::XML::HTMLParser.string('<!-- stuff -->', :options => LibXML::XML::HTMLParser::Options::NOIMPLIED |
|
149
|
-
LibXML::XML::HTMLParser::Options::NOERROR |
|
150
|
-
LibXML::XML::HTMLParser::Options::NOWARNING |
|
151
|
-
LibXML::XML::HTMLParser::Options::RECOVER |
|
152
|
-
LibXML::XML::HTMLParser::Options::NONET)
|
153
|
-
assert(doc)
|
154
|
-
end
|
155
|
-
|
156
|
-
def test_open_many_files
|
157
|
-
file = File.expand_path(File.join(File.dirname(__FILE__), 'model/ruby-lang.html'))
|
158
|
-
1000.times do
|
159
|
-
LibXML::XML::HTMLParser.file(file).parse
|
160
|
-
end
|
161
|
-
end
|
162
|
-
end
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require_relative './test_helper'
|
4
|
+
require 'stringio'
|
5
|
+
|
6
|
+
class HTMLParserTest < Minitest::Test
|
7
|
+
def html_file
|
8
|
+
File.expand_path(File.join(File.dirname(__FILE__), 'model/ruby-lang.html'))
|
9
|
+
end
|
10
|
+
|
11
|
+
# ----- Sources ------
|
12
|
+
def test_file
|
13
|
+
xp = LibXML::XML::HTMLParser.file(html_file)
|
14
|
+
assert_instance_of(LibXML::XML::HTMLParser, xp)
|
15
|
+
doc = xp.parse
|
16
|
+
refute_nil(doc)
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_noexistent_file
|
20
|
+
error = assert_raises(LibXML::XML::Error) do
|
21
|
+
LibXML::XML::HTMLParser.file('i_dont_exist.xml')
|
22
|
+
end
|
23
|
+
|
24
|
+
assert_equal('Warning: failed to load external entity "i_dont_exist.xml".', error.to_s)
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_nil_file
|
28
|
+
error = assert_raises(TypeError) do
|
29
|
+
LibXML::XML::HTMLParser.file(nil)
|
30
|
+
end
|
31
|
+
|
32
|
+
assert_match(/nil into String/, error.to_s)
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_io
|
36
|
+
File.open(html_file) do |io|
|
37
|
+
xp = LibXML::XML::HTMLParser.io(io)
|
38
|
+
assert_instance_of(LibXML::XML::HTMLParser, xp)
|
39
|
+
|
40
|
+
doc = xp.parse
|
41
|
+
assert_instance_of(LibXML::XML::Document, doc)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_io_gc
|
46
|
+
# Test that the reader keeps a reference
|
47
|
+
# to the io object
|
48
|
+
file = File.open(html_file)
|
49
|
+
parser = LibXML::XML::HTMLParser.io(file)
|
50
|
+
file = nil
|
51
|
+
GC.start
|
52
|
+
assert(parser.parse)
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_nil_io
|
56
|
+
error = assert_raises(TypeError) do
|
57
|
+
LibXML::XML::HTMLParser.io(nil)
|
58
|
+
end
|
59
|
+
|
60
|
+
assert_equal("Must pass in an IO object", error.to_s)
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_string_io
|
64
|
+
data = File.read(html_file)
|
65
|
+
io = StringIO.new(data)
|
66
|
+
xp = LibXML::XML::HTMLParser.io(io)
|
67
|
+
assert_instance_of(LibXML::XML::HTMLParser, xp)
|
68
|
+
|
69
|
+
doc = xp.parse
|
70
|
+
assert_instance_of(LibXML::XML::Document, doc)
|
71
|
+
end
|
72
|
+
|
73
|
+
def test_string
|
74
|
+
str = '<html><body><p>hi</p></body></html>'
|
75
|
+
xp = LibXML::XML::HTMLParser.string(str)
|
76
|
+
|
77
|
+
assert_instance_of(LibXML::XML::HTMLParser, xp)
|
78
|
+
assert_instance_of(LibXML::XML::HTMLParser, xp)
|
79
|
+
|
80
|
+
doc = xp.parse
|
81
|
+
assert_instance_of(LibXML::XML::Document, doc)
|
82
|
+
end
|
83
|
+
|
84
|
+
def test_nil_string
|
85
|
+
error = assert_raises(TypeError) do
|
86
|
+
LibXML::XML::HTMLParser.string(nil)
|
87
|
+
end
|
88
|
+
|
89
|
+
assert_equal("wrong argument type nil (expected String)", error.to_s)
|
90
|
+
end
|
91
|
+
|
92
|
+
def test_parse
|
93
|
+
html = <<-EOS
|
94
|
+
<html>
|
95
|
+
<head>
|
96
|
+
<meta name=keywords content=nasty>
|
97
|
+
</head>
|
98
|
+
<body>Hello<br>World</html>
|
99
|
+
EOS
|
100
|
+
|
101
|
+
parser = LibXML::XML::HTMLParser.string(html, :options => LibXML::XML::HTMLParser::Options::NOBLANKS)
|
102
|
+
doc = parser.parse
|
103
|
+
assert_instance_of LibXML::XML::Document, doc
|
104
|
+
|
105
|
+
root = doc.root
|
106
|
+
assert_instance_of LibXML::XML::Node, root
|
107
|
+
assert_equal 'html', root.name
|
108
|
+
|
109
|
+
head = root.child
|
110
|
+
assert_instance_of LibXML::XML::Node, head
|
111
|
+
assert_equal 'head', head.name
|
112
|
+
|
113
|
+
meta = head.child
|
114
|
+
assert_instance_of LibXML::XML::Node, meta
|
115
|
+
assert_equal 'meta', meta.name
|
116
|
+
assert_equal 'keywords', meta[:name]
|
117
|
+
assert_equal 'nasty', meta[:content]
|
118
|
+
|
119
|
+
body = head.next
|
120
|
+
assert_instance_of LibXML::XML::Node, body
|
121
|
+
assert_equal 'body', body.name
|
122
|
+
|
123
|
+
hello = body.child
|
124
|
+
# It appears that some versions of libxml2 add a layer of <p>
|
125
|
+
# cant figure our why or how, so this skips it if there
|
126
|
+
hello = hello.child if hello.name == "p"
|
127
|
+
|
128
|
+
assert_instance_of LibXML::XML::Node, hello
|
129
|
+
assert_equal 'Hello', hello.content
|
130
|
+
|
131
|
+
br = hello.next
|
132
|
+
assert_instance_of LibXML::XML::Node, br
|
133
|
+
assert_equal 'br', br.name
|
134
|
+
|
135
|
+
world = br.next
|
136
|
+
assert_instance_of LibXML::XML::Node, world
|
137
|
+
assert_equal 'World', world.content
|
138
|
+
end
|
139
|
+
|
140
|
+
def test_no_implied
|
141
|
+
html = "hello world"
|
142
|
+
parser = LibXML::XML::HTMLParser.string(html, :options => LibXML::XML::HTMLParser::Options::NOIMPLIED)
|
143
|
+
doc = parser.parse
|
144
|
+
assert_equal("<p>#{html}</p>", doc.root.to_s)
|
145
|
+
end
|
146
|
+
|
147
|
+
def test_comment
|
148
|
+
doc = LibXML::XML::HTMLParser.string('<!-- stuff -->', :options => LibXML::XML::HTMLParser::Options::NOIMPLIED |
|
149
|
+
LibXML::XML::HTMLParser::Options::NOERROR |
|
150
|
+
LibXML::XML::HTMLParser::Options::NOWARNING |
|
151
|
+
LibXML::XML::HTMLParser::Options::RECOVER |
|
152
|
+
LibXML::XML::HTMLParser::Options::NONET)
|
153
|
+
assert(doc)
|
154
|
+
end
|
155
|
+
|
156
|
+
def test_open_many_files
|
157
|
+
file = File.expand_path(File.join(File.dirname(__FILE__), 'model/ruby-lang.html'))
|
158
|
+
1000.times do
|
159
|
+
LibXML::XML::HTMLParser.file(file).parse
|
160
|
+
end
|
161
|
+
end
|
162
|
+
end
|
data/test/test_namespace.rb
CHANGED
@@ -37,9 +37,7 @@ class TestNS < Minitest::Test
|
|
37
37
|
def test_duplicate_ns
|
38
38
|
node = LibXML::XML::Node.new('foo')
|
39
39
|
LibXML::XML::Namespace.new(node, 'myname', 'http://www.mynamespace.com')
|
40
|
-
|
41
|
-
LibXML::XML::Namespace.new(node, 'myname', 'http://www.mynamespace.com')
|
42
|
-
end
|
40
|
+
LibXML::XML::Namespace.new(node, 'myname', 'http://www.mynamespace.com')
|
43
41
|
end
|
44
42
|
|
45
43
|
def test_eql
|
data/test/test_node.rb
CHANGED
@@ -7,13 +7,11 @@ class TestNode < Minitest::Test
|
|
7
7
|
@file_name = "model/bands.utf-8.xml"
|
8
8
|
|
9
9
|
# Strip spaces to make testing easier
|
10
|
-
LibXML::XML.default_keep_blanks = false
|
11
10
|
file = File.join(File.dirname(__FILE__), @file_name)
|
12
|
-
@doc = LibXML::XML::Document.file(file)
|
11
|
+
@doc = LibXML::XML::Document.file(file, options: LibXML::XML::Parser::Options::NOBLANKS)
|
13
12
|
end
|
14
13
|
|
15
14
|
def teardown
|
16
|
-
LibXML::XML.default_keep_blanks = true
|
17
15
|
@doc = nil
|
18
16
|
end
|
19
17
|
|
data/test/test_node_write.rb
CHANGED
@@ -8,7 +8,6 @@ class TestNodeWrite < Minitest::Test
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def teardown
|
11
|
-
LibXML::XML.default_keep_blanks = true
|
12
11
|
@doc = nil
|
13
12
|
end
|
14
13
|
|
@@ -16,10 +15,8 @@ class TestNodeWrite < Minitest::Test
|
|
16
15
|
@encoding = Encoding.find(name)
|
17
16
|
@file_name = "model/bands.#{name.downcase}.xml"
|
18
17
|
|
19
|
-
# Strip spaces to make testing easier
|
20
|
-
LibXML::XML.default_keep_blanks = false
|
21
18
|
file = File.join(File.dirname(__FILE__), @file_name)
|
22
|
-
@doc = LibXML::XML::Document.file(file)
|
19
|
+
@doc = LibXML::XML::Document.file(file, options: LibXML::XML::Parser::Options::NOBLANKS)
|
23
20
|
end
|
24
21
|
|
25
22
|
def test_to_s_default
|
data/test/test_parser.rb
CHANGED
@@ -27,7 +27,7 @@ class TestParser < Minitest::Test
|
|
27
27
|
LibXML::XML::Parser.document(nil)
|
28
28
|
end
|
29
29
|
|
30
|
-
assert_equal("Must pass an LibXML::XML::Document object", error.
|
30
|
+
assert_equal("Must pass an LibXML::XML::Document object", error.message)
|
31
31
|
end
|
32
32
|
|
33
33
|
def test_file
|
@@ -44,7 +44,7 @@ class TestParser < Minitest::Test
|
|
44
44
|
LibXML::XML::Parser.file('i_dont_exist.xml')
|
45
45
|
end
|
46
46
|
|
47
|
-
assert_equal('Warning: failed to load external entity "i_dont_exist.xml".', error.
|
47
|
+
assert_equal('Warning: failed to load external entity "i_dont_exist.xml".', error.message)
|
48
48
|
end
|
49
49
|
|
50
50
|
def test_nil_file
|
@@ -52,7 +52,7 @@ class TestParser < Minitest::Test
|
|
52
52
|
LibXML::XML::Parser.file(nil)
|
53
53
|
end
|
54
54
|
|
55
|
-
assert_match(/nil into String/, error.
|
55
|
+
assert_match(/nil into String/, error.message)
|
56
56
|
end
|
57
57
|
|
58
58
|
def test_file_encoding
|
@@ -63,7 +63,11 @@ class TestParser < Minitest::Test
|
|
63
63
|
parser.parse
|
64
64
|
end
|
65
65
|
|
66
|
-
|
66
|
+
if windows?
|
67
|
+
assert_match(/Fatal error: Opening and ending tag mismatch/, error.message)
|
68
|
+
else
|
69
|
+
assert_match(/Fatal error: Extra content at the end of the document/, error.message)
|
70
|
+
end
|
67
71
|
|
68
72
|
parser = LibXML::XML::Parser.file(file, :encoding => LibXML::XML::Encoding::UTF_8)
|
69
73
|
doc = parser.parse
|
@@ -108,7 +112,7 @@ class TestParser < Minitest::Test
|
|
108
112
|
LibXML::XML::Parser.io(nil)
|
109
113
|
end
|
110
114
|
|
111
|
-
assert_equal("Must pass in an IO object", error.
|
115
|
+
assert_equal("Must pass in an IO object", error.message)
|
112
116
|
end
|
113
117
|
|
114
118
|
def test_string_io
|
@@ -153,7 +157,7 @@ class TestParser < Minitest::Test
|
|
153
157
|
LibXML::XML::Parser.string(nil)
|
154
158
|
end
|
155
159
|
|
156
|
-
assert_equal("wrong argument type nil (expected String)", error.
|
160
|
+
assert_equal("wrong argument type nil (expected String)", error.message)
|
157
161
|
end
|
158
162
|
|
159
163
|
def test_string_options
|
@@ -165,9 +169,7 @@ class TestParser < Minitest::Test
|
|
165
169
|
</test>
|
166
170
|
EOS
|
167
171
|
|
168
|
-
|
169
|
-
|
170
|
-
# Parse normally
|
172
|
+
# Parse normally - entities won't be substituted
|
171
173
|
parser = LibXML::XML::Parser.string(xml)
|
172
174
|
doc = parser.parse
|
173
175
|
assert_nil(doc.child.base_uri)
|
@@ -176,13 +178,13 @@ class TestParser < Minitest::Test
|
|
176
178
|
node = doc.find_first('/test/cdata').child
|
177
179
|
assert_equal(LibXML::XML::Node::CDATA_SECTION_NODE, node.node_type)
|
178
180
|
|
179
|
-
# Entities should not be
|
181
|
+
# Entities should not be substituted
|
180
182
|
node = doc.find_first('/test/entity')
|
181
183
|
assert_equal('&foo;', node.child.to_s)
|
182
184
|
|
183
185
|
# Parse with options
|
184
|
-
parser = LibXML::XML::Parser.string(xml, :
|
185
|
-
|
186
|
+
parser = LibXML::XML::Parser.string(xml, base_uri: 'http://libxml.rubyforge.org',
|
187
|
+
options: LibXML::XML::Parser::Options::NOCDATA | LibXML::XML::Parser::Options::NOENT)
|
186
188
|
doc = parser.parse
|
187
189
|
assert_equal(doc.child.base_uri, 'http://libxml.rubyforge.org')
|
188
190
|
|
@@ -214,7 +216,7 @@ class TestParser < Minitest::Test
|
|
214
216
|
end
|
215
217
|
|
216
218
|
assert_equal("Fatal error: Input is not proper UTF-8, indicate encoding !\nBytes: 0xF6 0x74 0x6C 0x65 at :2.",
|
217
|
-
error.
|
219
|
+
error.message)
|
218
220
|
|
219
221
|
# Parse as ISO_8859_1:
|
220
222
|
parser = LibXML::XML::Parser.string(xml, :encoding => LibXML::XML::Encoding::ISO_8859_1)
|
@@ -283,16 +285,23 @@ class TestParser < Minitest::Test
|
|
283
285
|
|
284
286
|
refute_nil(error)
|
285
287
|
assert_kind_of(LibXML::XML::Error, error)
|
286
|
-
|
288
|
+
if windows?
|
289
|
+
assert_equal("Fatal error: Couldn't find end of Start Tag ruby_array line 1 at :1.", error.message)
|
290
|
+
assert_equal(LibXML::XML::Error::GT_REQUIRED, error.code)
|
291
|
+
assert_equal("ruby_array", error.str1)
|
292
|
+
assert_equal(1, error.int1)
|
293
|
+
else
|
294
|
+
assert_equal("Fatal error: Extra content at the end of the document at :1.", error.message)
|
295
|
+
assert_equal(LibXML::XML::Error::DOCUMENT_END, error.code)
|
296
|
+
assert_nil(error.str1)
|
297
|
+
assert_equal(0, error.int1)
|
298
|
+
end
|
287
299
|
assert_equal(LibXML::XML::Error::PARSER, error.domain)
|
288
|
-
assert_equal(LibXML::XML::Error::DOCUMENT_END, error.code)
|
289
300
|
assert_equal(LibXML::XML::Error::FATAL, error.level)
|
290
301
|
assert_nil(error.file)
|
291
302
|
assert_equal(1, error.line)
|
292
|
-
assert_nil(error.str1)
|
293
303
|
assert_nil(error.str2)
|
294
304
|
assert_nil(error.str3)
|
295
|
-
assert_equal(0, error.int1)
|
296
305
|
assert_equal(34, error.int2)
|
297
306
|
assert_nil(error.node)
|
298
307
|
end
|
data/test/test_reader.rb
CHANGED
@@ -60,9 +60,10 @@ class TestReader < Minitest::Test
|
|
60
60
|
end
|
61
61
|
|
62
62
|
def test_invalid_file
|
63
|
-
assert_raises(
|
63
|
+
error = assert_raises(Errno::ENOENT) do
|
64
64
|
LibXML::XML::Reader.file('/does/not/exist')
|
65
65
|
end
|
66
|
+
assert_equal("No such file or directory - /does/not/exist", error.message)
|
66
67
|
end
|
67
68
|
|
68
69
|
def test_string
|
@@ -256,7 +257,6 @@ class TestReader < Minitest::Test
|
|
256
257
|
end
|
257
258
|
|
258
259
|
def test_node
|
259
|
-
LibXML::XML.default_line_numbers = true
|
260
260
|
reader = LibXML::XML::Reader.file(XML_FILE)
|
261
261
|
|
262
262
|
# first try to get a node
|
@@ -358,7 +358,7 @@ class TestReader < Minitest::Test
|
|
358
358
|
reader = LibXML::XML::Reader.string(xml, :encoding => LibXML::XML::Encoding::ISO_8859_1)
|
359
359
|
reader.read
|
360
360
|
|
361
|
-
|
362
|
-
assert_equal(reader.encoding,
|
361
|
+
encoding = windows? ? LibXML::XML::Encoding::ISO_8859_1 : LibXML::XML::Encoding::NONE
|
362
|
+
assert_equal(reader.encoding, encoding)
|
363
363
|
end
|
364
364
|
end
|
data/test/test_sax_parser.rb
CHANGED
@@ -318,7 +318,7 @@ EOS
|
|
318
318
|
error = assert_raises(LibXML::XML::Error) do
|
319
319
|
parser.parse
|
320
320
|
end
|
321
|
-
|
321
|
+
assert_match("Fatal error: xmlParseEntityRef: no name at", error.to_s)
|
322
322
|
|
323
323
|
# Check callbacks
|
324
324
|
parser.callbacks.result
|