summaryrefslogtreecommitdiff
path: root/test/rexml/test_changing_encoding.rb
diff options
context:
space:
mode:
authorkou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-09-17 13:14:14 +0000
committerkou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-09-17 13:14:14 +0000
commit91ed484f92040e5c2006a3a00ec77a54d552cf37 (patch)
tree03fd6677a85aaad516d0c9464b1273ea107231b7 /test/rexml/test_changing_encoding.rb
parent045491d5be06b615d66d3f66cca2b5d2bc3c1929 (diff)
* 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.rb46
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 0000000..f83247a
--- /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