root/lang/ruby/tee/trunk/test/test_tee.rb @ 3786

Revision 3786, 1.7 kB (checked in by shyouhei, 6 years ago)

lang/ruby/tee: import.

Line 
1#!/bin/ruby -Ku
2# Copyright(c) 2006 URABE, Shyouhei.
3#
4# Permission is hereby granted, free of  charge, to any person obtaining a copy
5# of  this code, to  deal in  the code  without restriction,  including without
6# limitation  the rights  to  use, copy,  modify,  merge, publish,  distribute,
7# sublicense, and/or sell copies of the code, and to permit persons to whom the
8# code is furnished to do so, subject to the following conditions:
9#
10#        The above copyright notice and this permission notice shall be
11#        included in all copies or substantial portions of the code.
12#
13# THE  CODE IS  PROVIDED "AS  IS",  WITHOUT WARRANTY  OF ANY  KIND, EXPRESS  OR
14# IMPLIED,  INCLUDING BUT  NOT LIMITED  TO THE  WARRANTIES  OF MERCHANTABILITY,
15# FITNESS FOR A PARTICULAR PURPOSE  AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
16# AUTHOR  OR  COPYRIGHT  HOLDER BE  LIABLE  FOR  ANY  CLAIM, DAMAGES  OR  OTHER
17# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18# OUT OF  OR IN CONNECTION WITH  THE CODE OR THE  USE OR OTHER  DEALINGS IN THE
19# CODE.
20
21require 'test/unit'
22require 'stringio'
23require 'tempfile'
24require 'tee'
25
26class TC_IO < Test::Unit::TestCase
27        def test_tee
28                io1 = open "/dev/null", "w"
29                io2 = StringIO.new
30                io1.tee io2
31                io1.write "test"
32                io1.close
33                Thread.pass
34                assert_equal "test", io2.string
35        end
36
37        def test_tee_redirection_makes_loop
38                io1 = Tempfile.new('tee')
39                io1.tee io1
40                io1.write "test"
41                io1.rewind
42                assert_equal "test", io1.read
43                io1.close
44        end
45end
46
47
48# Local Variables:
49# mode: ruby
50# coding: utf-8
51# indent-tabs-mode: t
52# tab-width: 3
53# ruby-indent-level: 3
54# fill-column: 79
55# default-justification: full
56# End:
57# vi: ts=3 sw=3
Note: See TracBrowser for help on using the browser.