aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorSutou Kouhei <kou@clear-code.com>2023-11-08 09:46:10 +0900
committergit <svn-admin@ruby-lang.org>2023-11-08 00:46:17 +0000
commit7ed37388fb9c0e85325b4e3db2ffbfca3f4179ad (patch)
treecd4cee344e40960484f60b72c699fc090b744460 /test
parent2f07963609aeb4f70ca74cedd73faa3b5cf21c17 (diff)
downloadruby-7ed37388fb9c0e85325b4e3db2ffbfca3f4179ad.tar.gz
[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
Diffstat (limited to 'test')
-rw-r--r--test/stringio/test_stringio.rb8
1 files changed, 8 insertions, 0 deletions
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))