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

* string.c (rb_str_succ): don't increment/decrement codepoint.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15268 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2008-01-27 08:21:24 +00:00
parent 4a9d407e35
commit b1e6c052cd
3 changed files with 170 additions and 92 deletions

View file

@ -1349,10 +1349,6 @@ class TestM17NComb < Test::Unit::TestCase
end
def test_str_succ
starts = [
e("\xA1\xA1"),
e("\xFE\xFE")
]
STRINGS.each {|s0|
next if s0.empty?
s = s0.dup
@ -1360,11 +1356,16 @@ class TestM17NComb < Test::Unit::TestCase
h = {}
n.times {|i|
if h[s]
assert(false, "#{encdump s} cycle with succ! #{i-h[s]} times")
assert(false, "#{encdump s} cycle with succ #{i-h[s]} times")
end
h[s] = i
assert_operator(s.length, :<=, s0.length + Math.log2(i+1) + 1, "#{encdump s0} succ! #{i} times => #{encdump s}")
s.succ!
assert_operator(s.length, :<=, s0.length + Math.log2(i+1) + 1, "#{encdump s0} succ #{i} times => #{encdump s}")
#puts encdump(s)
t = s.succ
if s.valid_encoding?
assert(t.valid_encoding?, "#{encdump s}.succ.valid_encoding?")
end
s = t
}
}
end