From 7ed37388fb9c0e85325b4e3db2ffbfca3f4179ad Mon Sep 17 00:00:00 2001 From: Sutou Kouhei Date: Wed, 8 Nov 2023 09:46:10 +0900 Subject: [ruby/stringio] Add missing row separator encoding conversion (https://github.com/ruby/stringio/pull/69) The conversion logic is borrowed from ruby/ruby's io.c: https://github.com/ruby/ruby/blob/40391faeab608665da87a05c686c074f91a5a206/io.c#L4059-L4079 Fix ruby/stringio#68 Reported by IWAMOTO Kouichi. Thanks!!! https://github.com/ruby/stringio/commit/4b170c1a68 --- test/stringio/test_stringio.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'test') diff --git a/test/stringio/test_stringio.rb b/test/stringio/test_stringio.rb index cb82841231..216b06d3ad 100644 --- a/test/stringio/test_stringio.rb +++ b/test/stringio/test_stringio.rb @@ -88,6 +88,14 @@ class TestStringIO < Test::Unit::TestCase assert_string("", Encoding::UTF_8, StringIO.new("foo").gets(0)) end + def test_gets_utf_16 + stringio = StringIO.new("line1\nline2\nline3\n".encode("utf-16le")) + assert_equal("line1\n".encode("utf-16le"), stringio.gets) + assert_equal("line2\n".encode("utf-16le"), stringio.gets) + assert_equal("line3\n".encode("utf-16le"), stringio.gets) + assert_nil(stringio.gets) + end + def test_gets_chomp assert_equal(nil, StringIO.new("").gets(chomp: true)) assert_equal("", StringIO.new("\n").gets(chomp: true)) -- cgit v1.2.3