File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 9393 @rd . readpartial ( 0 ) . should == ""
9494 end
9595
96+ it "raises IOError if the stream is closed and the length argument is 0" do
97+ @rd . close
98+ -> { @rd . readpartial ( 0 ) } . should raise_error ( IOError , "closed stream" )
99+ end
100+
96101 it "clears and returns the given buffer if the length argument is 0" do
97102 buffer = +"existing content"
98103 @rd . readpartial ( 0 , buffer ) . should == buffer
Original file line number Diff line number Diff line change 6161
6262 it "raises IOError if the stream is closed" do
6363 @string . close
64- -> { @string . readpartial ( 1 ) } . should raise_error ( IOError )
64+ -> { @string . readpartial ( 1 ) } . should raise_error ( IOError , "not opened for reading" )
6565 end
6666
6767 it "raises ArgumentError if the negative argument is provided" do
68- -> { @string . readpartial ( -1 ) } . should raise_error ( ArgumentError )
68+ -> { @string . readpartial ( -1 ) } . should raise_error ( ArgumentError , "negative length -1 given" )
6969 end
7070
7171 it "immediately returns an empty string if the length argument is 0" do
7272 @string . readpartial ( 0 ) . should == ""
7373 end
74+
75+ it "raises IOError if the stream is closed and the length argument is 0" do
76+ @string . close
77+ -> { @string . readpartial ( 0 ) } . should raise_error ( IOError , "not opened for reading" )
78+ end
79+
80+ it "clears and returns the given buffer if the length argument is 0" do
81+ buffer = +"existing content"
82+ @string . readpartial ( 0 , buffer ) . should == buffer
83+ buffer . should == ""
84+ end
85+
86+ version_is StringIO ::VERSION , "3.1.2" do # ruby_version_is "3.4"
87+ it "preserves the encoding of the given buffer" do
88+ buffer = '' . encode ( Encoding ::ISO_8859_1 )
89+ @string . readpartial ( 10 , buffer )
90+
91+ buffer . encoding . should == Encoding ::ISO_8859_1
92+ end
93+ end
7494end
You can’t perform that action at this time.
0 commit comments