mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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
This commit is contained in:
parent
8c0b261d48
commit
a3d6de4adc
2 changed files with 15 additions and 0 deletions
|
@ -1,3 +1,8 @@
|
|||
Sun Jul 12 06:42:23 2015 ksss <co000ri@gmail.com>
|
||||
|
||||
* test/stringio/test_stringio.rb (test_sysread): add a test for
|
||||
StringIO#sysread. [Fix GH-966]
|
||||
|
||||
Sat Jul 11 21:16:34 2015 ksss <co000ri@gmail.com>
|
||||
|
||||
* ext/stringio/stringio.c (Init_stringio): [DOC] Fix an example,
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue