From b28155a02faccaffc35fb04ec1e80ae1239d06cf Mon Sep 17 00:00:00 2001 From: akr Date: Thu, 20 Dec 2007 10:09:32 +0000 Subject: [PATCH] add test for succ. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14366 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_m17n.rb | 54 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 50 insertions(+), 4 deletions(-) diff --git a/test/ruby/test_m17n.rb b/test/ruby/test_m17n.rb index 36fafc8a6e..8b06a2e07b 100644 --- a/test/ruby/test_m17n.rb +++ b/test/ruby/test_m17n.rb @@ -1534,6 +1534,11 @@ class TestM17N < Test::Unit::TestCase } end + def test_squeeze + s = "\xa3\xb0\xa3\xb1\xa3\xb1\xa3\xb3\xa3\xb4".force_encoding("euc-jp") + assert_equal("\xa3\xb0\xa3\xb1\xa3\xb3\xa3\xb4".force_encoding("euc-jp"), s.squeeze) + end + def test_str_strip STRINGS.each {|s| if !s.valid_encoding? @@ -1627,14 +1632,55 @@ class TestM17N < Test::Unit::TestCase encs << s3.encoding if !is_ascii_only?(s3) encs.uniq! #p e, encs - assert(1 < encs.length) + assert(1 < encs.length, "#{encdump s1}.tr(#{encdump s2}, #{encdump s3})") end } end - def test_squeeze - s = "\xa3\xb0\xa3\xb1\xa3\xb1\xa3\xb3\xa3\xb4".force_encoding("euc-jp") - assert_equal("\xa3\xb0\xa3\xb1\xa3\xb3\xa3\xb4".force_encoding("euc-jp"), s.squeeze) + def test_tr_s + combination(STRINGS, STRINGS, STRINGS) {|s1, s2, s3| + begin + #puts "#{encdump s1}.tr_s(#{encdump s2}, #{encdump s3})" + t = s1.tr_s(s2, s3) + rescue ArgumentError + e = $! + end + if e + encs = [] + encs << s1.encoding if !is_ascii_only?(s1) + encs << s2.encoding if !is_ascii_only?(s2) + encs << s3.encoding if !is_ascii_only?(s3) + encs.uniq! + #p e, encs + assert(1 < encs.length, "#{encdump s1}.tr_s(#{encdump s2}, #{encdump s3})") + end + } + end + + def test_str_upcase + STRINGS.each {|s| + begin + t1 = s.upcase + rescue ArgumentError + assert(!s.valid_encoding?) + next + end + assert(t1.valid_encoding?) if s.valid_encoding? + assert(t1.casecmp(s)) + t2 = s.dup + t2.upcase! + assert_equal(t1, t2) + } + end + + def test_str_succ + s0 = e("\xA1\xA1") + s = s0.dup + n = 1000 + n.times { + s.succ! + } + assert_operator(s.length, :<, s0.length + Math.log2(n) + 1) end def test_sub