diff options
| author | Takashi Kokubun <takashikkbn@gmail.com> | 2025-01-14 17:53:38 -0800 |
|---|---|---|
| committer | Takashi Kokubun <takashikkbn@gmail.com> | 2025-01-14 17:53:38 -0800 |
| commit | 00147cbab567b05b8a4137875bbda341ef704760 (patch) | |
| tree | 9d7394bbac93a711c67c25c2ac5141acbcbcde80 /test/ruby | |
| parent | 1b1c6e67588ef417847d36f4f4017bd18157a1d2 (diff) | |
merge revision(s) e90b447655dd39ad1eb645cdaae450efd605db00: [Backport #20924]
[Bug #20924] Fix reading with delimiter in wide character encodings
Diffstat (limited to 'test/ruby')
| -rw-r--r-- | test/ruby/test_io.rb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb index 7542f08fcf..51c9f2b83c 100644 --- a/test/ruby/test_io.rb +++ b/test/ruby/test_io.rb @@ -2010,6 +2010,36 @@ class TestIO < Test::Unit::TestCase } end + def test_readline_limit_nonascii + mkcdtmpdir do + i = 0 + + File.open("text#{i+=1}", "w+:utf-8") do |f| + f.write("Test\nok\u{bf}ok\n") + f.rewind + + assert_equal("Test\nok\u{bf}", f.readline("\u{bf}")) + assert_equal("ok\n", f.readline("\u{bf}")) + end + + File.open("text#{i+=1}", "w+b:utf-32le") do |f| + f.write("0123456789") + f.rewind + + assert_equal(4, f.readline(4).bytesize) + assert_equal(4, f.readline(3).bytesize) + end + + File.open("text#{i+=1}", "w+:utf-8:utf-32le") do |f| + f.write("0123456789") + f.rewind + + assert_equal(4, f.readline(4).bytesize) + assert_equal(4, f.readline(3).bytesize) + end + end + end + def test_set_lineno_readline pipe(proc do |w| w.puts "foo" |
