Skip to content

Commit 632378a

Browse files
committed
Add "reads after ungetc with multibyte characters in the buffer" spec to StringIO#readpartial
This one was missing in #1278, I got it to work with the `encoding: binary` directive. The StringIO code was fine, the spec was just incomplete.
1 parent 7863a1b commit 632378a

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

library/stringio/readpartial_spec.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# encoding: binary
12
require_relative '../../spec_helper'
23
require_relative 'fixtures/classes'
34

@@ -24,6 +25,14 @@
2425
@string.readpartial(3).should == ", l"
2526
end
2627

28+
it "reads after ungetc with multibyte characters in the buffer" do
29+
@string = StringIO.new(+"∂φ/∂x = gaîté")
30+
c = @string.getc
31+
@string.ungetc(c)
32+
@string.readpartial(3).should == "\xE2\x88\x82"
33+
@string.readpartial(3).should == "\xCF\x86/"
34+
end
35+
2736
it "reads after ungetc without data in the buffer" do
2837
@string = StringIO.new
2938
@string.write("f").should == 1

0 commit comments

Comments
 (0)