diff options
author | kou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-10-30 12:10:56 +0000 |
---|---|---|
committer | kou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-10-30 12:10:56 +0000 |
commit | 994f066f76857a781f8819b8da2c2aeceedbf87b (patch) | |
tree | d89e9bcf6ac8d558367f888919de0c4894224063 /test | |
parent | 767fe5170d97461be5c79936b467dee3d4eb7179 (diff) |
* lib/rexml/encoding.rb: use Ruby native encoding mechnism. [ruby-dev:42464]
* lib/rexml/encodings/: remove.
* lib/rexml/document.rb, lib/rexml/formatters/default.rb,
lib/rexml/output.rb, lib/rexml/parseexception.rb,
lib/rexml/parsers/baseparser.rb, lib/rexml/source.rb,
lib/rexml/xmldecl.rb: use Ruby's native Encoding object.
* test/rexml/, test/rss/: follow the above encoding chagnes.
* NEWS: add REXML's incompatible change about encoding.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29646 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/rexml/test_changing_encoding.rb | 4 | ||||
-rw-r--r-- | test/rexml/test_contrib.rb | 4 | ||||
-rw-r--r-- | test/rexml/test_core.rb | 10 | ||||
-rw-r--r-- | test/rexml/test_encoding.rb | 6 | ||||
-rw-r--r-- | test/rss/test_1.0.rb | 5 | ||||
-rw-r--r-- | test/rss/test_2.0.rb | 5 | ||||
-rw-r--r-- | test/rss/test_atom.rb | 10 |
7 files changed, 21 insertions, 23 deletions
diff --git a/test/rexml/test_changing_encoding.rb b/test/rexml/test_changing_encoding.rb index f83247afb1..c6c1f59a1a 100644 --- a/test/rexml/test_changing_encoding.rb +++ b/test/rexml/test_changing_encoding.rb @@ -1,15 +1,13 @@ #!/usr/bin/ruby -Ku # -*- coding: utf-8 -*- -require 'kconv' -require 'iconv' require 'rexml/encoding' class ChangingEncodings < Test::Unit::TestCase def initialize a @u = 'テスト ほげ ふが 美しい' - @e = Kconv.toeuc(@u) + @e = @u.encode("EUC-JP") @f = Foo.new super end diff --git a/test/rexml/test_contrib.rb b/test/rexml/test_contrib.rb index 785169bdd0..f448b0fe4a 100644 --- a/test/rexml/test_contrib.rb +++ b/test/rexml/test_contrib.rb @@ -241,7 +241,7 @@ DELIMITER end doc = REXML::Document.new(source_iso) - assert_equal('ISO-8859-1', doc.xml_decl.encoding) + assert_equal('ISO-8859-1', doc.xml_decl.encoding.to_s) assert_equal(koln_utf, doc.root.text) doc.write(out="") assert_equal(source_iso, out ) @@ -270,7 +270,7 @@ EOF expected_utf = expected_iso.unpack('C*').pack('U*') if expected_utf.respond_to? :encode expected_iso.force_encoding("iso-8859-1") - expected_utf.force_encoding(Encoding::UTF_8) + expected_utf.force_encoding(::Encoding::UTF_8) end assert_equal(expected_utf, tn.to_s.strip) f = REXML::Formatters::Default.new diff --git a/test/rexml/test_core.rb b/test/rexml/test_core.rb index 48a31aee0e..5fae4f54e3 100644 --- a/test/rexml/test_core.rb +++ b/test/rexml/test_core.rb @@ -433,6 +433,11 @@ class Tester < Test::Unit::TestCase assert_equal source, decl2.to_s end + def test_xmldecl_utf_16be_encoding_name + assert_equal("<?xml version='1.0' encoding='UTF-16'?>", + XMLDecl.new("1.0", "UTF-16").to_s) + end + def each_test( element, xpath, num_children ) count = 0 element.each_element( xpath ) { |child| @@ -1123,7 +1128,6 @@ EOL end def test_repeated_writes - require 'iconv' a = IO.read(fixture_path("iso8859-1.xml")) f = REXML::Formatters::Pretty.new @@ -1246,9 +1250,9 @@ EOL def test_ticket_88 doc = REXML::Document.new("<?xml version=\"1.0\" encoding=\"shift_jis\"?>") - assert_equal("<?xml version='1.0' encoding='SHIFT_JIS'?>", doc.to_s) + assert_equal("<?xml version='1.0' encoding='Shift_JIS'?>", doc.to_s) doc = REXML::Document.new("<?xml version = \"1.0\" encoding = \"shift_jis\"?>") - assert_equal("<?xml version='1.0' encoding='SHIFT_JIS'?>", doc.to_s) + assert_equal("<?xml version='1.0' encoding='Shift_JIS'?>", doc.to_s) end def test_ticket_85 diff --git a/test/rexml/test_encoding.rb b/test/rexml/test_encoding.rb index 23e4802927..e1f9296821 100644 --- a/test/rexml/test_encoding.rb +++ b/test/rexml/test_encoding.rb @@ -26,7 +26,7 @@ class EncodingTester < Test::Unit::TestCase def test_encoded_in_change_out doc = Document.new( @encoded ) doc.xml_decl.encoding = "UTF-8" - assert_equal( doc.encoding, "UTF-8" ) + assert_equal( ::Encoding::UTF_8, doc.encoding ) REXML::Formatters::Default.new.write( doc.root, out="" ) out.force_encoding('binary') if out.respond_to? :force_encoding assert_equal( @not_encoded, out ) @@ -47,7 +47,7 @@ class EncodingTester < Test::Unit::TestCase def test_in_change_out doc = Document.new( @not_encoded ) doc.xml_decl.encoding = "ISO-8859-3" - assert_equal( doc.encoding, "ISO-8859-3" ) + assert_equal( ::Encoding::ISO_8859_3, doc.encoding ) doc.write( out="" ) out.force_encoding('binary') if out.respond_to? :force_encoding assert_equal( @encoded, out ) @@ -86,7 +86,7 @@ class EncodingTester < Test::Unit::TestCase def test_ticket_110 utf16 = REXML::Document.new(File.new(fixture_path("ticket_110_utf16.xml"))) - assert_equal( "UTF-16", utf16.encoding ) + assert_equal( ::Encoding::UTF_16BE, utf16.encoding ) assert( utf16[0].kind_of?(REXML::XMLDecl)) end end diff --git a/test/rss/test_1.0.rb b/test/rss/test_1.0.rb index 52ad24cfcd..4b496adfcd 100644 --- a/test/rss/test_1.0.rb +++ b/test/rss/test_1.0.rb @@ -24,9 +24,8 @@ module RSS xmldecl = doc.xml_decl - %w(version encoding).each do |x| - assert_equal(instance_eval(x), xmldecl.__send__(x)) - end + assert_equal(version, xmldecl.version) + assert_equal(encoding, xmldecl.encoding.to_s) assert_equal(standalone, !xmldecl.standalone.nil?) assert_equal(@rdf_uri, doc.root.namespace) diff --git a/test/rss/test_2.0.rb b/test/rss/test_2.0.rb index 884afcc816..ed83ca6cf7 100644 --- a/test/rss/test_2.0.rb +++ b/test/rss/test_2.0.rb @@ -21,9 +21,8 @@ module RSS xmldecl = doc.xml_decl - %w(version encoding).each do |x| - assert_equal(instance_eval(x), xmldecl.__send__(x)) - end + assert_equal(version, xmldecl.version) + assert_equal(encoding, xmldecl.encoding.to_s) assert_equal(standalone, !xmldecl.standalone.nil?) assert_equal("", doc.root.namespace) diff --git a/test/rss/test_atom.rb b/test/rss/test_atom.rb index 71e0f44ea9..80da69bd94 100644 --- a/test/rss/test_atom.rb +++ b/test/rss/test_atom.rb @@ -69,9 +69,8 @@ module RSS doc = REXML::Document.new(feed.to_s) xmldecl = doc.xml_decl - %w(version encoding).each do |x| - assert_equal(instance_eval(x), xmldecl.__send__(x)) - end + assert_equal(version, xmldecl.version) + assert_equal(encoding, xmldecl.encoding.to_s) assert_equal(standalone, !xmldecl.standalone.nil?) assert_equal(@uri, doc.root.namespace) @@ -96,9 +95,8 @@ module RSS doc = REXML::Document.new(entry.to_s) xmldecl = doc.xml_decl - %w(version encoding).each do |x| - assert_equal(instance_eval(x), xmldecl.__send__(x)) - end + assert_equal(version, xmldecl.version) + assert_equal(encoding, xmldecl.encoding.to_s) assert_equal(standalone, !xmldecl.standalone.nil?) assert_equal(@uri, doc.root.namespace) |