diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2016-06-10 14:18:14 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2019-08-14 11:20:57 +0900 |
commit | c8f9e9a2a0788fff08824985a74748dbe7ff7b18 (patch) | |
tree | 7f2f3391051d627e9a97297a9b5cc4a228ac3c8c /test | |
parent | 765d60315312a6a7068d9b24d7c6f38b778c4604 (diff) | |
download | ruby-c8f9e9a2a0788fff08824985a74748dbe7ff7b18.tar.gz |
[ruby/stringio] stringio: encoding support
https://github.com/ruby/stringio/commit/7b20075ab0
Diffstat (limited to 'test')
-rw-r--r-- | test/stringio/test_stringio.rb | 12 |
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 |