Fix documentation build under maverick (doxygen 1.7.1)
[senf.git] / senf / Utils / Logger / FileTarget.test.cc
1 // $Id$
2 //
3 // Copyright (C) 2009
4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 //     Thorsten Horstmann <tho@berlios.de>
7 //
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
12 //
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 // GNU General Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the
20 // Free Software Foundation, Inc.,
21 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22
23 /** \file
24     \brief FileTarget unit tests */
25
26 //#include "FileTarget.test.hh"
27 //#include "FileTarget.test.ih"
28
29 // Custom includes
30 #include <fstream>
31 #include <boost/filesystem/operations.hpp>
32 #include "FileTarget.hh"
33 #include "Logger.hh"
34
35 #include <senf/Utils/auto_unit_test.hh>
36 #include <boost/test/test_tools.hpp>
37
38 #define prefix_
39 //-/////////////////////////////////////////////////////////////////////////////////////////////////
40
41 SENF_AUTO_UNIT_TEST(fileTarget)
42 {
43     std::string filename ("/tmp/senf_fileTarget_test.log");
44     senf::log::FileTarget target (filename);
45
46     target.tag("");
47     target.showTime(false);
48     target.showLevel(false);
49     target.route();
50
51     std::string message ("Test message");
52     SENF_LOG((message));
53
54     BOOST_REQUIRE( boost::filesystem::exists(filename));
55     std::ifstream inFile;
56     inFile.open(filename.c_str());
57     BOOST_REQUIRE( inFile);
58
59     char buffer[256];
60     inFile.getline(buffer, 256);
61     inFile.close();
62     BOOST_CHECK_EQUAL( std::string(buffer), message);
63
64     SENF_CHECK_NO_THROW( boost::filesystem::remove(filename) );
65
66     target.reopen();
67     BOOST_REQUIRE( boost::filesystem::exists(filename));
68     SENF_CHECK_NO_THROW( boost::filesystem::remove(filename) );
69
70     filename = std::string("/tmp/senf_fileTarget_test2.log");
71     target.reopen( filename);
72     BOOST_REQUIRE( boost::filesystem::exists(filename));
73     SENF_CHECK_NO_THROW( boost::filesystem::remove(filename) );
74 }
75
76 //-/////////////////////////////////////////////////////////////////////////////////////////////////
77 #undef prefix_
78
79 \f
80 // Local Variables:
81 // mode: c++
82 // fill-column: 100
83 // comment-column: 40
84 // c-file-style: "senf"
85 // indent-tabs-mode: nil
86 // ispell-local-dictionary: "american"
87 // compile-command: "scons -u test"
88 // End: