diff options
Diffstat (limited to 'test/socket')
-rw-r--r-- | test/socket/test_basicsocket.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/test/socket/test_basicsocket.rb b/test/socket/test_basicsocket.rb index 0671e97c75..d388b4f0dd 100644 --- a/test/socket/test_basicsocket.rb +++ b/test/socket/test_basicsocket.rb @@ -205,4 +205,25 @@ class TestSocket_BasicSocket < Test::Unit::TestCase assert_not_predicate(ssock, :nonblock?) unless set_nb end end + + def test_read_nonblock_mix_buffered + socks do |sserv, ssock, csock| + ssock.write("hello\nworld\n") + assert_equal "hello\n", csock.gets + IO.select([csock], nil, nil, 10) or + flunk 'socket did not become readable' + assert_equal "world\n", csock.read_nonblock(8) + end + end + + def test_write_nonblock_buffered + socks do |sserv, ssock, csock| + ssock.sync = false + ssock.write("h") + assert_equal :wait_readable, csock.read_nonblock(1, exception: false) + assert_equal 4, ssock.write_nonblock("ello") + ssock.close + assert_equal "hello", csock.read(5) + end + end end if defined?(BasicSocket) |