summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-01-30 06:13:25 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-01-30 06:13:25 +0000
commitb4be48e88d74c1e5cce9d68aed30c4e4ef17d7c5 (patch)
tree3066878392faddefabd02e3e318ea5c14dbd9ab7 /test
parent46142e472fd713023766aa2943158d7fd50011ae (diff)
* enc/emacs_mule.c (emacsmule_islead): 7bit range is also leading
byte. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30731 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_m17n.rb28
1 files changed, 17 insertions, 11 deletions
diff --git a/test/ruby/test_m17n.rb b/test/ruby/test_m17n.rb
index 8a945481c3..799e46073c 100644
--- a/test/ruby/test_m17n.rb
+++ b/test/ruby/test_m17n.rb
@@ -1106,17 +1106,11 @@ class TestM17N < Test::Unit::TestCase
s1 = s("\x81\x40")
s2 = "@"
assert_equal(false, s1.end_with?(s2), "#{encdump s1}.end_with?(#{encdump s2})")
- s1orig = "\u3042\u3044"
- s2orig = "\u3044"
- Encoding.list.each do |enc|
- next if enc.dummy?
- begin
- s1 = s1orig.encode(enc)
- s2 = s2orig.encode(enc)
- rescue
- else
- assert_equal(true, s1.end_with?(s2), "#{encdump s1}.end_with?(#{encdump s2})")
- end
+ each_encoding("\u3042\u3044", "\u3044") do |_s1, _s2|
+ assert_equal(true, _s1.end_with?(_s2), "#{encdump _s1}.end_with?(#{encdump _s2})")
+ end
+ each_encoding("\u3042a\u3044", "a\u3044") do |_s1, _s2|
+ assert_equal(true, _s1.end_with?(_s2), "#{encdump _s1}.end_with?(#{encdump _s2})")
end
end
@@ -1152,6 +1146,10 @@ class TestM17N < Test::Unit::TestCase
assert_equal(e("\xa1\xa2\xa1\xa3").split(//),
[e("\xa1\xa2"), e("\xa1\xa3")],
'[ruby-dev:32452]')
+
+ each_encoding("abc,def", ",", "abc", "def") do |str, sep, *expected|
+ assert_equal(expected, str.split(sep, -1))
+ end
end
def test_nonascii_method_name
@@ -1397,4 +1395,12 @@ class TestM17N < Test::Unit::TestCase
def test_combchar_codepoint
assert_equal([0x30BB, 0x309A], "\u30BB\u309A".codepoints.to_a)
end
+
+ def each_encoding(*strings)
+ Encoding.list.each do |enc|
+ next if enc.dummy?
+ strs = strings.map {|s| s.encode(enc)} rescue next
+ yield *strs
+ end
+ end
end