[前][次][番号順一覧][スレッド一覧]

ruby-changes:39138

From: nobu <ko1@a...>
Date: Sun, 12 Jul 2015 06:43:14 +0900 (JST)
Subject: [ruby-changes:39138] nobu:r51219 (trunk): Simple testing for StringIO#sysread

nobu	2015-07-12 06:42:27 +0900 (Sun, 12 Jul 2015)

  New Revision: 51219

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=51219

  Log:
    Simple testing for StringIO#sysread
    
    * test/stringio/test_stringio.rb (test_sysread): add a test for
      StringIO#sysread.  [Fix GH-966]

  Modified files:
    trunk/ChangeLog
    trunk/test/stringio/test_stringio.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 51218)
+++ ChangeLog	(revision 51219)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sun Jul 12 06:42:23 2015  ksss  <co000ri@g...>
+
+	* 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@g...>
 
 	* ext/stringio/stringio.c (Init_stringio): [DOC] Fix an example,
Index: test/stringio/test_stringio.rb
===================================================================
--- test/stringio/test_stringio.rb	(revision 51218)
+++ test/stringio/test_stringio.rb	(revision 51219)
@@ -470,6 +470,7 @@ class TestStringIO < Test::Unit::TestCas https://github.com/ruby/ruby/blob/trunk/test/stringio/test_stringio.rb#L470
     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::TestCas https://github.com/ruby/ruby/blob/trunk/test/stringio/test_stringio.rb#L526
     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)

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]