Tizen 2.1 base
[external/device-mapper.git] / report-generators / test / tc_log.rb
1 # Copyright (C) 2010 Red Hat, Inc. All rights reserved.
2 #
3 # This copyrighted material is made available to anyone wishing to use,
4 # modify, copy, or redistribute it subject to the terms and conditions
5 # of the GNU General Public License v.2.
6 #
7 # You should have received a copy of the GNU General Public License
8 # along with this program; if not, write to the Free Software Foundation,
9 # Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
10
11 require 'test/unit'
12 require 'stringio'
13 require 'log'
14
15 class TestLog < Test::Unit::TestCase
16   include Log
17
18   private
19   def remove_timestamps(l)
20     l.gsub(/\[[^\]]*\]/, '')
21   end
22
23   public
24   def test_log
25     StringIO.open do |out|
26       init(out)
27
28       info("msg1")
29       warning("msg2")
30       debug("msg3")
31
32       assert_equal("I,   INFO -- : msg1\nW,   WARN -- : msg2\nD,  DEBUG -- : msg3\n",
33                    remove_timestamps(out.string))
34     end
35   end
36 end