summaryrefslogtreecommitdiff
path: root/test/stringio
diff options
context:
space:
mode:
authorYoann Lecuyer <yoann.lecuyer@gmail.com>2020-08-26 22:46:58 +0200
committerNobuyoshi Nakada <nobu@ruby-lang.org>2020-08-27 23:41:22 +0900
commitb3c1c767ea64ce435c115cece5074274b7aefadc (patch)
tree03b1c4cfa9f426df1bac008556f96952afe3ce8a /test/stringio
parent96d701f73780638ffd3c8fa91c43f33f1a207d65 (diff)
downloadruby-b3c1c767ea64ce435c115cece5074274b7aefadc.tar.gz
[stringio] fix stringio codepoint enumerator off by one error
Diffstat (limited to 'test/stringio')
-rw-r--r--test/stringio/test_stringio.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/test/stringio/test_stringio.rb b/test/stringio/test_stringio.rb
index 54f57165a4..a49326119f 100644
--- a/test/stringio/test_stringio.rb
+++ b/test/stringio/test_stringio.rb
@@ -525,6 +525,16 @@ class TestStringIO < Test::Unit::TestCase
assert_equal([49, 50, 51, 52], f.each_codepoint.to_a)
end
+ def test_each_codepoint_enumerator
+ io = StringIO.new('你好построить')
+
+ chinese_part = io.each_codepoint.take(2).pack('U*')
+ russian_part = io.read(40).force_encoding('UTF-8')
+
+ assert_equal("你好", chinese_part)
+ assert_equal("построить", russian_part)
+ end
+
def test_gets2
f = StringIO.new("foo\nbar\nbaz\n")
assert_equal("fo", f.gets(2))