add some tests on conversion for pipe.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14560 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
0fbe6b5da1
commit
888a89153a
@ -1,5 +1,6 @@
|
|||||||
require 'test/unit'
|
require 'test/unit'
|
||||||
require 'tmpdir'
|
require 'tmpdir'
|
||||||
|
require 'timeout'
|
||||||
|
|
||||||
class TestIO_M17N < Test::Unit::TestCase
|
class TestIO_M17N < Test::Unit::TestCase
|
||||||
ENCS = [
|
ENCS = [
|
||||||
@ -65,6 +66,39 @@ EOT
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_pipe_terminator_conversion
|
||||||
|
with_pipe("euc-jp:utf-8") {|r, w|
|
||||||
|
w.write "before \xa2\xa2 after"
|
||||||
|
rs = "\xA2\xA2".encode("utf-8", "euc-jp")
|
||||||
|
timeout(1) {
|
||||||
|
assert_equal("before \xa2\xa2".encode("utf-8", "euc-jp"),
|
||||||
|
r.gets(rs))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_pipe_conversion
|
||||||
|
with_pipe("euc-jp:utf-8") {|r, w|
|
||||||
|
w.write "\xa1\xa1"
|
||||||
|
assert_equal("\xa1\xa1".encode("utf-8", "euc-jp"), r.getc)
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_pipe_convert_partial_read
|
||||||
|
with_pipe("euc-jp:utf-8") {|r, w|
|
||||||
|
begin
|
||||||
|
t = Thread.new {
|
||||||
|
w.write "\xa1"
|
||||||
|
sleep 0.1
|
||||||
|
w.write "\xa1"
|
||||||
|
}
|
||||||
|
assert_equal("\xa1\xa1".encode("utf-8", "euc-jp"), r.getc)
|
||||||
|
ensure
|
||||||
|
t.join if t
|
||||||
|
end
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
def test_open_ascii
|
def test_open_ascii
|
||||||
with_tmpdir {
|
with_tmpdir {
|
||||||
src = "abc\n"
|
src = "abc\n"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user