2003-12-04 21:54:48 -05:00
|
|
|
require 'test/unit'
|
2008-02-18 03:09:05 -05:00
|
|
|
require_relative 'ut_eof'
|
2003-12-04 21:54:48 -05:00
|
|
|
|
|
|
|
class TestPipe < Test::Unit::TestCase
|
|
|
|
include TestEOF
|
|
|
|
def open_file(content)
|
2003-12-04 23:18:37 -05:00
|
|
|
r, w = IO.pipe
|
|
|
|
w << content
|
|
|
|
w.close
|
|
|
|
begin
|
|
|
|
yield r
|
|
|
|
ensure
|
|
|
|
r.close
|
|
|
|
end
|
2003-12-04 21:54:48 -05:00
|
|
|
end
|
2014-06-06 23:51:57 -04:00
|
|
|
class WithConversion < self
|
|
|
|
def open_file(content)
|
|
|
|
r, w = IO.pipe
|
|
|
|
w << content
|
|
|
|
w.close
|
|
|
|
r.set_encoding("us-ascii:utf-8")
|
|
|
|
begin
|
|
|
|
yield r
|
|
|
|
ensure
|
|
|
|
r.close
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2003-12-04 21:54:48 -05:00
|
|
|
end
|