Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions library/stringio/readpartial_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# encoding: binary
Copy link
Member

@andrykonchin andrykonchin Aug 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably we can avoid this just by converting string literals to binary encoding explicitly:

    @string.readpartial(3).should == "\xE2\x88\x82".b
    @string.readpartial(3).should == "\xCF\x86/".b

Does it look better?

require_relative '../../spec_helper'
require_relative 'fixtures/classes'

Expand All @@ -24,6 +25,14 @@
@string.readpartial(3).should == ", l"
end

it "reads after ungetc with multibyte characters in the buffer" do
@string = StringIO.new(+"∂φ/∂x = gaîté")
c = @string.getc
@string.ungetc(c)
@string.readpartial(3).should == "\xE2\x88\x82"
@string.readpartial(3).should == "\xCF\x86/"
end

it "reads after ungetc without data in the buffer" do
@string = StringIO.new
@string.write("f").should == 1
Expand Down
Loading