2015-12-16 00:07:31 -05:00
|
|
|
# frozen_string_literal: false
|
2012-02-08 08:35:27 -05:00
|
|
|
require 'test/unit'
|
2015-07-14 23:56:17 -04:00
|
|
|
require "-test-/string"
|
2012-02-08 08:35:27 -05:00
|
|
|
|
|
|
|
class Test_StringModifyExpand < Test::Unit::TestCase
|
|
|
|
def test_modify_expand_memory_leak
|
2015-07-14 23:56:17 -04:00
|
|
|
assert_no_memory_leak(["-r-test-/string"],
|
2014-09-17 18:05:22 -04:00
|
|
|
<<-PRE, <<-CMD, "rb_str_modify_expand()", limit: 2.5)
|
2012-02-08 08:35:27 -05:00
|
|
|
s=Bug::String.new
|
2012-02-09 10:47:11 -05:00
|
|
|
PRE
|
|
|
|
size = $initial_size
|
2012-02-08 08:35:27 -05:00
|
|
|
10.times{s.modify_expand!(size)}
|
|
|
|
s.replace("")
|
|
|
|
CMD
|
|
|
|
end
|
2016-05-18 01:52:40 -04:00
|
|
|
|
|
|
|
def test_integer_overflow
|
|
|
|
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)
|
|
|
|
}
|
|
|
|
end
|
2012-02-08 08:35:27 -05:00
|
|
|
end
|