summaryrefslogtreecommitdiff
path: root/test/net/ftp
diff options
context:
space:
mode:
authorshugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-06-17 07:44:53 +0000
committershugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-06-17 07:44:53 +0000
commit6479e0b04fd685d0ebe8dd4b198ffec6ad6baa1c (patch)
tree71755f4fd0fcac16161e3e7a2be22210c5ab7456 /test/net/ftp
parentd689dca633e979bb888a6a287a07e0084a0f5187 (diff)
* lib/net/ftp.rb (gets, readline): read lines without LF properly.
[ruby-core:63205] [Bug #9949] * test/net/ftp/test_buffered_socket.rb: related test. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46457 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/net/ftp')
-rw-r--r--test/net/ftp/test_buffered_socket.rb40
1 files changed, 40 insertions, 0 deletions
diff --git a/test/net/ftp/test_buffered_socket.rb b/test/net/ftp/test_buffered_socket.rb
new file mode 100644
index 0000000..f9eefcd
--- /dev/null
+++ b/test/net/ftp/test_buffered_socket.rb
@@ -0,0 +1,40 @@
+require "net/ftp"
+require "test/unit"
+require "ostruct"
+require "stringio"
+
+class FTPTest < Test::Unit::TestCase
+ def test_gets_empty
+ sock = create_buffered_socket("")
+ assert_equal(nil, sock.gets)
+ end
+
+ def test_gets_one_line
+ sock = create_buffered_socket("foo\n")
+ assert_equal("foo\n", sock.gets)
+ end
+
+ def test_gets_one_line_without_term
+ sock = create_buffered_socket("foo")
+ assert_equal("foo", sock.gets)
+ end
+
+ def test_gets_two_lines
+ sock = create_buffered_socket("foo\nbar\n")
+ assert_equal("foo\n", sock.gets)
+ assert_equal("bar\n", sock.gets)
+ end
+
+ def test_gets_two_lines_without_term
+ sock = create_buffered_socket("foo\nbar")
+ assert_equal("foo\n", sock.gets)
+ assert_equal("bar", sock.gets)
+ end
+
+ private
+
+ def create_buffered_socket(s)
+ io = StringIO.new(s)
+ return Net::FTP::BufferedSocket.new(io)
+ end
+end