From 6c60006de5cfd75f10a1b4a3d822e2de41d22db6 Mon Sep 17 00:00:00 2001 From: Jeremy Evans Date: Fri, 10 Feb 2023 10:33:53 -0800 Subject: Raise ArgumentError if IO.read is provided negative offset Fixes [Bug #19380] --- test/ruby/test_io.rb | 3 +++ 1 file changed, 3 insertions(+) (limited to 'test') diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb index 0716dd7bf9..f57dee4261 100644 --- a/test/ruby/test_io.rb +++ b/test/ruby/test_io.rb @@ -2866,6 +2866,9 @@ class TestIO < Test::Unit::TestCase assert_equal("foo\nbar\nbaz\n", File.read(t.path)) assert_equal("foo\nba", File.read(t.path, 6)) assert_equal("bar\n", File.read(t.path, 4, 4)) + + assert_raise(ArgumentError) { File.read(t.path, -1) } + assert_raise(ArgumentError) { File.read(t.path, 1, -1) } } end -- cgit v1.2.3