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

more use of RbConfig::LIMITS

`8 * RbConfig::SIZEOF` ... is not straight.
This commit is contained in:
卜部昌平 2019-10-08 11:21:20 +09:00
parent dd0c75fdc2
commit 11b6ff12af
2 changed files with 3 additions and 5 deletions

View file

@ -19,9 +19,8 @@ class Test_StringModifyExpand < Test::Unit::TestCase
return if RbConfig::SIZEOF['size_t'] > RbConfig::SIZEOF['long']
bug12390 = '[ruby-core:75592] [Bug #12390]'
s = Bug::String.new
long_max = (1 << (8 * RbConfig::SIZEOF['long'] - 1)) - 1
assert_raise(ArgumentError, bug12390) {
s.modify_expand!(long_max)
s.modify_expand!(RbConfig::LIMITS["LONG_MAX"])
}
end
end

View file

@ -199,9 +199,8 @@ class TestStringIO < Test::Unit::TestCase
end
def test_write_integer_overflow
long_max = (1 << (RbConfig::SIZEOF["long"] * 8 - 1)) - 1
f = StringIO.new
f.pos = long_max
f.pos = RbConfig::LIMITS["LONG_MAX"]
assert_raise(ArgumentError) {
f.write("pos + len overflows")
}
@ -767,7 +766,7 @@ class TestStringIO < Test::Unit::TestCase
def test_overflow
skip if RbConfig::SIZEOF["void*"] > RbConfig::SIZEOF["long"]
limit = (1 << (RbConfig::SIZEOF["void*"]*8-1)) - 0x10
limit = RbConfig::LIMITS["INTPTR_MAX"] - 0x10
assert_separately(%w[-rstringio], "#{<<-"begin;"}\n#{<<-"end;"}")
begin;
limit = #{limit}