1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Suppress warnings: setting Encoding.default_internal

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41036 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
naruse 2013-06-02 14:46:43 +00:00
parent 166d8dc2d6
commit dffcadb4ea

View file

@ -2,6 +2,7 @@
# some of the comments are in UTF-8
require 'test/unit'
require_relative 'envutil'
class TestTranscode < Test::Unit::TestCase
def test_errors
assert_raise(Encoding::ConverterNotFoundError) { 'abc'.encode('foo', 'bar') }
@ -29,16 +30,16 @@ class TestTranscode < Test::Unit::TestCase
end
def test_noargument
default_default_internal = Encoding.default_internal
Encoding.default_internal = nil
assert_equal("\u3042".encode, "\u3042")
assert_equal("\xE3\x81\x82\x81".force_encoding("utf-8").encode,
"\xE3\x81\x82\x81".force_encoding("utf-8"))
Encoding.default_internal = 'EUC-JP'
assert_equal("\u3042".encode, "\xA4\xA2".force_encoding('EUC-JP'))
assert_equal("\xE3\x81\x82\x81".force_encoding("utf-8").encode,
"\xA4\xA2?".force_encoding('EUC-JP'))
Encoding.default_internal = default_default_internal
EnvUtil.with_default_internal(nil) do
assert_equal("\u3042".encode, "\u3042")
assert_equal("\xE3\x81\x82\x81".force_encoding("utf-8").encode,
"\xE3\x81\x82\x81".force_encoding("utf-8"))
end
EnvUtil.with_default_internal('EUC-JP') do
assert_equal("\u3042".encode, "\xA4\xA2".force_encoding('EUC-JP'))
assert_equal("\xE3\x81\x82\x81".force_encoding("utf-8").encode,
"\xA4\xA2?".force_encoding('EUC-JP'))
end
end
def test_length