diff options
author | nahi <nahi@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-06-11 14:07:42 +0000 |
---|---|---|
committer | nahi <nahi@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-06-11 14:07:42 +0000 |
commit | 47f89c982ccd616245d8c4f15d0d0d5067773ef7 (patch) | |
tree | 1fc550d00181fc6345b5388f576455d373c9dd67 /test/openssl | |
parent | 35c16fe35fd7420ce7d0cd4059a02650ad8d4eb2 (diff) | |
download | ruby-47f89c982ccd616245d8c4f15d0d0d5067773ef7.tar.gz |
* ext/openssl/lib/openssl/buffering.rb (module OpenSSL):
Buffering#each_byte should return String in accordance with IO in
1.9.
* test/openssl/test_buffering.rb (class OpenSSL): add tests for getc
and each_byte.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32012 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/openssl')
-rw-r--r-- | test/openssl/test_buffering.rb | 35 |
1 files changed, 29 insertions, 6 deletions
diff --git a/test/openssl/test_buffering.rb b/test/openssl/test_buffering.rb index 49335de8d2..25e0b66232 100644 --- a/test/openssl/test_buffering.rb +++ b/test/openssl/test_buffering.rb @@ -10,7 +10,10 @@ class OpenSSL::TestBuffering < MiniTest::Unit::TestCase attr_accessor :sync def initialize - @io = StringIO.new + @io = "" + def @io.sync + true + end super @@ -18,15 +21,18 @@ class OpenSSL::TestBuffering < MiniTest::Unit::TestCase end def string - @io.string + @io end - def sysread *a - @io.sysread *a + def sysread(size) + str = @io.slice!(0, size) + raise EOFError if str.empty? + str end - def syswrite *a - @io.syswrite *a + def syswrite(str) + @io << str + str.size end end @@ -63,4 +69,21 @@ class OpenSSL::TestBuffering < MiniTest::Unit::TestCase refute @io.sync, 'sync must not change' end + def test_getc + @io.syswrite('abc') + res = [] + assert_equal(?a, @io.getc) + assert_equal(?b, @io.getc) + assert_equal(?c, @io.getc) + end + + def test_each_byte + @io.syswrite('abc') + res = [] + @io.each_byte do |c| + res << c + end + assert_equal([97, 98, 99], res) + end + end if defined?(OpenSSL) |