diff options
author | shugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-10-17 02:50:43 +0000 |
---|---|---|
committer | shugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-10-17 02:50:43 +0000 |
commit | 5545c5aafa2204fe3b50d7c465e8fb542f338dd2 (patch) | |
tree | 50d751e8f23cd1b62120a6221afcfeba16924552 /test/socket | |
parent | 68222eb41754f5288644b5d9b07e47a17badf11e (diff) | |
download | ruby-5545c5aafa2204fe3b50d7c465e8fb542f338dd2.tar.gz |
* ext/socket/socket.c (init_sock): sockets should be binmode.
* test/socket/test_tcp.rb (test_encoding): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19816 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/socket')
-rw-r--r-- | test/socket/test_tcp.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/socket/test_tcp.rb b/test/socket/test_tcp.rb index 3aa7be82c3..c623c1b58c 100644 --- a/test/socket/test_tcp.rb +++ b/test/socket/test_tcp.rb @@ -21,4 +21,23 @@ assert false, "TODO: doesn't work on mswin32/64" if /mswin/ =~ RUBY_PLATFORM th.kill th.join end + + def test_encoding + svr = TCPServer.new("localhost", 0) + th = Thread.new { + c = svr.accept + c.write "foo\r\n" + c.close + } + addr = svr.addr + sock = TCPSocket.open(addr[2], addr[1]) + assert_equal(true, sock.binmode?) + s = sock.gets + assert_equal("foo\r\n", s) + assert_equal(Encoding.find("ASCII-8BIT"), s.encoding) + ensure + th.kill + th.join + sock.close if sock + end end if defined?(TCPSocket) |