diff options
author | Benoit Daloze <eregontp@gmail.com> | 2021-11-29 15:50:28 +0100 |
---|---|---|
committer | Benoit Daloze <eregontp@gmail.com> | 2021-11-29 15:50:28 +0100 |
commit | 67a1e2258974df4b597d019739595c18fbb9a7c1 (patch) | |
tree | 992ad4fc0fc08a6af8f04373703a339f957eb143 /spec/ruby/core/encoding/converter | |
parent | e6d93a27afa058319e6dad093bbef637e49fce47 (diff) |
Update to ruby/spec@7f22a0b
Diffstat (limited to 'spec/ruby/core/encoding/converter')
-rw-r--r-- | spec/ruby/core/encoding/converter/putback_spec.rb | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/spec/ruby/core/encoding/converter/putback_spec.rb b/spec/ruby/core/encoding/converter/putback_spec.rb index 87495eaf3f..c4e0a5da21 100644 --- a/spec/ruby/core/encoding/converter/putback_spec.rb +++ b/spec/ruby/core/encoding/converter/putback_spec.rb @@ -34,14 +34,23 @@ describe "Encoding::Converter#putback" do @ec.putback.should == "" end + it "returns the problematic bytes for UTF-16LE" do + ec = Encoding::Converter.new("utf-16le", "iso-8859-1") + src = "\x00\xd8\x61\x00" + dst = "" + ec.primitive_convert(src, dst).should == :invalid_byte_sequence + ec.primitive_errinfo.should == [:invalid_byte_sequence, "UTF-16LE", "UTF-8", "\x00\xD8", "a\x00"] + ec.putback.should == "a\x00".force_encoding("utf-16le") + ec.putback.should == "" + end + it "accepts an integer argument corresponding to the number of bytes to be put back" do ec = Encoding::Converter.new("utf-16le", "iso-8859-1") src = "\x00\xd8\x61\x00" dst = "" ec.primitive_convert(src, dst).should == :invalid_byte_sequence ec.primitive_errinfo.should == [:invalid_byte_sequence, "UTF-16LE", "UTF-8", "\x00\xD8", "a\x00"] - ec.putback(1).should == "\x00".force_encoding("utf-16le") - ec.putback.should == "a".force_encoding("utf-16le") + ec.putback(2).should == "a\x00".force_encoding("utf-16le") ec.putback.should == "" end end |