4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 // Thorsten Horstmann <tho@berlios.de>
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.
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.
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.
24 \brief FileTarget unit tests */
26 //#include "FileTarget.test.hh"
27 //#include "FileTarget.test.ih"
31 #include <boost/filesystem/operations.hpp>
32 #include "FileTarget.hh"
35 #include "../auto_unit_test.hh"
36 #include <boost/test/test_tools.hpp>
39 ///////////////////////////////cc.p////////////////////////////////////////
41 BOOST_AUTO_UNIT_TEST(fileTarget)
43 std::string filename ("/tmp/senf_fileTarget_test.log");
44 senf::log::FileTarget target (filename);
47 target.showTime(false);
48 target.showLevel(false);
51 std::string message ("Test message");
54 BOOST_REQUIRE( boost::filesystem::exists(filename));
56 inFile.open(filename.c_str());
57 BOOST_REQUIRE( inFile);
60 inFile.getline(buffer, 256);
62 BOOST_CHECK_EQUAL( std::string(buffer), message);
64 SENF_CHECK_NO_THROW( boost::filesystem::remove(filename) );
67 BOOST_REQUIRE( boost::filesystem::exists(filename));
68 SENF_CHECK_NO_THROW( boost::filesystem::remove(filename) );
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) );
76 ///////////////////////////////cc.e////////////////////////////////////////
84 // c-file-style: "senf"
85 // indent-tabs-mode: nil
86 // ispell-local-dictionary: "american"
87 // compile-command: "scons -u test"