libxml-ruby 3.1.0-x64-mingw32 → 3.2.0-x64-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/HISTORY +8 -0
  3. data/ext/libxml/extconf.h +3 -0
  4. data/ext/libxml/extconf.rb +30 -26
  5. data/ext/libxml/ruby_libxml.h +0 -8
  6. data/ext/libxml/ruby_xml.c +40 -0
  7. data/ext/libxml/ruby_xml_document.c +1 -1
  8. data/ext/libxml/ruby_xml_dtd.c +6 -8
  9. data/ext/libxml/ruby_xml_node.c +1 -1
  10. data/ext/libxml/ruby_xml_parser_context.c +1 -1
  11. data/ext/libxml/ruby_xml_version.h +3 -3
  12. data/lib/2.7/libxml_ruby.so +0 -0
  13. data/lib/libxml-ruby.rb +30 -0
  14. data/lib/libxml.rb +3 -28
  15. data/libxml-ruby.gemspec +2 -2
  16. data/test/test_attr.rb +18 -18
  17. data/test/test_attr_decl.rb +8 -8
  18. data/test/test_attributes.rb +10 -10
  19. data/test/test_canonicalize.rb +16 -24
  20. data/test/test_deprecated_require.rb +3 -3
  21. data/test/test_document.rb +118 -112
  22. data/test/test_document_write.rb +39 -88
  23. data/test/test_dtd.rb +23 -23
  24. data/test/test_encoding.rb +15 -15
  25. data/test/test_encoding_sax.rb +3 -3
  26. data/test/test_error.rb +51 -51
  27. data/test/test_helper.rb +2 -9
  28. data/test/test_html_parser.rb +30 -30
  29. data/test/test_html_parser_context.rb +6 -6
  30. data/test/test_namespace.rb +16 -16
  31. data/test/test_namespaces.rb +25 -25
  32. data/test/test_node.rb +36 -30
  33. data/test/test_node_cdata.rb +10 -10
  34. data/test/test_node_comment.rb +6 -6
  35. data/test/test_node_copy.rb +2 -2
  36. data/test/test_node_edit.rb +16 -16
  37. data/test/test_node_pi.rb +7 -7
  38. data/test/test_node_text.rb +6 -6
  39. data/test/test_node_write.rb +16 -26
  40. data/test/test_node_xlink.rb +6 -6
  41. data/test/test_parser.rb +68 -72
  42. data/test/test_parser_context.rb +28 -28
  43. data/test/test_properties.rb +5 -5
  44. data/test/test_reader.rb +80 -85
  45. data/test/test_relaxng.rb +11 -11
  46. data/test/test_sax_parser.rb +28 -28
  47. data/test/test_schema.rb +24 -24
  48. data/test/test_suite.rb +3 -4
  49. data/test/test_traversal.rb +4 -4
  50. data/test/test_writer.rb +50 -52
  51. data/test/test_xinclude.rb +3 -3
  52. data/test/test_xml.rb +114 -102
  53. data/test/test_xpath.rb +22 -22
  54. data/test/test_xpath_context.rb +5 -5
  55. data/test/test_xpath_expression.rb +6 -6
  56. data/test/test_xpointer.rb +15 -15
  57. metadata +7 -5
@@ -1,6 +1,6 @@
1
1
  # encoding: UTF-8
2
2
 
3
- require File.expand_path('../test_helper', __FILE__)
3
+ require_relative './test_helper'
4
4
 
5
5
 
6
6
  class TestParserContext < Minitest::Test
@@ -12,9 +12,9 @@ class TestParserContext < Minitest::Test
12
12
  </bands>
13
13
  EOS
14
14
 
15
- context = XML::Parser::Context.string(xml)
16
- assert_instance_of(XML::Parser::Context, context)
17
- assert_equal(XML::Encoding::NONE, context.encoding)
15
+ context = LibXML::XML::Parser::Context.string(xml)
16
+ assert_instance_of(LibXML::XML::Parser::Context, context)
17
+ assert_equal(LibXML::XML::Encoding::NONE, context.encoding)
18
18
  assert_nil(context.base_uri)
19
19
  end
20
20
 
@@ -26,11 +26,11 @@ class TestParserContext < Minitest::Test
26
26
  </bands>
27
27
  EOS
28
28
 
29
- context = XML::Parser::Context.string(xml)
30
- assert_equal(XML::Encoding::NONE, context.encoding)
29
+ context = LibXML::XML::Parser::Context.string(xml)
30
+ assert_equal(LibXML::XML::Encoding::NONE, context.encoding)
31
31
 
32
- context.encoding = XML::Encoding::ISO_8859_1
33
- assert_equal(XML::Encoding::ISO_8859_1, context.encoding)
32
+ context.encoding = LibXML::XML::Encoding::ISO_8859_1
33
+ assert_equal(LibXML::XML::Encoding::ISO_8859_1, context.encoding)
34
34
  end
35
35
 
36
36
  def test_invalid_encoding
@@ -41,7 +41,7 @@ class TestParserContext < Minitest::Test
41
41
  </bands>
42
42
  EOS
43
43
 
44
- context = XML::Parser::Context.string(xml)
44
+ context = LibXML::XML::Parser::Context.string(xml)
45
45
 
46
46
  error = assert_raises(ArgumentError) do
47
47
  context.encoding = -999
@@ -57,7 +57,7 @@ class TestParserContext < Minitest::Test
57
57
  </bands>
58
58
  EOS
59
59
 
60
- context = XML::Parser::Context.string(xml)
60
+ context = LibXML::XML::Parser::Context.string(xml)
61
61
  assert_nil(context.base_uri)
62
62
 
63
63
  context.base_uri = 'http://libxml.rubyforge.org'
@@ -66,25 +66,25 @@ class TestParserContext < Minitest::Test
66
66
 
67
67
  def test_string_empty
68
68
  error = assert_raises(TypeError) do
69
- XML::Parser::Context.string(nil)
69
+ LibXML::XML::Parser::Context.string(nil)
70
70
  end
71
71
  assert_equal("wrong argument type nil (expected String)", error.to_s)
72
72
 
73
73
  error = assert_raises(ArgumentError) do
74
- XML::Parser::Context.string('')
74
+ LibXML::XML::Parser::Context.string('')
75
75
  end
76
76
  assert_equal("Must specify a string with one or more characters", error.to_s)
77
77
  end
78
78
 
79
79
  def test_well_formed
80
- parser = XML::Parser.string("<abc/>")
80
+ parser = LibXML::XML::Parser.string("<abc/>")
81
81
  parser.parse
82
82
  assert(parser.context.well_formed?)
83
83
  end
84
84
 
85
85
  def test_not_well_formed
86
- parser = XML::Parser.string("<abc>")
87
- assert_raises(XML::Error) do
86
+ parser = LibXML::XML::Parser.string("<abc>")
87
+ assert_raises(LibXML::XML::Error) do
88
88
  parser.parse
89
89
  end
90
90
  assert(!parser.context.well_formed?)
@@ -92,34 +92,34 @@ class TestParserContext < Minitest::Test
92
92
 
93
93
  def test_version_info
94
94
  file = File.expand_path(File.join(File.dirname(__FILE__), 'model/bands.utf-8.xml'))
95
- parser = XML::Parser.file(file)
95
+ parser = LibXML::XML::Parser.file(file)
96
96
  assert_nil(parser.context.version)
97
97
  parser.parse
98
98
  assert_equal("1.0", parser.context.version)
99
99
  end
100
100
 
101
101
  def test_depth
102
- context = XML::Parser::Context.new
102
+ context = LibXML::XML::Parser::Context.new
103
103
  assert_instance_of(Integer, context.depth)
104
104
  end
105
105
 
106
106
  def test_disable_sax
107
- context = XML::Parser::Context.new
107
+ context = LibXML::XML::Parser::Context.new
108
108
  assert(!context.disable_sax?)
109
109
  end
110
110
 
111
111
  def test_docbook
112
- context = XML::Parser::Context.new
112
+ context = LibXML::XML::Parser::Context.new
113
113
  assert(!context.docbook?)
114
114
  end
115
115
 
116
116
  def test_html
117
- context = XML::Parser::Context.new
117
+ context = LibXML::XML::Parser::Context.new
118
118
  assert(!context.html?)
119
119
  end
120
120
 
121
121
  def test_keep_blanks
122
- context = XML::Parser::Context.new
122
+ context = LibXML::XML::Parser::Context.new
123
123
  if context.keep_blanks?
124
124
  assert_instance_of(TrueClass, context.keep_blanks?)
125
125
  else
@@ -134,7 +134,7 @@ class TestParserContext < Minitest::Test
134
134
  end
135
135
 
136
136
  def test_replace_entities
137
- context = XML::Parser::Context.new
137
+ context = LibXML::XML::Parser::Context.new
138
138
  assert(!context.replace_entities?)
139
139
 
140
140
  # context.options = 1
@@ -148,24 +148,24 @@ class TestParserContext < Minitest::Test
148
148
  end
149
149
 
150
150
  def test_space_depth
151
- context = XML::Parser::Context.new
151
+ context = LibXML::XML::Parser::Context.new
152
152
  assert_equal(1, context.space_depth)
153
153
  end
154
154
 
155
155
  def test_subset_external
156
- context = XML::Parser::Context.new
156
+ context = LibXML::XML::Parser::Context.new
157
157
  assert(!context.subset_external?)
158
158
  end
159
159
 
160
160
  def test_data_directory_get
161
- context = XML::Parser::Context.new
161
+ context = LibXML::XML::Parser::Context.new
162
162
  assert_nil(context.data_directory)
163
163
  end
164
164
 
165
165
  def test_parse_error
166
- xp = XML::Parser.string('<foo><bar/></foz>')
166
+ xp = LibXML::XML::Parser.string('<foo><bar/></foz>')
167
167
 
168
- assert_raises(XML::Error) do
168
+ assert_raises(LibXML::XML::Error) do
169
169
  xp.parse
170
170
  end
171
171
 
@@ -175,7 +175,7 @@ class TestParserContext < Minitest::Test
175
175
  assert_equal(0, context.depth)
176
176
  assert_equal(true, context.disable_sax?)
177
177
  assert_equal(false, context.docbook?)
178
- assert_equal(XML::Encoding::NONE, context.encoding)
178
+ assert_equal(LibXML::XML::Encoding::NONE, context.encoding)
179
179
  assert_equal(76, context.errno)
180
180
  assert_equal(false, context.html?)
181
181
  assert_equal(5, context.io_max_num_streams)
@@ -1,6 +1,6 @@
1
1
  # encoding: UTF-8
2
2
 
3
- require File.expand_path('../test_helper', __FILE__)
3
+ require_relative './test_helper'
4
4
 
5
5
 
6
6
  # attributes is deprecated - use attributes instead.
@@ -8,7 +8,7 @@ require File.expand_path('../test_helper', __FILE__)
8
8
 
9
9
  class Testattributes < Minitest::Test
10
10
  def setup()
11
- xp = XML::Parser.string('<ruby_array uga="booga" foo="bar"><fixnum>one</fixnum><fixnum>two</fixnum></ruby_array>')
11
+ xp = LibXML::XML::Parser.string('<ruby_array uga="booga" foo="bar"><fixnum>one</fixnum><fixnum>two</fixnum></ruby_array>')
12
12
  @doc = xp.parse
13
13
  end
14
14
 
@@ -19,20 +19,20 @@ class Testattributes < Minitest::Test
19
19
  def test_traversal
20
20
  attributes = @doc.root.attributes
21
21
 
22
- assert_instance_of(XML::Attributes, attributes)
22
+ assert_instance_of(LibXML::XML::Attributes, attributes)
23
23
  attribute = attributes.first
24
24
  assert_equal('uga', attribute.name)
25
25
  assert_equal('booga', attribute.value)
26
26
 
27
27
  attribute = attribute.next
28
- assert_instance_of(XML::Attr, attribute)
28
+ assert_instance_of(LibXML::XML::Attr, attribute)
29
29
  assert_equal('foo', attribute.name)
30
30
  assert_equal('bar', attribute.value)
31
31
  end
32
32
 
33
33
  def test_no_attributes
34
34
  attributes = @doc.root.child.attributes
35
- assert_instance_of(XML::Attributes, attributes)
35
+ assert_instance_of(LibXML::XML::Attributes, attributes)
36
36
  assert_equal(0, attributes.length)
37
37
  end
38
38
  end
@@ -1,6 +1,6 @@
1
1
  # encoding: UTF-8
2
2
 
3
- require File.expand_path('../test_helper', __FILE__)
3
+ require_relative './test_helper'
4
4
  require 'stringio'
5
5
 
6
6
  class TestReader < Minitest::Test
@@ -19,60 +19,60 @@ class TestReader < Minitest::Test
19
19
  assert(!reader.read)
20
20
 
21
21
  # Check what was read
22
- expected = [XML::Reader::TYPE_PROCESSING_INSTRUCTION,
23
- XML::Reader::TYPE_ELEMENT,
24
- XML::Reader::TYPE_SIGNIFICANT_WHITESPACE,
25
- XML::Reader::TYPE_COMMENT,
26
- XML::Reader::TYPE_SIGNIFICANT_WHITESPACE,
27
- XML::Reader::TYPE_ELEMENT,
28
- XML::Reader::TYPE_SIGNIFICANT_WHITESPACE,
29
- XML::Reader::TYPE_ELEMENT,
30
- XML::Reader::TYPE_CDATA,
31
- XML::Reader::TYPE_END_ELEMENT,
32
- XML::Reader::TYPE_SIGNIFICANT_WHITESPACE,
33
- XML::Reader::TYPE_ELEMENT,
34
- XML::Reader::TYPE_SIGNIFICANT_WHITESPACE,
35
- XML::Reader::TYPE_ELEMENT,
36
- XML::Reader::TYPE_SIGNIFICANT_WHITESPACE,
37
- XML::Reader::TYPE_ELEMENT,
38
- XML::Reader::TYPE_TEXT,
39
- XML::Reader::TYPE_END_ELEMENT,
40
- XML::Reader::TYPE_SIGNIFICANT_WHITESPACE,
41
- XML::Reader::TYPE_END_ELEMENT,
42
- XML::Reader::TYPE_SIGNIFICANT_WHITESPACE,
43
- XML::Reader::TYPE_END_ELEMENT,
44
- XML::Reader::TYPE_SIGNIFICANT_WHITESPACE,
45
- XML::Reader::TYPE_END_ELEMENT,
46
- XML::Reader::TYPE_SIGNIFICANT_WHITESPACE,
47
- XML::Reader::TYPE_END_ELEMENT]
22
+ expected = [LibXML::XML::Reader::TYPE_PROCESSING_INSTRUCTION,
23
+ LibXML::XML::Reader::TYPE_ELEMENT,
24
+ LibXML::XML::Reader::TYPE_SIGNIFICANT_WHITESPACE,
25
+ LibXML::XML::Reader::TYPE_COMMENT,
26
+ LibXML::XML::Reader::TYPE_SIGNIFICANT_WHITESPACE,
27
+ LibXML::XML::Reader::TYPE_ELEMENT,
28
+ LibXML::XML::Reader::TYPE_SIGNIFICANT_WHITESPACE,
29
+ LibXML::XML::Reader::TYPE_ELEMENT,
30
+ LibXML::XML::Reader::TYPE_CDATA,
31
+ LibXML::XML::Reader::TYPE_END_ELEMENT,
32
+ LibXML::XML::Reader::TYPE_SIGNIFICANT_WHITESPACE,
33
+ LibXML::XML::Reader::TYPE_ELEMENT,
34
+ LibXML::XML::Reader::TYPE_SIGNIFICANT_WHITESPACE,
35
+ LibXML::XML::Reader::TYPE_ELEMENT,
36
+ LibXML::XML::Reader::TYPE_SIGNIFICANT_WHITESPACE,
37
+ LibXML::XML::Reader::TYPE_ELEMENT,
38
+ LibXML::XML::Reader::TYPE_TEXT,
39
+ LibXML::XML::Reader::TYPE_END_ELEMENT,
40
+ LibXML::XML::Reader::TYPE_SIGNIFICANT_WHITESPACE,
41
+ LibXML::XML::Reader::TYPE_END_ELEMENT,
42
+ LibXML::XML::Reader::TYPE_SIGNIFICANT_WHITESPACE,
43
+ LibXML::XML::Reader::TYPE_END_ELEMENT,
44
+ LibXML::XML::Reader::TYPE_SIGNIFICANT_WHITESPACE,
45
+ LibXML::XML::Reader::TYPE_END_ELEMENT,
46
+ LibXML::XML::Reader::TYPE_SIGNIFICANT_WHITESPACE,
47
+ LibXML::XML::Reader::TYPE_END_ELEMENT]
48
48
 
49
49
  assert_equal(expected, node_types)
50
50
  end
51
51
 
52
52
  def test_document
53
- reader = XML::Reader.document(XML::Document.file(XML_FILE))
53
+ reader = LibXML::XML::Reader.document(LibXML::XML::Document.file(XML_FILE))
54
54
  verify_simple(reader)
55
55
  end
56
56
 
57
57
  def test_file
58
- reader = XML::Reader.file(XML_FILE)
58
+ reader = LibXML::XML::Reader.file(XML_FILE)
59
59
  verify_simple(reader)
60
60
  end
61
61
 
62
62
  def test_invalid_file
63
- assert_raises(XML::Error) do
64
- XML::Reader.file('/does/not/exist')
63
+ assert_raises(LibXML::XML::Error) do
64
+ LibXML::XML::Reader.file('/does/not/exist')
65
65
  end
66
66
  end
67
67
 
68
68
  def test_string
69
- reader = XML::Reader.string(File.read(XML_FILE))
69
+ reader = LibXML::XML::Reader.string(File.read(XML_FILE))
70
70
  verify_simple(reader)
71
71
  end
72
72
 
73
73
  def test_io
74
74
  File.open(XML_FILE, 'rb') do |io|
75
- reader = XML::Reader.io(io)
75
+ reader = LibXML::XML::Reader.io(io)
76
76
  verify_simple(reader)
77
77
  end
78
78
  end
@@ -81,7 +81,7 @@ class TestReader < Minitest::Test
81
81
  # Test that the reader keeps a reference
82
82
  # to the io object
83
83
  file = File.open(XML_FILE, 'rb')
84
- reader = XML::Reader.io(file)
84
+ reader = LibXML::XML::Reader.io(file)
85
85
  file = nil
86
86
  GC.start
87
87
  assert(reader.read)
@@ -90,21 +90,21 @@ class TestReader < Minitest::Test
90
90
  def test_string_io
91
91
  data = File.read(XML_FILE)
92
92
  string_io = StringIO.new(data)
93
- reader = XML::Reader.io(string_io)
93
+ reader = LibXML::XML::Reader.io(string_io)
94
94
  verify_simple(reader)
95
95
  end
96
96
 
97
97
  def test_error
98
- reader = XML::Reader.string('<foo blah')
98
+ reader = LibXML::XML::Reader.string('<foo blah')
99
99
 
100
- error = assert_raises(XML::Error) do
100
+ error = assert_raises(LibXML::XML::Error) do
101
101
  reader.read
102
102
  end
103
103
  assert_equal("Fatal error: Couldn't find end of Start Tag foo at :1.", error.to_s)
104
104
  end
105
105
 
106
106
  def test_attr
107
- parser = XML::Reader.string("<foo x='1' y='2'/>")
107
+ parser = LibXML::XML::Reader.string("<foo x='1' y='2'/>")
108
108
  assert(parser.read)
109
109
  assert_equal('foo', parser.name)
110
110
  assert_equal('1', parser['x'])
@@ -116,7 +116,7 @@ class TestReader < Minitest::Test
116
116
  end
117
117
 
118
118
  def test_move_attr
119
- reader = XML::Reader.string('<root xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xhtml="http://www.w3.org/1999/xhtml"><link xml:id="abc" xlink:href="def" xhtml:class="ghi" bar="jkl" /></root>')
119
+ reader = LibXML::XML::Reader.string('<root xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xhtml="http://www.w3.org/1999/xhtml"><link xml:id="abc" xlink:href="def" xhtml:class="ghi" bar="jkl" /></root>')
120
120
  assert(reader.read) # <root/>
121
121
  assert(reader.read) # <link/>
122
122
 
@@ -134,7 +134,7 @@ class TestReader < Minitest::Test
134
134
  end
135
135
 
136
136
  def test_get_attr
137
- reader = XML::Reader.string('<root xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xhtml="http://www.w3.org/1999/xhtml"><link xml:id="abc" xlink:href="def" xhtml:class="ghi" bar="jkl" /></root>')
137
+ reader = LibXML::XML::Reader.string('<root xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xhtml="http://www.w3.org/1999/xhtml"><link xml:id="abc" xlink:href="def" xhtml:class="ghi" bar="jkl" /></root>')
138
138
  assert(reader.read) # <root/>
139
139
  assert(reader.read) # <link/>
140
140
 
@@ -148,24 +148,24 @@ class TestReader < Minitest::Test
148
148
  end
149
149
 
150
150
  def test_value
151
- parser = XML::Reader.string("<foo><bar>1</bar><bar>2</bar><bar>3</bar></foo>")
151
+ parser = LibXML::XML::Reader.string("<foo><bar>1</bar><bar>2</bar><bar>3</bar></foo>")
152
152
  assert(parser.read)
153
153
  assert_equal('foo', parser.name)
154
154
  assert_nil(parser.value)
155
155
  3.times do |i|
156
156
  assert(parser.read)
157
- assert_equal(XML::Reader::TYPE_ELEMENT, parser.node_type)
157
+ assert_equal(LibXML::XML::Reader::TYPE_ELEMENT, parser.node_type)
158
158
  assert_equal('bar', parser.name)
159
159
  assert(parser.read)
160
- assert_equal(XML::Reader::TYPE_TEXT, parser.node_type)
160
+ assert_equal(LibXML::XML::Reader::TYPE_TEXT, parser.node_type)
161
161
  assert_equal((i + 1).to_s, parser.value)
162
162
  assert(parser.read)
163
- assert_equal(XML::Reader::TYPE_END_ELEMENT, parser.node_type)
163
+ assert_equal(LibXML::XML::Reader::TYPE_END_ELEMENT, parser.node_type)
164
164
  end
165
165
  end
166
166
 
167
167
  def test_expand
168
- reader = XML::Reader.file(XML_FILE)
168
+ reader = LibXML::XML::Reader.file(XML_FILE)
169
169
  reader.read.to_s
170
170
  reader.read
171
171
 
@@ -177,7 +177,7 @@ class TestReader < Minitest::Test
177
177
  end
178
178
 
179
179
  def test_expand_find
180
- reader = XML::Reader.file(XML_FILE)
180
+ reader = LibXML::XML::Reader.file(XML_FILE)
181
181
  reader.read.to_s
182
182
  reader.read
183
183
 
@@ -195,7 +195,7 @@ class TestReader < Minitest::Test
195
195
  end
196
196
 
197
197
  def test_expand_invalid
198
- reader = XML::Reader.file(XML_FILE)
198
+ reader = LibXML::XML::Reader.file(XML_FILE)
199
199
 
200
200
  # Expand a node before one has been read
201
201
  node = reader.expand
@@ -203,7 +203,7 @@ class TestReader < Minitest::Test
203
203
  end
204
204
 
205
205
  def test_expand_should_be_invalid
206
- reader = XML::Reader.file(XML_FILE)
206
+ reader = LibXML::XML::Reader.file(XML_FILE)
207
207
 
208
208
  # Read a couple of nodes
209
209
  reader.read
@@ -222,7 +222,7 @@ class TestReader < Minitest::Test
222
222
 
223
223
  def test_expand_incorrectly_use_returned_node
224
224
  file = File.join(File.dirname(__FILE__), 'model/cwm_1_0.xml')
225
- reader = XML::Reader.file(file)
225
+ reader = LibXML::XML::Reader.file(file)
226
226
 
227
227
  nodes = Array.new
228
228
  while reader.read
@@ -242,27 +242,27 @@ class TestReader < Minitest::Test
242
242
  end
243
243
 
244
244
  def test_mode
245
- reader = XML::Reader.string('<xml/>')
246
- assert_equal(XML::Reader::MODE_INITIAL, reader.read_state)
245
+ reader = LibXML::XML::Reader.string('<xml/>')
246
+ assert_equal(LibXML::XML::Reader::MODE_INITIAL, reader.read_state)
247
247
  reader.read
248
- assert_equal(XML::Reader::MODE_EOF, reader.read_state)
248
+ assert_equal(LibXML::XML::Reader::MODE_EOF, reader.read_state)
249
249
  end
250
250
 
251
251
  def test_bytes_consumed
252
- reader = XML::Reader.file(XML_FILE)
252
+ reader = LibXML::XML::Reader.file(XML_FILE)
253
253
  reader.read
254
- assert_equal(416, reader.byte_consumed)
254
+ assert_equal(428, reader.byte_consumed)
255
255
  end
256
256
 
257
257
  def test_node
258
- XML.default_line_numbers = true
259
- reader = XML::Reader.file(XML_FILE)
258
+ LibXML::XML.default_line_numbers = true
259
+ reader = LibXML::XML::Reader.file(XML_FILE)
260
260
 
261
261
  # first try to get a node
262
262
  assert_nil(reader.node)
263
263
 
264
264
  reader.read
265
- assert_instance_of(XML::Node, reader.node)
265
+ assert_instance_of(LibXML::XML::Node, reader.node)
266
266
  end
267
267
 
268
268
  def test_base_uri
@@ -270,7 +270,7 @@ class TestReader < Minitest::Test
270
270
  # ö - c3 b6 in hex, \303\266 in octal
271
271
  # ü - c3 bc in hex, \303\274 in octal
272
272
  xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?><bands genre=\"metal\">\n <m\303\266tley_cr\303\274e country=\"us\">An American heavy metal band formed in Los Angeles, California in 1981.</m\303\266tley_cr\303\274e>\n <iron_maiden country=\"uk\">British heavy metal band formed in 1975.</iron_maiden>\n</bands>"
273
- reader = XML::Reader.string(xml, :base_uri => "http://libxml.rubyforge.org")
273
+ reader = LibXML::XML::Reader.string(xml, :base_uri => "http://libxml.rubyforge.org")
274
274
 
275
275
  reader.read
276
276
  assert_equal(reader.base_uri, "http://libxml.rubyforge.org")
@@ -287,22 +287,22 @@ class TestReader < Minitest::Test
287
287
  EOS
288
288
 
289
289
  # Parse normally
290
- reader = XML::Reader.string(xml)
290
+ reader = LibXML::XML::Reader.string(xml)
291
291
  reader.read # foo
292
292
  reader.read # test
293
293
  reader.read # text
294
294
  reader.read # cdata
295
295
  reader.read # cdata-section
296
- assert_equal(XML::Node::CDATA_SECTION_NODE, reader.node_type)
296
+ assert_equal(LibXML::XML::Node::CDATA_SECTION_NODE, reader.node_type)
297
297
 
298
298
  # Convert cdata section to text
299
- reader = XML::Reader.string(xml, :options => XML::Parser::Options::NOCDATA)
299
+ reader = LibXML::XML::Reader.string(xml, :options => LibXML::XML::Parser::Options::NOCDATA)
300
300
  reader.read # foo
301
301
  reader.read # test
302
302
  reader.read # text
303
303
  reader.read # cdata
304
304
  reader.read # cdata-section
305
- assert_equal(XML::Node::TEXT_NODE, reader.node_type)
305
+ assert_equal(LibXML::XML::Node::TEXT_NODE, reader.node_type)
306
306
  end
307
307
 
308
308
  def test_encoding
@@ -311,24 +311,19 @@ class TestReader < Minitest::Test
311
311
  # ü - fc in hex, \374 in octal
312
312
  xml = "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?><bands genre=\"metal\">\n <m\366tley_cr\374e country=\"us\">An American heavy metal band formed in Los Angeles, California in 1981.</m\366tley_cr\374e>\n <iron_maiden country=\"uk\">British heavy metal band formed in 1975.</iron_maiden>\n</bands>"
313
313
 
314
- reader = XML::Reader.string(xml, :encoding => XML::Encoding::ISO_8859_1)
314
+ reader = LibXML::XML::Reader.string(xml, :encoding => LibXML::XML::Encoding::ISO_8859_1)
315
315
  reader.read
316
316
 
317
- if defined?(Encoding)
318
- assert_equal(Encoding::ISO8859_1, reader.read_outer_xml.encoding)
319
- assert_equal(Encoding::ISO8859_1, reader.read_inner_xml.encoding)
320
- assert_equal(Encoding::ISO8859_1, reader.read_string.encoding)
321
-
322
- assert_equal("<bands genre=\"metal\">\n <m\xC3\xB6tley_cr\xC3\xBCe country=\"us\">An American heavy metal band formed in Los Angeles, California in 1981.</m\xC3\xB6tley_cr\xC3\xBCe>\n <iron_maiden country=\"uk\">British heavy metal band formed in 1975.</iron_maiden>\n</bands>".force_encoding(Encoding::ISO8859_1),
323
- reader.read_outer_xml)
324
- assert_equal("\n <m\xC3\xB6tley_cr\xC3\xBCe country=\"us\">An American heavy metal band formed in Los Angeles, California in 1981.</m\xC3\xB6tley_cr\xC3\xBCe>\n <iron_maiden country=\"uk\">British heavy metal band formed in 1975.</iron_maiden>\n".force_encoding(Encoding::ISO8859_1),
325
- reader.read_inner_xml)
326
- assert_equal("\n An American heavy metal band formed in Los Angeles, California in 1981.\n British heavy metal band formed in 1975.\n".force_encoding(Encoding::ISO8859_1),
327
- reader.read_string)
328
- else
329
- assert_equal("<bands genre=\"metal\">\n <m\303\266tley_cr\303\274e country=\"us\">An American heavy metal band formed in Los Angeles, California in 1981.</m\303\266tley_cr\303\274e>\n <iron_maiden country=\"uk\">British heavy metal band formed in 1975.</iron_maiden>\n</bands>",
330
- reader.read_outer_xml)
331
- end
317
+ assert_equal(Encoding::ISO8859_1, reader.read_outer_xml.encoding)
318
+ assert_equal(Encoding::ISO8859_1, reader.read_inner_xml.encoding)
319
+ assert_equal(Encoding::ISO8859_1, reader.read_string.encoding)
320
+
321
+ assert_equal("<bands genre=\"metal\">\n <m\xC3\xB6tley_cr\xC3\xBCe country=\"us\">An American heavy metal band formed in Los Angeles, California in 1981.</m\xC3\xB6tley_cr\xC3\xBCe>\n <iron_maiden country=\"uk\">British heavy metal band formed in 1975.</iron_maiden>\n</bands>".force_encoding(Encoding::ISO8859_1),
322
+ reader.read_outer_xml)
323
+ assert_equal("\n <m\xC3\xB6tley_cr\xC3\xBCe country=\"us\">An American heavy metal band formed in Los Angeles, California in 1981.</m\xC3\xB6tley_cr\xC3\xBCe>\n <iron_maiden country=\"uk\">British heavy metal band formed in 1975.</iron_maiden>\n".force_encoding(Encoding::ISO8859_1),
324
+ reader.read_inner_xml)
325
+ assert_equal("\n An American heavy metal band formed in Los Angeles, California in 1981.\n British heavy metal band formed in 1975.\n".force_encoding(Encoding::ISO8859_1),
326
+ reader.read_string)
332
327
  end
333
328
 
334
329
  def test_invalid_encoding
@@ -337,8 +332,8 @@ class TestReader < Minitest::Test
337
332
  # ü - fc in hex, \374 in octal
338
333
  xml = "<bands genre=\"metal\">\n <m\366tley_cr\374e country=\"us\">An American heavy metal band formed in Los Angeles, California in 1981.</m\366tley_cr\374e>\n <iron_maiden country=\"uk\">British heavy metal band formed in 1975.</iron_maiden>\n</bands>"
339
334
 
340
- reader = XML::Reader.string(xml)
341
- error = assert_raises(XML::Error) do
335
+ reader = LibXML::XML::Reader.string(xml)
336
+ error = assert_raises(LibXML::XML::Error) do
342
337
  reader.read
343
338
  end
344
339
 
@@ -348,10 +343,10 @@ class TestReader < Minitest::Test
348
343
  end
349
344
 
350
345
  def test_file_encoding
351
- reader = XML::Reader.file(XML_FILE)
346
+ reader = LibXML::XML::Reader.file(XML_FILE)
352
347
  reader.read
353
- assert_equal(XML::Encoding::UTF_8, reader.encoding)
354
- assert_equal(Encoding::UTF_8, reader.value.encoding) if defined?(Encoding)
348
+ assert_equal(LibXML::XML::Encoding::UTF_8, reader.encoding)
349
+ assert_equal(Encoding::UTF_8, reader.value.encoding)
355
350
  end
356
351
 
357
352
  def test_string_encoding
@@ -359,10 +354,10 @@ class TestReader < Minitest::Test
359
354
  # ö - f6 in hex, \366 in octal
360
355
  # ü - fc in hex, \374 in octal
361
356
  xml = "<bands genre=\"metal\">\n <m\366tley_cr\374e country=\"us\">An American heavy metal band formed in Los Angeles, California in 1981.</m\366tley_cr\374e>\n <iron_maiden country=\"uk\">British heavy metal band formed in 1975.</iron_maiden>\n</bands>"
362
- reader = XML::Reader.string(xml, :encoding => XML::Encoding::ISO_8859_1)
357
+ reader = LibXML::XML::Reader.string(xml, :encoding => LibXML::XML::Encoding::ISO_8859_1)
363
358
  reader.read
364
359
 
365
360
  # Encoding is always null for strings, very annoying!
366
- assert_equal(reader.encoding, XML::Encoding::NONE)
361
+ assert_equal(reader.encoding, LibXML::XML::Encoding::NONE)
367
362
  end
368
363
  end