summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorHiroshi SHIBATA <hsbt@ruby-lang.org>2024-03-21 15:56:32 +0900
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2024-04-23 16:04:41 +0900
commit26ec606bcd2de68b457a9b36852b764a71083b25 (patch)
tree8b76dcfd6c667cde1312598bdcda1337a221af00 /test
parent3229fb9769790c650cd9d11e64648daf576e11fa (diff)
Merge StringIO 3.0.1.2
Diffstat (limited to 'test')
-rw-r--r--test/stringio/test_stringio.rb25
1 files changed, 21 insertions, 4 deletions
diff --git a/test/stringio/test_stringio.rb b/test/stringio/test_stringio.rb
index e91a625488..0a4b90ef96 100644
--- a/test/stringio/test_stringio.rb
+++ b/test/stringio/test_stringio.rb
@@ -759,6 +759,15 @@ class TestStringIO < Test::Unit::TestCase
assert_equal("b""\0""a", s.string)
end
+ def test_ungetc_fill
+ count = 100
+ s = StringIO.new
+ s.print 'a' * count
+ s.ungetc('b' * (count * 5))
+ assert_equal((count * 5), s.string.size)
+ assert_match(/\Ab+\z/, s.string)
+ end
+
def test_ungetbyte_pos
b = '\\b00010001 \\B00010001 \\b1 \\B1 \\b000100011'
s = StringIO.new( b )
@@ -784,6 +793,15 @@ class TestStringIO < Test::Unit::TestCase
assert_equal("b""\0""a", s.string)
end
+ def test_ungetbyte_fill
+ count = 100
+ s = StringIO.new
+ s.print 'a' * count
+ s.ungetbyte('b' * (count * 5))
+ assert_equal((count * 5), s.string.size)
+ assert_match(/\Ab+\z/, s.string)
+ end
+
def test_frozen
s = StringIO.new
s.freeze
@@ -827,18 +845,17 @@ class TestStringIO < Test::Unit::TestCase
end
def test_overflow
- omit if RbConfig::SIZEOF["void*"] > RbConfig::SIZEOF["long"]
+ return if RbConfig::SIZEOF["void*"] > RbConfig::SIZEOF["long"]
limit = RbConfig::LIMITS["INTPTR_MAX"] - 0x10
assert_separately(%w[-rstringio], "#{<<-"begin;"}\n#{<<-"end;"}")
begin;
limit = #{limit}
ary = []
- while true
+ begin
x = "a"*0x100000
break if [x].pack("p").unpack("i!")[0] < 0
ary << x
- omit if ary.size > 100
- end
+ end while ary.size <= 100
s = StringIO.new(x)
s.gets("xxx", limit)
assert_equal(0x100000, s.pos)