From e49820a827a6c495fcaf19fc7398316409fd1953 Mon Sep 17 00:00:00 2001 From: akr Date: Sun, 20 Jan 2008 00:51:52 +0000 Subject: [PATCH] add a test. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15137 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_m17n.rb | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/test/ruby/test_m17n.rb b/test/ruby/test_m17n.rb index 8bdcd26c4b..10be0433f0 100644 --- a/test/ruby/test_m17n.rb +++ b/test/ruby/test_m17n.rb @@ -297,12 +297,23 @@ class TestM17N < Test::Unit::TestCase end def test_utf16 - assert_equal(255, "f\0f\0".force_encoding("utf-16le").hex) - assert_raise(ArgumentError) { - "aa".force_encoding("utf-16be").count("aa") + s1 = "ab".force_encoding("utf-16be") + s2 = "b".force_encoding("utf-16be") + assert_equal(false, s1.end_with?(s2), "#{encdump s1}.end_with?(#{encdump s2})") + + s1 = "f\0f\0".force_encoding("utf-16le") + assert_equal(255, s1.hex, "#{encdump s1}.hex") + + s1 = "aa".force_encoding("utf-16be") + s2 = "aa" + assert_raise(ArgumentError, "#{encdump s1}.count(#{encdump s2})") { + s1.count(s2) } - assert_raise(ArgumentError) { - "a".force_encoding("us-ascii") + "aa".force_encoding("utf-16be") + + s1 = "a".force_encoding("us-ascii") + s2 = "aa".force_encoding("utf-16be") + assert_raise(ArgumentError, "#{encdump s1} + #{encdump s2}") { + s1 + s2 } end