diff options
| author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-12-23 18:22:59 +0000 |
|---|---|---|
| committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-12-23 18:22:59 +0000 |
| commit | 2ecedd3c38f3f255936c5e6240147f65b24b832a (patch) | |
| tree | 2f89d0641f0922fd6d5cf8c2960583575bc72db0 /test/ruby | |
| parent | 8f2b78857231e1c4d41adf9b687a1df376c5626d (diff) | |
| download | ruby-2ecedd3c38f3f255936c5e6240147f65b24b832a.tar.gz ruby-2ecedd3c38f3f255936c5e6240147f65b24b832a.tar.xz ruby-2ecedd3c38f3f255936c5e6240147f65b24b832a.zip | |
add tests.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@14545 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby')
| -rw-r--r-- | test/ruby/test_io_m17n.rb | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/test/ruby/test_io_m17n.rb b/test/ruby/test_io_m17n.rb index 7e3dc2be9..ce35b4d21 100644 --- a/test/ruby/test_io_m17n.rb +++ b/test/ruby/test_io_m17n.rb @@ -54,6 +54,17 @@ EOT } end + def test_terminator_conversion2 + with_tmpdir { + generate_file('tmp', "before \xA1\xA2\xA2\xA3 after") + s = open("tmp", "r:euc-jp:utf-8") {|f| + f.gets("\xA2\xA2".force_encoding("euc-jp").encode("utf-8")) + } + assert_equal(Encoding.find("euc-jp"), s.encoding) + assert_str_equal("before \xA1\xA2\xA2\xA3 after".force_encoding("iso-8859-1"), s) + } + end + def test_open_ascii with_tmpdir { src = "abc\n" @@ -175,6 +186,37 @@ EOT end def test_pipe + utf8 = "\u6666" + eucjp = "\xb3\xa2".force_encoding("EUC-JP") + + with_pipe {|r,w| + assert_equal(Encoding.default_external, r.external_encoding) + assert_equal(nil, r.internal_encoding) + w << utf8 + w.close + s = r.read + assert_equal(Encoding.default_external, s.encoding) + puts encdump(s) + puts encdump(utf8) + assert_str_equal(utf8, s) + } + + with_pipe("EUC-JP") {|r,w| + assert_equal(Encoding::EUC_JP, r.external_encoding) + assert_equal(nil, r.internal_encoding) + w << eucjp + w.close + assert_equal(eucjp, r.read) + } + + with_pipe("UTF-8:EUC-JP") {|r,w| + assert_equal(Encoding::UTF_8, r.external_encoding) + assert_equal(Encoding::EUC_JP, r.internal_encoding) + w << utf8 + w.close + assert_equal(eucjp, r.read) + } + ENCS.each {|enc| with_pipe(enc) {|r, w| w << "\xc2\xa1" |
