libxml-ruby 2.2.2-x86-mingw32 → 2.3.0-x86-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.
- data/HISTORY +14 -2
- data/MANIFEST +1 -0
- data/README.rdoc +2 -2
- data/ext/libxml/ruby_xml_document.c +191 -29
- data/ext/libxml/ruby_xml_document.h +1 -0
- data/ext/libxml/ruby_xml_encoding.c +21 -7
- data/ext/libxml/ruby_xml_encoding.h +1 -0
- data/ext/libxml/ruby_xml_node.c +38 -0
- data/ext/libxml/ruby_xml_sax2_handler.c +30 -34
- data/ext/libxml/ruby_xml_sax_parser.c +0 -14
- data/ext/libxml/ruby_xml_version.h +4 -4
- data/lib/1.8/libxml_ruby.so +0 -0
- data/lib/1.9/libxml_ruby.so +0 -0
- data/lib/libxml/document.rb +18 -16
- data/libxml-ruby.gemspec +3 -2
- data/test/c14n/given/doc.dtd +1 -0
- data/test/c14n/given/example-1.xml +14 -0
- data/test/c14n/given/example-2.xml +11 -0
- data/test/c14n/given/example-3.xml +18 -0
- data/test/c14n/given/example-4.xml +9 -0
- data/test/c14n/given/example-5.xml +12 -0
- data/test/c14n/given/example-6.xml +2 -0
- data/test/c14n/given/example-7.xml +11 -0
- data/test/c14n/given/example-8.xml +11 -0
- data/test/c14n/given/example-8.xpath +10 -0
- data/test/c14n/given/world.txt +1 -0
- data/test/c14n/result/1-1-without-comments/example-1 +4 -0
- data/test/c14n/result/1-1-without-comments/example-2 +11 -0
- data/test/c14n/result/1-1-without-comments/example-3 +14 -0
- data/test/c14n/result/1-1-without-comments/example-4 +9 -0
- data/test/c14n/result/1-1-without-comments/example-5 +3 -0
- data/test/c14n/result/1-1-without-comments/example-6 +1 -0
- data/test/c14n/result/1-1-without-comments/example-7 +1 -0
- data/test/c14n/result/1-1-without-comments/example-8 +1 -0
- data/test/c14n/result/with-comments/example-1 +6 -0
- data/test/c14n/result/with-comments/example-2 +11 -0
- data/test/c14n/result/with-comments/example-3 +14 -0
- data/test/c14n/result/with-comments/example-4 +9 -0
- data/test/c14n/result/with-comments/example-5 +4 -0
- data/test/c14n/result/with-comments/example-6 +1 -0
- data/test/c14n/result/with-comments/example-7 +1 -0
- data/test/c14n/result/without-comments/example-1 +4 -0
- data/test/c14n/result/without-comments/example-2 +11 -0
- data/test/c14n/result/without-comments/example-3 +14 -0
- data/test/c14n/result/without-comments/example-4 +9 -0
- data/test/c14n/result/without-comments/example-5 +3 -0
- data/test/c14n/result/without-comments/example-6 +1 -0
- data/test/c14n/result/without-comments/example-7 +1 -0
- data/test/tc_canonicalize.rb +125 -0
- data/test/tc_document.rb +2 -18
- data/test/tc_encoding.rb +7 -5
- data/test/tc_encoding_sax.rb +115 -0
- data/test/tc_node_pi.rb +40 -0
- data/test/tc_xpath.rb +23 -0
- data/test/test_suite.rb +7 -1
- metadata +45 -6
- data/test/new_main.rb +0 -29
@@ -0,0 +1,9 @@
|
|
1
|
+
<doc>
|
2
|
+
<text>First line
|
3
|
+
Second line</text>
|
4
|
+
<value>2</value>
|
5
|
+
<compute>value>"0" && value<"10" ?"valid":"error"</compute>
|
6
|
+
<compute expr="value>"0" && value<"10" ?"valid":"error"">valid</compute>
|
7
|
+
<norm attr=" ' 
	 ' "></norm>
|
8
|
+
<normId id="' 
	 '"></normId>
|
9
|
+
</doc>
|
@@ -0,0 +1 @@
|
|
1
|
+
<doc>©</doc>
|
@@ -0,0 +1 @@
|
|
1
|
+
<e1 xmlns="http://www.ietf.org" xmlns:w3c="http://www.w3.org"><e3 xmlns="" id="E3" xml:space="preserve"></e3></e1>
|
@@ -0,0 +1 @@
|
|
1
|
+
<e1 xmlns="http://www.ietf.org" xmlns:w3c="http://www.w3.org" xml:base="something/else"><e3 xmlns="" id="E3" xml:base="bar/foo" xml:space="preserve"></e3></e1>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<doc>
|
2
|
+
<e1></e1>
|
3
|
+
<e2></e2>
|
4
|
+
<e3 id="elem3" name="elem3"></e3>
|
5
|
+
<e4 id="elem4" name="elem4"></e4>
|
6
|
+
<e5 xmlns="http://www.uvic.ca" xmlns:a="http://www.w3.org" xmlns:b="http://www.ietf.org" attr="I'm" attr2="all" b:attr="sorted" a:attr="out"></e5>
|
7
|
+
<e6 xmlns:a="http://www.w3.org">
|
8
|
+
<e7 xmlns="http://www.ietf.org">
|
9
|
+
<e8 xmlns="">
|
10
|
+
<e9 xmlns:a="http://www.ietf.org" attr="default"></e9>
|
11
|
+
</e8>
|
12
|
+
</e7>
|
13
|
+
</e6>
|
14
|
+
</doc>
|
@@ -0,0 +1,9 @@
|
|
1
|
+
<doc>
|
2
|
+
<text>First line
|
3
|
+
Second line</text>
|
4
|
+
<value>2</value>
|
5
|
+
<compute>value>"0" && value<"10" ?"valid":"error"</compute>
|
6
|
+
<compute expr="value>"0" && value<"10" ?"valid":"error"">valid</compute>
|
7
|
+
<norm attr=" ' 
	 ' "></norm>
|
8
|
+
<normId id="' 
	 '"></normId>
|
9
|
+
</doc>
|
@@ -0,0 +1 @@
|
|
1
|
+
<doc>©</doc>
|
@@ -0,0 +1 @@
|
|
1
|
+
<e1 xmlns="http://www.ietf.org" xmlns:w3c="http://www.w3.org"><e3 xmlns="" id="E3" xml:space="preserve"></e3></e1>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<doc>
|
2
|
+
<e1></e1>
|
3
|
+
<e2></e2>
|
4
|
+
<e3 id="elem3" name="elem3"></e3>
|
5
|
+
<e4 id="elem4" name="elem4"></e4>
|
6
|
+
<e5 xmlns="http://www.uvic.ca" xmlns:a="http://www.w3.org" xmlns:b="http://www.ietf.org" attr="I'm" attr2="all" b:attr="sorted" a:attr="out"></e5>
|
7
|
+
<e6 xmlns:a="http://www.w3.org">
|
8
|
+
<e7 xmlns="http://www.ietf.org">
|
9
|
+
<e8 xmlns="">
|
10
|
+
<e9 xmlns:a="http://www.ietf.org" attr="default"></e9>
|
11
|
+
</e8>
|
12
|
+
</e7>
|
13
|
+
</e6>
|
14
|
+
</doc>
|
@@ -0,0 +1,9 @@
|
|
1
|
+
<doc>
|
2
|
+
<text>First line
|
3
|
+
Second line</text>
|
4
|
+
<value>2</value>
|
5
|
+
<compute>value>"0" && value<"10" ?"valid":"error"</compute>
|
6
|
+
<compute expr="value>"0" && value<"10" ?"valid":"error"">valid</compute>
|
7
|
+
<norm attr=" ' 
	 ' "></norm>
|
8
|
+
<normId id="' 
	 '"></normId>
|
9
|
+
</doc>
|
@@ -0,0 +1 @@
|
|
1
|
+
<doc>©</doc>
|
@@ -0,0 +1 @@
|
|
1
|
+
<e1 xmlns="http://www.ietf.org" xmlns:w3c="http://www.w3.org"><e3 xmlns="" id="E3" xml:space="preserve"></e3></e1>
|
@@ -0,0 +1,125 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
require './test_helper'
|
3
|
+
require 'test/unit'
|
4
|
+
|
5
|
+
class TestCanonicalize < Test::Unit::TestCase
|
6
|
+
# (www.w3.org) 3.1 PIs, Comments, and Outside of Document Element
|
7
|
+
# http://www.w3.org/TR/xml-c14n#Example-OutsideDoc
|
8
|
+
def test_canonicalize_with_w3c_c14n_3_1
|
9
|
+
given_doc = XML::Document.file('c14n/given/example-1.xml')
|
10
|
+
|
11
|
+
# With Comments
|
12
|
+
expected_with_comments = IO.read('c14n/result/with-comments/example-1')
|
13
|
+
assert_equal(expected_with_comments, given_doc.canonicalize(:comments => true))
|
14
|
+
|
15
|
+
# Without Comments
|
16
|
+
expected_without_comments = IO.read('c14n/result/without-comments/example-1')
|
17
|
+
assert_equal(expected_without_comments, given_doc.canonicalize)
|
18
|
+
assert_equal(expected_without_comments, given_doc.canonicalize(:comments => false))
|
19
|
+
|
20
|
+
# Without Comments (XML_C14N_1_1)
|
21
|
+
expected_1_1_without_comments = IO.read('c14n/result/1-1-without-comments/example-1')
|
22
|
+
mode = XML::Document::XML_C14N_1_1
|
23
|
+
assert_equal(expected_1_1_without_comments, given_doc.canonicalize(:mode => mode))
|
24
|
+
end#test_canonicalize_with_w3c_c14n_3_1
|
25
|
+
|
26
|
+
|
27
|
+
# (www.w3.org) 3.2 Whitespace in Document Content
|
28
|
+
# http://www.w3.org/TR/xml-c14n#Example-WhitespaceInContent
|
29
|
+
def test_canonicalize_with_w3c_c14n_3_2
|
30
|
+
given_doc = XML::Document.file('c14n/given/example-2.xml')
|
31
|
+
expected = IO.read('c14n/result/without-comments/example-2')
|
32
|
+
assert_equal(expected, given_doc.canonicalize)
|
33
|
+
|
34
|
+
expected_1_1_without_comments = IO.read('c14n/result/1-1-without-comments/example-2')
|
35
|
+
mode = XML::Document::XML_C14N_1_1
|
36
|
+
assert_equal(expected_1_1_without_comments, given_doc.canonicalize(:mode => mode))
|
37
|
+
end
|
38
|
+
|
39
|
+
# (www.w3.org) 3.3 Start and End Tags
|
40
|
+
# http://www.w3.org/TR/xml-c14n#Example-SETags
|
41
|
+
# (2012-02-20) Test failing due to missing 'attr' in 'e9' node.
|
42
|
+
# - Embedded DTD not parsed out of XML, therefore default attributes are
|
43
|
+
# not applied to canonicalization.
|
44
|
+
def test_canonicalize_with_w3c_c14n_3_3
|
45
|
+
given_doc = XML::Document.file('c14n/given/example-3.xml')
|
46
|
+
expected = IO.read('c14n/result/without-comments/example-3')
|
47
|
+
assert_equal(expected, given_doc.canonicalize)
|
48
|
+
|
49
|
+
expected_1_1_without_comments = IO.read('c14n/result/1-1-without-comments/example-3')
|
50
|
+
mode = XML::Document::XML_C14N_1_1
|
51
|
+
assert_equal(expected_1_1_without_comments, given_doc.canonicalize(:mode => mode))
|
52
|
+
end
|
53
|
+
|
54
|
+
# (www.w3.org) 3.4 Character Modifications and Character References
|
55
|
+
# http://www.w3.org/TR/xml-c14n#Example-Chars
|
56
|
+
def test_canonicalize_with_w3c_c14n_3_4
|
57
|
+
given_doc = XML::Document.file('c14n/given/example-4.xml')
|
58
|
+
expected = IO.read('c14n/result/without-comments/example-4')
|
59
|
+
assert_equal(expected, given_doc.canonicalize)
|
60
|
+
|
61
|
+
expected_1_1_without_comments = IO.read('c14n/result/1-1-without-comments/example-4')
|
62
|
+
mode = XML::Document::XML_C14N_1_1
|
63
|
+
assert_equal(expected_1_1_without_comments, given_doc.canonicalize(:mode => mode))
|
64
|
+
end
|
65
|
+
|
66
|
+
# (www.w3.org) 3.5 Entity References
|
67
|
+
# http://www.w3.org/TR/xml-c14n#Example-Entities
|
68
|
+
# (2012-02-20) Failing likely due to a logic error
|
69
|
+
# - libxml2(c14n.c:1788) XML_ENTITY_REF_NODE is invalid node for parsing.
|
70
|
+
def test_canonicalize_with_w3c_c14n_3_5
|
71
|
+
given_doc = XML::Document.file('c14n/given/example-5.xml')
|
72
|
+
|
73
|
+
# With Comments
|
74
|
+
expected_with_comments = IO.read('c14n/result/with-comments/example-5')
|
75
|
+
|
76
|
+
# TODO - CANNOT COMPLETE TEST unless libxml2 supports additional node types.
|
77
|
+
#assert_equal(expected_with_comments, given_doc.canonicalize(:comments => true))
|
78
|
+
|
79
|
+
# Without Comments
|
80
|
+
expected_without_comments = IO.read('c14n/result/without-comments/example-5')
|
81
|
+
# TODO - CANNOT COMPLETE TEST unless libxml2 supports additional node types.
|
82
|
+
#assert_equal(expected_without_comments, given_doc.canonicalize(:comments => false))
|
83
|
+
expected_1_1_without_comments = IO.read('c14n/result/1-1-without-comments/example-5')
|
84
|
+
mode = XML::Document::XML_C14N_1_1
|
85
|
+
|
86
|
+
# TODO - CANNOT COMPLETE TEST unless libxml2 supports additional node types.
|
87
|
+
#assert_equal(expected_1_1_without_comments, given_doc.canonicalize(:mode => mode))
|
88
|
+
end
|
89
|
+
|
90
|
+
# (www.w3.org) 3.6 UTF-8 Encoding
|
91
|
+
# http://www.w3.org/TR/xml-c14n#Example-UTF8
|
92
|
+
def test_canonicalize_with_w3c_c14n_3_6
|
93
|
+
given_doc = XML::Document.file('c14n/given/example-6.xml')
|
94
|
+
if defined?(Encoding)
|
95
|
+
expected = IO.read('c14n/result/without-comments/example-6', :encoding => Encoding::UTF_8)
|
96
|
+
else
|
97
|
+
expected = IO.read('c14n/result/without-comments/example-6')
|
98
|
+
end
|
99
|
+
assert_equal(expected, given_doc.canonicalize)
|
100
|
+
|
101
|
+
if defined?(Encoding)
|
102
|
+
expected_1_1_without_comments = IO.read('c14n/result/1-1-without-comments/example-6', :encoding => Encoding::UTF_8)
|
103
|
+
else
|
104
|
+
expected_1_1_without_comments = IO.read('c14n/result/1-1-without-comments/example-6')
|
105
|
+
end
|
106
|
+
mode = XML::Document::XML_C14N_1_1
|
107
|
+
assert_equal(expected_1_1_without_comments, given_doc.canonicalize(:mode => mode))
|
108
|
+
end
|
109
|
+
|
110
|
+
# (www.w3.org) 3.7 Document Subsets
|
111
|
+
# http://www.w3.org/TR/xml-c14n#Example-DocSubsets
|
112
|
+
def test_canonicalize_with_w3c_c14n_3_7
|
113
|
+
# Non Canonicalized Document
|
114
|
+
given_doc = XML::Document.file('c14n/given/example-7.xml')
|
115
|
+
expected = IO.read('c14n/result/without-comments/example-7')
|
116
|
+
|
117
|
+
e1_node = given_doc.find_first('ietf:e1', 'ietf:http://www.ietf.org')
|
118
|
+
|
119
|
+
# Select current node, all child nodes, all attributes and namespace nodes
|
120
|
+
subdoc_nodes = e1_node.find("(.//.|.//@id|namespace::*)")
|
121
|
+
|
122
|
+
# TODO - This fails because the namespace nodes aren't taken into account
|
123
|
+
# assert_equal(expected, given_doc.canonicalize(:nodes => subdoc_nodes))
|
124
|
+
end
|
125
|
+
end
|
data/test/tc_document.rb
CHANGED
@@ -31,22 +31,6 @@ class TestDocument < Test::Unit::TestCase
|
|
31
31
|
}
|
32
32
|
end
|
33
33
|
|
34
|
-
def test_canonicalize
|
35
|
-
doc = XML::Parser.string(<<-EOS).parse
|
36
|
-
<?xml-stylesheet href="doc.xsl" type="text/xsl"?>
|
37
|
-
<doc>Hello, world!<!-- Comment 1 --></doc>
|
38
|
-
EOS
|
39
|
-
|
40
|
-
expected = "<?xml-stylesheet href=\"doc.xsl\" type=\"text/xsl\"?>\n<doc>Hello, world!</doc>"
|
41
|
-
assert_equal(expected, doc.canonicalize)
|
42
|
-
|
43
|
-
expected = "<?xml-stylesheet href=\"doc.xsl\" type=\"text/xsl\"?>\n<doc>Hello, world!<!-- Comment 1 --></doc>"
|
44
|
-
assert_equal(expected, doc.canonicalize(true))
|
45
|
-
|
46
|
-
expected = "<?xml-stylesheet href=\"doc.xsl\" type=\"text/xsl\"?>\n<doc>Hello, world!</doc>"
|
47
|
-
assert_equal(expected, doc.canonicalize(false))
|
48
|
-
end
|
49
|
-
|
50
34
|
def test_compression
|
51
35
|
if XML.enabled_zlib?
|
52
36
|
0.upto(9) do |i|
|
@@ -88,7 +72,6 @@ class TestDocument < Test::Unit::TestCase
|
|
88
72
|
@doc.to_s(:indent => false))
|
89
73
|
end
|
90
74
|
|
91
|
-
|
92
75
|
def test_doc_node_type
|
93
76
|
assert_equal(XML::Node::DOCUMENT_NODE, XML::Document.new.node_type)
|
94
77
|
end
|
@@ -131,6 +114,7 @@ class TestDocument < Test::Unit::TestCase
|
|
131
114
|
error = assert_raise(XML::Error) do
|
132
115
|
doc2.root << node
|
133
116
|
end
|
117
|
+
|
134
118
|
assert_equal(" Nodes belong to different documents. You must first import the node by calling XML::Document.import.",
|
135
119
|
error.to_s)
|
136
120
|
|
@@ -139,4 +123,4 @@ class TestDocument < Test::Unit::TestCase
|
|
139
123
|
assert_equal("<nums><two/><one/></nums>",
|
140
124
|
doc2.root.to_s(:indent => false))
|
141
125
|
end
|
142
|
-
end
|
126
|
+
end
|
data/test/tc_encoding.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
if defined?(Encoding)
|
4
3
|
require './test_helper'
|
5
4
|
require 'test/unit'
|
6
5
|
|
@@ -26,16 +25,20 @@ class TestEncoding < Test::Unit::TestCase
|
|
26
25
|
Encoding.default_internal = nil
|
27
26
|
end
|
28
27
|
|
28
|
+
def file_for_encoding(encoding)
|
29
|
+
file_name = "model/bands.#{encoding.name.downcase}.xml"
|
30
|
+
File.join(File.dirname(__FILE__), file_name)
|
31
|
+
end
|
32
|
+
|
29
33
|
def load_encoding(encoding)
|
30
34
|
@encoding = encoding
|
31
|
-
|
35
|
+
file = file_for_encoding(encoding)
|
32
36
|
|
33
37
|
# Strip spaces to make testing easier
|
34
38
|
XML.default_keep_blanks = false
|
35
|
-
file = File.join(File.dirname(__FILE__), file_name)
|
36
39
|
@doc = XML::Document.file(file)
|
37
40
|
end
|
38
|
-
|
41
|
+
|
39
42
|
def test_encoding
|
40
43
|
doc = XML::Document.new
|
41
44
|
assert_equal(XML::Encoding::NONE, doc.encoding)
|
@@ -115,5 +118,4 @@ class TestEncoding < Test::Unit::TestCase
|
|
115
118
|
assert_equal("109 246 116 108 101 121 95 99 114 252 101",
|
116
119
|
name.bytes.to_a.join(" "))
|
117
120
|
end
|
118
|
-
end
|
119
121
|
end
|
@@ -0,0 +1,115 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
require './test_helper'
|
3
|
+
require 'test/unit'
|
4
|
+
|
5
|
+
class SaxEncodingCallbacks
|
6
|
+
attr_reader :encoding
|
7
|
+
#include Test::Unit::Assertions
|
8
|
+
include MiniTest::Assertions
|
9
|
+
|
10
|
+
def initialize
|
11
|
+
@encoding = Encoding::UTF_8
|
12
|
+
end
|
13
|
+
|
14
|
+
# Called for a CDATA block event.
|
15
|
+
def on_cdata_block(cdata)
|
16
|
+
assert_equal(self.encoding, cdata.encoding)
|
17
|
+
end
|
18
|
+
|
19
|
+
# Called for a characters event.
|
20
|
+
def on_characters(chars)
|
21
|
+
assert_equal(self.encoding, chars.encoding)
|
22
|
+
end
|
23
|
+
|
24
|
+
# Called for a comment event.
|
25
|
+
def on_comment(msg)
|
26
|
+
assert_equal(self.encoding, msg.encoding)
|
27
|
+
end
|
28
|
+
|
29
|
+
# Called for a end document event.
|
30
|
+
def on_end_document
|
31
|
+
end
|
32
|
+
|
33
|
+
# Called for a end element event.
|
34
|
+
def on_end_element_ns(name, prefix, uri)
|
35
|
+
assert_equal(self.encoding, name.encoding)
|
36
|
+
assert_equal(self.encoding, prefix.encoding) if prefix
|
37
|
+
assert_equal(self.encoding, uri.encoding) if uri
|
38
|
+
end
|
39
|
+
|
40
|
+
# Called for parser errors.
|
41
|
+
def on_error(msg)
|
42
|
+
assert_equal(self.encoding, msg.encoding)
|
43
|
+
end
|
44
|
+
|
45
|
+
# Called for an external subset event.
|
46
|
+
def on_external_subset(name, external_id, system_id)
|
47
|
+
assert_equal(self.encoding, name.encoding)
|
48
|
+
assert_equal(self.encoding, external_id.encoding)
|
49
|
+
assert_equal(self.encoding, system_id.encoding)
|
50
|
+
end
|
51
|
+
|
52
|
+
# Called for an external subset notification event.
|
53
|
+
def on_has_external_subset
|
54
|
+
end
|
55
|
+
|
56
|
+
# Called for an internal subset notification event.
|
57
|
+
def on_has_internal_subset
|
58
|
+
end
|
59
|
+
|
60
|
+
# Called for an internal subset event.
|
61
|
+
def on_internal_subset(name, external_id, system_id)
|
62
|
+
assert_equal(self.encoding, name.encoding)
|
63
|
+
assert_equal(self.encoding, external_id.encoding)
|
64
|
+
assert_equal(self.encoding, system_id.encoding)
|
65
|
+
end
|
66
|
+
|
67
|
+
# Called for 'is standalone' event.
|
68
|
+
def on_is_standalone
|
69
|
+
end
|
70
|
+
|
71
|
+
# Called for an processing instruction event.
|
72
|
+
def on_processing_instruction(target, data)
|
73
|
+
assert_equal(self.encoding, target.encoding)
|
74
|
+
assert_equal(self.encoding, data.encoding)
|
75
|
+
end
|
76
|
+
|
77
|
+
# Called for a reference event.
|
78
|
+
def on_reference(name)
|
79
|
+
assert_equal(self.encoding, name.encoding)
|
80
|
+
end
|
81
|
+
|
82
|
+
# Called for a start document event.
|
83
|
+
def on_start_document
|
84
|
+
end
|
85
|
+
|
86
|
+
# Called for a start element event.
|
87
|
+
def on_start_element_ns(name, attributes, prefix, uri, namespaces)
|
88
|
+
assert_equal(self.encoding, name.encoding) if name
|
89
|
+
assert_equal(self.encoding, prefix.encoding) if prefix
|
90
|
+
assert_equal(self.encoding, uri.encoding) if uri
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
class TestEncodingSax < Test::Unit::TestCase
|
95
|
+
def setup
|
96
|
+
Encoding.default_internal = nil
|
97
|
+
end
|
98
|
+
|
99
|
+
def file_for_encoding(encoding)
|
100
|
+
file_name = "model/bands.#{encoding.name.downcase}.xml"
|
101
|
+
File.join(File.dirname(__FILE__), file_name)
|
102
|
+
end
|
103
|
+
|
104
|
+
def test_encoding_iso_8859_1
|
105
|
+
parser = XML::SaxParser.file(file_for_encoding(Encoding::ISO_8859_1))
|
106
|
+
parser.callbacks = SaxEncodingCallbacks.new
|
107
|
+
parser.parse
|
108
|
+
end
|
109
|
+
|
110
|
+
def test_encoding_utf8
|
111
|
+
parser = XML::SaxParser.file(file_for_encoding(Encoding::UTF_8))
|
112
|
+
parser.callbacks = SaxEncodingCallbacks.new
|
113
|
+
parser.parse
|
114
|
+
end
|
115
|
+
end
|