libxml-ruby 3.0.0-x64-mingw32 → 3.2.2-x64-mingw32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. checksums.yaml +5 -5
  2. data/HISTORY +37 -0
  3. data/MANIFEST +34 -34
  4. data/README.rdoc +65 -36
  5. data/Rakefile +21 -3
  6. data/ext/libxml/extconf.rb +30 -26
  7. data/ext/libxml/ruby_libxml.h +0 -8
  8. data/ext/libxml/ruby_xml.c +40 -0
  9. data/ext/libxml/ruby_xml_document.c +1 -5
  10. data/ext/libxml/ruby_xml_dtd.c +6 -8
  11. data/ext/libxml/ruby_xml_encoding.c +1 -13
  12. data/ext/libxml/ruby_xml_encoding.h +0 -3
  13. data/ext/libxml/ruby_xml_error.c +1 -1
  14. data/ext/libxml/ruby_xml_error.h +1 -1
  15. data/ext/libxml/ruby_xml_io.c +14 -18
  16. data/ext/libxml/ruby_xml_io.h +1 -1
  17. data/ext/libxml/ruby_xml_node.c +16 -17
  18. data/ext/libxml/ruby_xml_parser_context.c +1 -1
  19. data/ext/libxml/ruby_xml_reader.c +7 -2
  20. data/ext/libxml/ruby_xml_schema.c +44 -66
  21. data/ext/libxml/ruby_xml_schema_element.c +15 -14
  22. data/ext/libxml/ruby_xml_schema_type.c +66 -93
  23. data/ext/libxml/ruby_xml_version.h +4 -4
  24. data/ext/libxml/ruby_xml_writer.c +189 -192
  25. data/lib/3.0/libxml_ruby.so +0 -0
  26. data/lib/libxml/schema/element.rb +0 -8
  27. data/lib/libxml/schema/type.rb +0 -8
  28. data/lib/libxml/schema.rb +0 -19
  29. data/lib/libxml-ruby.rb +30 -0
  30. data/lib/libxml.rb +3 -28
  31. data/libxml-ruby.gemspec +5 -4
  32. data/setup.rb +0 -1
  33. data/test/model/cwm_1_0.xml +11336 -0
  34. data/test/{tc_attr.rb → test_attr.rb} +18 -18
  35. data/test/{tc_attr_decl.rb → test_attr_decl.rb} +8 -8
  36. data/test/{tc_attributes.rb → test_attributes.rb} +10 -10
  37. data/test/{tc_canonicalize.rb → test_canonicalize.rb} +35 -39
  38. data/test/test_deprecated_require.rb +12 -0
  39. data/test/{tc_document.rb → test_document.rb} +31 -24
  40. data/test/test_document_write.rb +146 -0
  41. data/test/{tc_dtd.rb → test_dtd.rb} +26 -25
  42. data/test/{tc_encoding.rb → test_encoding.rb} +20 -17
  43. data/test/{tc_encoding_sax.rb → test_encoding_sax.rb} +3 -3
  44. data/test/test_error.rb +178 -0
  45. data/test/test_helper.rb +4 -11
  46. data/test/{tc_html_parser.rb → test_html_parser.rb} +31 -30
  47. data/test/test_html_parser_context.rb +23 -0
  48. data/test/test_namespace.rb +60 -0
  49. data/test/{tc_namespaces.rb → test_namespaces.rb} +29 -38
  50. data/test/{tc_node.rb → test_node.rb} +37 -31
  51. data/test/{tc_node_cdata.rb → test_node_cdata.rb} +10 -10
  52. data/test/{tc_node_comment.rb → test_node_comment.rb} +6 -6
  53. data/test/{tc_node_copy.rb → test_node_copy.rb} +3 -4
  54. data/test/{tc_node_edit.rb → test_node_edit.rb} +20 -21
  55. data/test/{tc_node_pi.rb → test_node_pi.rb} +8 -10
  56. data/test/{tc_node_text.rb → test_node_text.rb} +8 -9
  57. data/test/{tc_node_write.rb → test_node_write.rb} +16 -26
  58. data/test/test_node_xlink.rb +28 -0
  59. data/test/{tc_parser.rb → test_parser.rb} +72 -75
  60. data/test/{tc_parser_context.rb → test_parser_context.rb} +38 -44
  61. data/test/{tc_properties.rb → test_properties.rb} +5 -5
  62. data/test/test_reader.rb +364 -0
  63. data/test/{tc_relaxng.rb → test_relaxng.rb} +11 -11
  64. data/test/{tc_sax_parser.rb → test_sax_parser.rb} +38 -31
  65. data/test/{tc_schema.rb → test_schema.rb} +40 -33
  66. data/test/test_suite.rb +39 -40
  67. data/test/{tc_traversal.rb → test_traversal.rb} +4 -4
  68. data/test/{tc_writer.rb → test_writer.rb} +95 -74
  69. data/test/{tc_xinclude.rb → test_xinclude.rb} +3 -3
  70. data/test/test_xml.rb +263 -0
  71. data/test/{tc_xpath.rb → test_xpath.rb} +25 -25
  72. data/test/{tc_xpath_context.rb → test_xpath_context.rb} +5 -5
  73. data/test/{tc_xpath_expression.rb → test_xpath_expression.rb} +7 -7
  74. data/test/{tc_xpointer.rb → test_xpointer.rb} +15 -15
  75. metadata +92 -106
  76. data/lib/2.4/libxml_ruby.so +0 -0
  77. data/lib/libs/libiconv-2.dll +0 -0
  78. data/lib/libs/libxml2-2.dll +0 -0
  79. data/lib/libs/zlib1.dll +0 -0
  80. data/test/tc_deprecated_require.rb +0 -12
  81. data/test/tc_document_write.rb +0 -195
  82. data/test/tc_error.rb +0 -178
  83. data/test/tc_html_parser_context.rb +0 -23
  84. data/test/tc_namespace.rb +0 -61
  85. data/test/tc_node_xlink.rb +0 -28
  86. data/test/tc_reader.rb +0 -358
  87. data/test/tc_xml.rb +0 -225
@@ -1,195 +0,0 @@
1
- # encoding: UTF-8
2
-
3
- require './test_helper'
4
- require 'tmpdir'
5
-
6
- class TestDocumentWrite < Minitest::Test
7
- def setup
8
- @file_name = "model/bands.utf-8.xml"
9
-
10
- # Strip spaces to make testing easier
11
- XML.default_keep_blanks = false
12
- file = File.join(File.dirname(__FILE__), @file_name)
13
- @doc = XML::Document.file(file)
14
- end
15
-
16
- def teardown
17
- XML.default_keep_blanks = true
18
- @doc = nil
19
- end
20
-
21
- # --- to_s tests ---
22
- def test_to_s_default
23
- # Default to_s has indentation
24
- if defined?(Encoding)
25
- assert_equal("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<bands genre=\"metal\">\n <m\u00F6tley_cr\u00FCe country=\"us\">M\u00F6tley Cr\u00FCe is an American heavy metal band formed in Los Angeles, California in 1981.</m\u00F6tley_cr\u00FCe>\n <iron_maiden country=\"uk\">Iron Maiden is a British heavy metal band formed in 1975.</iron_maiden>\n</bands>\n",
26
- @doc.to_s)
27
- else
28
- assert_equal("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<bands genre=\"metal\">\n <m\303\266tley_cr\303\274e country=\"us\">M\303\266tley Cr\303\274e is an American heavy metal band formed in Los Angeles, California in 1981.</m\303\266tley_cr\303\274e>\n <iron_maiden country=\"uk\">Iron Maiden is a British heavy metal band formed in 1975.</iron_maiden>\n</bands>\n",
29
- @doc.to_s)
30
- end
31
- end
32
-
33
- def test_to_s_no_global_indentation
34
- # No indentation due to global setting
35
- XML.indent_tree_output = false
36
- value = @doc.to_s
37
-
38
- if defined?(Encoding)
39
- assert_equal(Encoding::UTF_8, value.encoding)
40
- assert_equal("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<bands genre=\"metal\">\n<m\u00F6tley_cr\u00FCe country=\"us\">M\u00F6tley Cr\u00FCe is an American heavy metal band formed in Los Angeles, California in 1981.</m\u00F6tley_cr\u00FCe>\n<iron_maiden country=\"uk\">Iron Maiden is a British heavy metal band formed in 1975.</iron_maiden>\n</bands>\n",
41
- value)
42
- else
43
- assert_equal("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<bands genre=\"metal\">\n<m\303\266tley_cr\303\274e country=\"us\">M\303\266tley Cr\303\274e is an American heavy metal band formed in Los Angeles, California in 1981.</m\303\266tley_cr\303\274e>\n<iron_maiden country=\"uk\">Iron Maiden is a British heavy metal band formed in 1975.</iron_maiden>\n</bands>\n",
44
- value)
45
- end
46
- ensure
47
- XML.indent_tree_output = true
48
- end
49
-
50
- def test_to_s_no_indentation
51
- # No indentation due to local setting
52
- value = @doc.to_s(:indent => false)
53
- if defined?(Encoding)
54
- assert_equal(Encoding::UTF_8, value.encoding)
55
- assert_equal("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<bands genre=\"metal\"><m\u00F6tley_cr\u00FCe country=\"us\">M\u00F6tley Cr\u00FCe is an American heavy metal band formed in Los Angeles, California in 1981.</m\u00F6tley_cr\u00FCe><iron_maiden country=\"uk\">Iron Maiden is a British heavy metal band formed in 1975.</iron_maiden></bands>\n",
56
- value)
57
- else
58
- assert_equal("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<bands genre=\"metal\"><m\303\266tley_cr\303\274e country=\"us\">M\303\266tley Cr\303\274e is an American heavy metal band formed in Los Angeles, California in 1981.</m\303\266tley_cr\303\274e><iron_maiden country=\"uk\">Iron Maiden is a British heavy metal band formed in 1975.</iron_maiden></bands>\n",
59
- value)
60
- end
61
- end
62
-
63
- def test_to_s_encoding
64
- # Test encodings
65
-
66
- # UTF8:
67
- # ö - c3 b6 in hex, \303\266 in octal
68
- # ü - c3 bc in hex, \303\274 in octal
69
- value = @doc.to_s(:encoding => XML::Encoding::UTF_8)
70
- if defined?(Encoding)
71
- assert_equal(Encoding::UTF_8, value.encoding)
72
- assert_equal("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<bands genre=\"metal\">\n <m\u00F6tley_cr\u00FCe country=\"us\">M\u00F6tley Cr\u00FCe is an American heavy metal band formed in Los Angeles, California in 1981.</m\u00F6tley_cr\u00FCe>\n <iron_maiden country=\"uk\">Iron Maiden is a British heavy metal band formed in 1975.</iron_maiden>\n</bands>\n",
73
- value)
74
- else
75
- assert_equal("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<bands genre=\"metal\">\n <m\303\266tley_cr\303\274e country=\"us\">M\303\266tley Cr\303\274e is an American heavy metal band formed in Los Angeles, California in 1981.</m\303\266tley_cr\303\274e>\n <iron_maiden country=\"uk\">Iron Maiden is a British heavy metal band formed in 1975.</iron_maiden>\n</bands>\n",
76
- value)
77
- end
78
-
79
- # ISO_8859_1:
80
- # ö - f6 in hex, \366 in octal
81
- # ü - fc in hex, \374 in octal
82
- value = @doc.to_s(:encoding => XML::Encoding::ISO_8859_1)
83
- if defined?(Encoding)
84
- assert_equal(Encoding::ISO8859_1, value.encoding)
85
- assert_equal("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n<bands genre=\"metal\">\n <m\xF6tley_cr\xFCe country=\"us\">M\xF6tley Cr\xFCe is an American heavy metal band formed in Los Angeles, California in 1981.</m\xF6tley_cr\xFCe>\n <iron_maiden country=\"uk\">Iron Maiden is a British heavy metal band formed in 1975.</iron_maiden>\n</bands>\n".force_encoding(Encoding::ISO8859_1),
86
- @doc.to_s(:encoding => XML::Encoding::ISO_8859_1))
87
- else
88
- assert_equal("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n<bands genre=\"metal\">\n <m\366tley_cr\374e country=\"us\">M\366tley Cr\374e is an American heavy metal band formed in Los Angeles, California in 1981.</m\366tley_cr\374e>\n <iron_maiden country=\"uk\">Iron Maiden is a British heavy metal band formed in 1975.</iron_maiden>\n</bands>\n",
89
- @doc.to_s(:encoding => XML::Encoding::ISO_8859_1))
90
- end
91
-
92
- # Invalid encoding
93
- error = assert_raises(ArgumentError) do
94
- @doc.to_s(:encoding => -9999)
95
- end
96
- assert_equal('Unknown encoding value: -9999', error.to_s)
97
- end
98
-
99
- # --- save tests -----
100
- def test_save_utf8
101
- temp_filename = File.join(Dir.tmpdir, "tc_document_write_test_save_utf8.xml")
102
-
103
- bytes = @doc.save(temp_filename)
104
- assert_equal(305, bytes)
105
-
106
- if defined?(Encoding)
107
- contents = File.read(temp_filename, nil, nil, :encoding => Encoding::UTF_8)
108
- assert_equal(Encoding::UTF_8, contents.encoding)
109
- assert_equal("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<bands genre=\"metal\">\n <m\u00F6tley_cr\u00FCe country=\"us\">M\u00F6tley Cr\u00FCe is an American heavy metal band formed in Los Angeles, California in 1981.</m\u00F6tley_cr\u00FCe>\n <iron_maiden country=\"uk\">Iron Maiden is a British heavy metal band formed in 1975.</iron_maiden>\n</bands>\n",
110
- contents)
111
- else
112
- contents = File.read(temp_filename)
113
- assert_equal("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<bands genre=\"metal\">\n <m\303\266tley_cr\303\274e country=\"us\">M\303\266tley Cr\303\274e is an American heavy metal band formed in Los Angeles, California in 1981.</m\303\266tley_cr\303\274e>\n <iron_maiden country=\"uk\">Iron Maiden is a British heavy metal band formed in 1975.</iron_maiden>\n</bands>\n",
114
- contents)
115
- end
116
- ensure
117
- File.delete(temp_filename)
118
- end
119
-
120
- def test_save_utf8_no_indents
121
- temp_filename = File.join(Dir.tmpdir, "tc_document_write_test_save_utf8_no_indents.xml")
122
-
123
- bytes = @doc.save(temp_filename, :indent => false)
124
- assert_equal(298, bytes)
125
-
126
- if defined?(Encoding)
127
- contents = File.read(temp_filename, nil, nil, :encoding => Encoding::UTF_8)
128
- assert_equal("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<bands genre=\"metal\"><m\u00F6tley_cr\u00FCe country=\"us\">M\u00F6tley Cr\u00FCe is an American heavy metal band formed in Los Angeles, California in 1981.</m\u00F6tley_cr\u00FCe><iron_maiden country=\"uk\">Iron Maiden is a British heavy metal band formed in 1975.</iron_maiden></bands>\n",
129
- contents)
130
- else
131
- contents = File.read(temp_filename)
132
- assert_equal("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<bands genre=\"metal\"><m\303\266tley_cr\303\274e country=\"us\">M\303\266tley Cr\303\274e is an American heavy metal band formed in Los Angeles, California in 1981.</m\303\266tley_cr\303\274e><iron_maiden country=\"uk\">Iron Maiden is a British heavy metal band formed in 1975.</iron_maiden></bands>\n",
133
- contents)
134
- end
135
- ensure
136
- File.delete(temp_filename)
137
- end
138
-
139
- def test_save_iso_8859_1
140
- temp_filename = File.join(Dir.tmpdir, "tc_document_write_test_save_iso_8859_1.xml")
141
- bytes = @doc.save(temp_filename, :encoding => XML::Encoding::ISO_8859_1)
142
- assert_equal(304, bytes)
143
-
144
- if defined?(Encoding)
145
- contents = File.read(temp_filename, nil, nil, :encoding => Encoding::ISO8859_1)
146
- assert_equal(Encoding::ISO8859_1, contents.encoding)
147
- assert_equal("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n<bands genre=\"metal\">\n <m\xF6tley_cr\xFCe country=\"us\">M\xF6tley Cr\xFCe is an American heavy metal band formed in Los Angeles, California in 1981.</m\xF6tley_cr\xFCe>\n <iron_maiden country=\"uk\">Iron Maiden is a British heavy metal band formed in 1975.</iron_maiden>\n</bands>\n".force_encoding(Encoding::ISO8859_1),
148
- contents)
149
- else
150
- contents = File.read(temp_filename)
151
- assert_equal("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n<bands genre=\"metal\">\n <m\xF6tley_cr\xFCe country=\"us\">M\xF6tley Cr\xFCe is an American heavy metal band formed in Los Angeles, California in 1981.</m\xF6tley_cr\xFCe>\n <iron_maiden country=\"uk\">Iron Maiden is a British heavy metal band formed in 1975.</iron_maiden>\n</bands>\n",
152
- contents)
153
- end
154
- ensure
155
- File.delete(temp_filename)
156
- end
157
-
158
- def test_save_iso_8859_1_no_indent
159
- temp_filename = File.join(Dir.tmpdir, "tc_document_write_test_save_iso_8859_1_no_indent.xml")
160
- bytes = @doc.save(temp_filename, :indent => false, :encoding => XML::Encoding::ISO_8859_1)
161
- assert_equal(297, bytes)
162
-
163
- if defined?(Encoding)
164
- contents = File.read(temp_filename, nil, nil, :encoding => Encoding::ISO8859_1)
165
- assert_equal(Encoding::ISO8859_1, contents.encoding)
166
- assert_equal("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n<bands genre=\"metal\"><m\xF6tley_cr\xFCe country=\"us\">M\xF6tley Cr\xFCe is an American heavy metal band formed in Los Angeles, California in 1981.</m\xF6tley_cr\xFCe><iron_maiden country=\"uk\">Iron Maiden is a British heavy metal band formed in 1975.</iron_maiden></bands>\n".force_encoding(Encoding::ISO8859_1),
167
- contents)
168
- else
169
- contents = File.read(temp_filename)
170
- assert_equal("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n<bands genre=\"metal\"><m\xF6tley_cr\xFCe country=\"us\">M\xF6tley Cr\xFCe is an American heavy metal band formed in Los Angeles, California in 1981.</m\xF6tley_cr\xFCe><iron_maiden country=\"uk\">Iron Maiden is a British heavy metal band formed in 1975.</iron_maiden></bands>\n",
171
- contents)
172
- end
173
- ensure
174
- File.delete(temp_filename)
175
- end
176
-
177
- def test_thread_set_root
178
- # Previously a segmentation fault occurred when running libxml in
179
- # background threads.
180
- thread = Thread.new do
181
- 100000.times do |i|
182
- document = LibXML::XML::Document.new
183
- node = LibXML::XML::Node.new('test')
184
- document.root = node
185
- end
186
- end
187
- thread.join
188
- assert(true)
189
- end
190
-
191
- # --- Debug ---
192
- def test_debug
193
- assert(@doc.debug)
194
- end
195
- end
data/test/tc_error.rb DELETED
@@ -1,178 +0,0 @@
1
- # encoding: UTF-8
2
-
3
- require './test_helper'
4
- require 'stringio'
5
-
6
- class TestError < Minitest::Test
7
- # def test_error_codes
8
- # assert_equal(4, XML::Error::DTD)
9
- # assert_equal(4, XML::Error.const_get('DTD'))
10
- #
11
- # assert_equal(4, XML::Error::DOCUMENT_EMPTY)
12
- # assert_equal(4, XML::Error.const_get('DOCUMENT_EMPTY'))
13
- # end
14
- #
15
- # def test_invalid_handler
16
- # assert_raises(RuntimeError) do
17
- # XML::Error.set_handler
18
- # end
19
- # end
20
- #
21
- # def test_handler
22
- # exception = nil
23
- # XML::Error.set_handler do |error|
24
- # exception = error
25
- # end
26
- #
27
- # # Raise the error
28
- # error = assert_raises(XML::Error) do
29
- # XML::Reader.string('<foo').read
30
- # end
31
- # assert_equal(exception, error)
32
- #
33
- # # Check the handler worked
34
- # refute_nil(exception)
35
- # assert_kind_of(XML::Error, exception)
36
- # assert_equal("Fatal error: Couldn't find end of Start Tag foo at :1.", exception.message)
37
- # assert_equal(XML::Error::PARSER, exception.domain)
38
- # assert_equal(XML::Error::GT_REQUIRED, exception.code)
39
- # assert_equal(XML::Error::FATAL, exception.level)
40
- # assert_nil(exception.file)
41
- # assert_equal(1, exception.line)
42
- # assert_equal('foo', exception.str1)
43
- # assert_nil(exception.str2)
44
- # assert_nil(exception.str3)
45
- # assert_equal(0, exception.int1)
46
- # assert_equal(5, exception.int2)
47
- # assert_nil(exception.node)
48
- # end
49
- #
50
- # def test_reset_handler
51
- # exception = nil
52
- # XML::Error.set_handler do |error|
53
- # exception = error
54
- # end
55
- #
56
- # XML::Error.reset_handler
57
- # XML::Reader.string('<foo')
58
- # assert_nil(exception)
59
- # end
60
- #
61
- # def test_get_handler
62
- # assert_respond_to(XML::Error, :get_handler)
63
- # assert_equal(0, XML::Error.method(:get_handler).arity)
64
- #
65
- # saved_handler = XML::Error.get_handler
66
- # XML::Error.set_handler{ puts "New handler" }
67
- # refute_equal(XML::Error.get_handler, saved_handler)
68
- #
69
- # XML::Error.set_handler(&saved_handler)
70
- # assert_equal(XML::Error.get_handler, saved_handler)
71
- # end
72
- #
73
- # def test_verbose_handler
74
- # XML::Error.set_handler(&XML::Error::VERBOSE_HANDLER)
75
- # output = StringIO.new
76
- # original_stderr = Object::STDERR
77
- #
78
- # Object.const_set(:STDERR, output)
79
- # begin
80
- # assert_raises(XML::Error) do
81
- # XML::Parser.string('<foo><bar/></foz>').parse
82
- # end
83
- # ensure
84
- # Object.const_set(:STDERR, original_stderr)
85
- # end
86
- # assert_equal("Fatal error: Opening and ending tag mismatch: foo line 1 and foz at :1.\n", output.string)
87
- # end
88
- #
89
- # def test_no_hanlder
90
- # XML::Error.reset_handler
91
- # output = StringIO.new
92
- # original_stderr = Object::STDERR
93
- #
94
- # Object.const_set(:STDERR, output)
95
- # begin
96
- # assert_raises(XML::Error) do
97
- # XML::Parser.string('<foo><bar/></foz>').parse
98
- # end
99
- # ensure
100
- # Object.const_set(:STDERR, original_stderr)
101
- # end
102
- # assert_equal('', output.string)
103
- # end
104
- #
105
- # def test_parse_error
106
- # exception = assert_raises(XML::Error) do
107
- # XML::Parser.string('<foo><bar/></foz>').parse
108
- # end
109
- #
110
- # assert_instance_of(XML::Error, exception)
111
- # assert_equal("Fatal error: Opening and ending tag mismatch: foo line 1 and foz at :1.", exception.message)
112
- # assert_equal(XML::Error::PARSER, exception.domain)
113
- # assert_equal(XML::Error::TAG_NAME_MISMATCH, exception.code)
114
- # assert_equal(XML::Error::FATAL, exception.level)
115
- # assert_nil(exception.file)
116
- # assert_equal(1, exception.line)
117
- # end
118
- #
119
- # def test_xpath_error
120
- # doc = XML::Document.file(File.join(File.dirname(__FILE__), 'model/soap.xml'))
121
- #
122
- # exception = assert_raises(XML::Error) do
123
- # doc.find('/foo[bar=test')
124
- # end
125
- #
126
- # assert_instance_of(XML::Error, exception)
127
- # assert_equal("Error: Invalid predicate.", exception.message)
128
- # assert_equal(XML::Error::XPATH, exception.domain)
129
- # assert_equal(XML::Error::XPATH_INVALID_PREDICATE_ERROR, exception.code)
130
- # assert_equal(XML::Error::ERROR, exception.level)
131
- # assert_nil(exception.file)
132
- # assert_nil(nil)
133
- # end
134
-
135
- def test_double_parse
136
- XML::Parser.register_error_handler(lambda {|msg| nil })
137
- parser = XML::Parser.string("<test>something</test>")
138
- parser.parse
139
-
140
- error = assert_raises(XML::Error) do
141
- # Try parsing a second time
142
- parser.parse
143
- end
144
-
145
- assert_equal(" LibXML::XML::Error.", error.to_s)
146
- end
147
-
148
- # def test_libxml_parser_empty_string
149
- # xp = XML::Parser.new
150
- #
151
- # error = assert_raises(TypeError) do
152
- # xp.string = nil
153
- # end
154
- # assert_equal('wrong argument type nil (expected String)', error.to_s)
155
- #
156
- # error = assert_raises(ArgumentError) do
157
- # xp.string = ''
158
- # end
159
- # assert_equal('Must specify a string with one or more characters', error.to_s)
160
- # end
161
- #
162
- # def test_error_domain_to_s
163
- # exception = assert_raises(XML::Error) do
164
- # XML::Parser.string('<foo href="http://example.org/cgi?k1=v1&k2=v2"></foo>').parse
165
- # end
166
- #
167
- # assert_equal(XML::Error::PARSER, exception.domain)
168
- # assert_equal("PARSER",exception.domain_to_s)
169
- # end
170
- #
171
- # def test_error_code_to_s
172
- # exception = assert_raises(XML::Error) do
173
- # XML::Parser.string('<foo href="http://example.org/cgi?k1=v1&k2=v2"></foo>').parse
174
- # end
175
- # assert_equal(XML::Error::ENTITYREF_SEMICOL_MISSING, exception.code)
176
- # assert_equal("ENTITYREF_SEMICOL_MISSING",exception.code_to_s)
177
- # end
178
- end
@@ -1,23 +0,0 @@
1
- # encoding: UTF-8
2
-
3
- require './test_helper'
4
-
5
-
6
- class TestHtmlParserContext < Minitest::Test
7
- def test_default_options
8
- context = XML::HTMLParser::Context.new
9
- assert_equal(0, context.options)
10
- end
11
-
12
- def test_no_options
13
- context = XML::HTMLParser::Context.new
14
- context.options = 0
15
- assert_equal(0, context.options)
16
- end
17
-
18
- def test_options
19
- context = XML::HTMLParser::Context.new
20
- context.options = XML::HTMLParser::Options::NOERROR
21
- assert_equal(XML::HTMLParser::Options::NOERROR, context.options)
22
- end
23
- end
data/test/tc_namespace.rb DELETED
@@ -1,61 +0,0 @@
1
- # encoding: UTF-8
2
-
3
- require './test_helper'
4
-
5
-
6
- class TestNS < Minitest::Test
7
- def setup
8
- file = File.join(File.dirname(__FILE__), 'model/soap.xml')
9
- @doc = XML::Document.file(file)
10
- end
11
-
12
- def teardown
13
- @doc = nil
14
- end
15
-
16
- def test_create_ns
17
- node = XML::Node.new('foo')
18
- ns = XML::Namespace.new(node, 'my_namepace', 'http://www.mynamespace.com')
19
- assert_equal(ns.prefix, 'my_namepace')
20
- assert_equal(ns.href, 'http://www.mynamespace.com')
21
- end
22
-
23
- def test_create_default_ns
24
- node = XML::Node.new('foo')
25
- ns = XML::Namespace.new(node, nil, 'http://www.mynamespace.com')
26
- assert_equal(ns.prefix, nil)
27
- assert_equal(ns.href, 'http://www.mynamespace.com')
28
- end
29
-
30
- def test_create_unbound_ns
31
- error = assert_raises(TypeError) do
32
- XML::Namespace.new(nil, 'my_namepace', 'http://www.mynamespace.com')
33
- end
34
- assert_equal('wrong argument type nil (expected Data)', error.to_s)
35
- end
36
-
37
- def test_duplicate_ns
38
- node = XML::Node.new('foo')
39
- XML::Namespace.new(node, 'myname', 'http://www.mynamespace.com')
40
- assert_raises(XML::Error) do
41
- XML::Namespace.new(node, 'myname', 'http://www.mynamespace.com')
42
- end
43
- end
44
-
45
- def test_eql
46
- node = XML::Node.new('Envelope')
47
- ns = XML::Namespace.new(node, 'soap', 'http://schemas.xmlsoap.org/soap/envelope/')
48
-
49
- assert(node.namespaces.namespace.eql?(node.namespaces.namespace))
50
- end
51
-
52
- def test_equal
53
- node1 = XML::Node.new('Envelope')
54
- ns1 = XML::Namespace.new(node1, 'soap', 'http://schemas.xmlsoap.org/soap/envelope/')
55
-
56
- node2 = XML::Node.new('Envelope')
57
- ns2 = XML::Namespace.new(node2, 'soap', 'http://schemas.xmlsoap.org/soap/envelope/')
58
-
59
- assert(ns1 == ns2)
60
- end
61
- end
@@ -1,28 +0,0 @@
1
- # encoding: UTF-8
2
-
3
- # $Id$
4
- require './test_helper'
5
-
6
-
7
- class TC_XML_Node_XLink < Minitest::Test
8
- def setup()
9
- xp = XML::Parser.string('<ruby_array xmlns:xlink="http://www.w3.org/1999/xlink/namespace/"><fixnum xlink:type="simple">one</fixnum></ruby_array>')
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