summaryrefslogtreecommitdiff
path: root/test/stringio
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-05-12 03:37:58 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-05-12 03:37:58 +0000
commit10fc0eb781b3d551740056ba2ea966bc93a1f1a2 (patch)
treedb801f6e70ec02d119332f4e62b20be9d447481d /test/stringio
parentbdfe8eab49040a2221083fac223ee7302724b750 (diff)
add tests for [ruby-dev:34591].
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16378 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/stringio')
-rw-r--r--test/stringio/test_stringio.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/test/stringio/test_stringio.rb b/test/stringio/test_stringio.rb
index f0031a5..5f8067e 100644
--- a/test/stringio/test_stringio.rb
+++ b/test/stringio/test_stringio.rb
@@ -40,4 +40,29 @@ class TestStringIO < Test::Unit::TestCase
end
assert_equal("hacker\nother ruby\n", stringio.string, "[ruby-core:3836]")
end
+
+ def test_gets
+ assert_equal(nil, StringIO.new("").gets)
+ assert_equal("\n", StringIO.new("\n").gets)
+ assert_equal("a\n", StringIO.new("a\n").gets)
+ assert_equal("a\n", StringIO.new("a\nb\n").gets)
+ assert_equal("a", StringIO.new("a").gets)
+ assert_equal("a\n", StringIO.new("a\nb").gets)
+ assert_equal("abc\n", StringIO.new("abc\n\ndef\n").gets)
+ assert_equal("abc\n\ndef\n", StringIO.new("abc\n\ndef\n").gets(nil))
+ assert_equal("abc\n\n", StringIO.new("abc\n\ndef\n").gets(""))
+ end
+
+ def test_readlines
+ assert_equal([], StringIO.new("").readlines)
+ assert_equal(["\n"], StringIO.new("\n").readlines)
+ assert_equal(["a\n"], StringIO.new("a\n").readlines)
+ assert_equal(["a\n", "b\n"], StringIO.new("a\nb\n").readlines)
+ assert_equal(["a"], StringIO.new("a").readlines)
+ assert_equal(["a\n", "b"], StringIO.new("a\nb").readlines)
+ assert_equal(["abc\n", "\n", "def\n"], StringIO.new("abc\n\ndef\n").readlines)
+ assert_equal(["abc\n\ndef\n"], StringIO.new("abc\n\ndef\n").readlines(nil), "[ruby-dev:34591]")
+ assert_equal(["abc\n\n", "def\n"], StringIO.new("abc\n\ndef\n").readlines(""))
+ end
+
end