test_m17n.rb: split tests for inspect

* test/ruby/test_m17n.rb (test_utf_16_32_inspect): split tests for
  each encodings.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44604 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2014-01-15 05:03:24 +00:00
Родитель 4892d046e5
Коммит de6d422655
1 изменённых файлов: 10 добавлений и 12 удалений

Просмотреть файл

@ -226,24 +226,22 @@ class TestM17N < Test::Unit::TestCase
end
end
def test_utf_16_32_inspect
str = "\u3042"
%w/UTF-16 UTF-32/.each do |enc|
%w/BE LE/.each do |endian|
s = str.encode(enc + endian)
STR_WITHOUT_BOM = "\u3042".freeze
STR_WITH_BOM = "\uFEFF\u3042".freeze
%w/UTF-16 UTF-32/.each do |enc|
%w/BE LE/.each do |endian|
define_method("test_utf_16_32_inspect(#{enc}#{endian})") do
s = STR_WITHOUT_BOM.encode(enc + endian)
# When a UTF-16/32 string doesn't have a BOM,
# inspect as a dummy encoding string.
assert_equal(s.dup.force_encoding("ISO-2022-JP").inspect,
s.dup.force_encoding(enc).inspect)
end
end
str = "\uFEFF\u3042"
%w/UTF-16 UTF-32/.each do |enc|
%w/BE LE/.each do |endian|
s = str.encode(enc + endian)
# When a UTF-16/32 string doesn't have a BOM,
# inspect as a dummy encoding string.
define_method("test_utf_16_32_inspect(#{enc}#{endian}-BOM)") do
s = STR_WITH_BOM.encode(enc + endian)
# When a UTF-16/32 string has a BOM,
# inspect as a particular encoding string.
assert_equal(s.inspect,
s.dup.force_encoding(enc).inspect)
end