summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author卜部昌平 <shyouhei@ruby-lang.org>2019-10-08 11:21:20 +0900
committer卜部昌平 <shyouhei@ruby-lang.org>2019-10-08 11:21:20 +0900
commit11b6ff12af99b177979c7a4f57f49b91a50fcc0c (patch)
tree459c2257a9807fd8f4fee77962a65cf09a080a74
parentdd0c75fdc2104a6ba38b68d4431a572504a3bbc2 (diff)
more use of RbConfig::LIMITS
`8 * RbConfig::SIZEOF` ... is not straight.
-rw-r--r--test/-ext-/string/test_modify_expand.rb3
-rw-r--r--test/stringio/test_stringio.rb5
2 files changed, 3 insertions, 5 deletions
diff --git a/test/-ext-/string/test_modify_expand.rb b/test/-ext-/string/test_modify_expand.rb
index b7f96426fc..9aa3b9a6ca 100644
--- a/test/-ext-/string/test_modify_expand.rb
+++ b/test/-ext-/string/test_modify_expand.rb
@@ -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
diff --git a/test/stringio/test_stringio.rb b/test/stringio/test_stringio.rb
index b4369ede5f..07fe350b46 100644
--- a/test/stringio/test_stringio.rb
+++ b/test/stringio/test_stringio.rb
@@ -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}