aboutsummaryrefslogtreecommitdiffstats
path: root/test/stringio/test_stringio.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/stringio/test_stringio.rb')
-rw-r--r--test/stringio/test_stringio.rb12
1 files changed, 11 insertions, 1 deletions
diff --git a/test/stringio/test_stringio.rb b/test/stringio/test_stringio.rb
index 873f67b3b8..1e8e5482ce 100644
--- a/test/stringio/test_stringio.rb
+++ b/test/stringio/test_stringio.rb
@@ -22,7 +22,6 @@ class TestStringIO < Test::Unit::TestCase
assert_raise(ArgumentError) { StringIO.new('', 'rx') }
assert_raise(ArgumentError) { StringIO.new('', 'rbt') }
assert_raise(TypeError) { StringIO.new(nil) }
- assert_raise(TypeError) { StringIO.new('str', nil) }
o = Object.new
def o.to_str
@@ -785,6 +784,17 @@ class TestStringIO < Test::Unit::TestCase
end;
end
+ def test_encoding_write
+ s = StringIO.new("", "w:utf-32be")
+ s.print "abc"
+ assert_equal("abc".encode("utf-32be"), s.string)
+ end
+
+ def test_encoding_read
+ s = StringIO.new("abc".encode("utf-32be"), "r:utf-8")
+ assert_equal("\0\0\0a\0\0\0b\0\0\0c", s.read)
+ end
+
def assert_string(content, encoding, str, mesg = nil)
assert_equal([content, encoding], [str, str.encoding], mesg)
end