summaryrefslogtreecommitdiff
path: root/test/stringio
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-07-11 21:42:27 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-07-11 21:42:27 +0000
commita3d6de4adc8581e8c845b5e9cee6c17171832b37 (patch)
treec8ecc9bd022f56db38ffbe315a167a84cb27736a /test/stringio
parent8c0b261d48c3473a86a7e92c9101ce98ab94a15a (diff)
Simple testing for StringIO#sysread
* test/stringio/test_stringio.rb (test_sysread): add a test for StringIO#sysread. [Fix GH-966] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51219 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
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 966bbe1..bd4a0f1 100644
--- a/test/stringio/test_stringio.rb
+++ b/test/stringio/test_stringio.rb
@@ -470,6 +470,7 @@ class TestStringIO < Test::Unit::TestCase
assert_raise(ArgumentError) { f.read(-1) }
assert_raise(ArgumentError) { f.read(1, 2, 3) }
assert_equal("\u3042\u3044", f.read)
+ assert_nil(f.read(1))
f.rewind
assert_equal("\u3042\u3044".force_encoding(Encoding::ASCII_8BIT), f.read(f.size))
@@ -525,6 +526,15 @@ class TestStringIO < Test::Unit::TestCase
assert_equal("\u3042\u3044".force_encoding(Encoding::ASCII_8BIT), f.read_nonblock(f.size, s))
end
+ def test_sysread
+ f = StringIO.new("sysread \u{30c6 30b9 30c8}")
+ assert_equal "sysread \u{30c6 30b9 30c8}", f.sysread
+ assert_equal "", f.sysread
+ assert_raise(EOFError) { f.sysread(1) }
+ f.rewind
+ assert_equal Encoding::ASCII_8BIT, f.sysread(3).encoding
+ end
+
def test_size
f = StringIO.new("1234")
assert_equal(4, f.size)