Debian Codegraph @

test/-ext-/string/test_modify_expand.rb

raw
1 # frozen_string_literal: false
2 require 'test/unit'
3 require "-test-/string"
4 require "rbconfig/sizeof"
5
6 class Test_StringModifyExpand < Test::Unit::TestCase
7 def test_modify_expand_memory_leak
8 assert_no_memory_leak(["-r-test-/string"],
9 <<-PRE, <<-CMD, "rb_str_modify_expand()", limit: 2.5)
10 s=Bug::String.new
11 PRE
12 size = $initial_size
13 10.times{s.modify_expand!(size)}
14 s.replace("")
15 CMD
16 end
17
18 def test_integer_overflow
19 return if RbConfig::SIZEOF['size_t'] > RbConfig::SIZEOF['long']
20 bug12390 = '[ruby-core:75592] [Bug #12390]'
21 s = Bug::String.new
22 assert_raise(ArgumentError, bug12390) {
23 s.modify_expand!(RbConfig::LIMITS["LONG_MAX"])
24 }
25 end
26 end