diff options
author | kou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-09-17 13:14:14 +0000 |
---|---|---|
committer | kou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-09-17 13:14:14 +0000 |
commit | 91ed484f92040e5c2006a3a00ec77a54d552cf37 (patch) | |
tree | 03fd6677a85aaad516d0c9464b1273ea107231b7 /test/rexml/test_changing_encoding.rb | |
parent | 045491d5be06b615d66d3f66cca2b5d2bc3c1929 (diff) | |
download | ruby-91ed484f92040e5c2006a3a00ec77a54d552cf37.tar.gz |
* test/rexml/: import REXML tests from
http://www.germane-software.com/repos/rexml/trunk/test/.
Many tests are failed temporary. I'll fix them quickly. Sorry.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29282 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/rexml/test_changing_encoding.rb')
-rw-r--r-- | test/rexml/test_changing_encoding.rb | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/test/rexml/test_changing_encoding.rb b/test/rexml/test_changing_encoding.rb new file mode 100644 index 0000000000..f83247afb1 --- /dev/null +++ b/test/rexml/test_changing_encoding.rb @@ -0,0 +1,46 @@ +#!/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) + @f = Foo.new + super + end + + class Foo + include REXML::Encoding + end + + # Note that these tests must be executed in order for the third one to + # actually test anything. + def test_0_euc + @f.encoding = 'EUC-JP' + assert_equal( @u, @f.decode(@e) ) + # This doesn't happen anymore, for some reason + #assert_raises( Iconv::IllegalSequence, "Decoding unicode should fail" ) { + # @f.decode(@u) == @u + #} + end + + def test_1_utf + @f.encoding = 'UTF-8' + assert_not_equal( @u, @f.decode( @e ) ) + assert_equal( @u, @f.decode( @u ) ) + end + + def test_2_euc + @f.encoding = 'EUC-JP' + assert_equal( @u, @f.decode(@e) ) + # This doesn't happen anymore, for some reason + #assert_raises( Iconv::IllegalSequence, "Decoding unicode should fail" ) { + # @f.decode(@u) == @u + #} + end +end |