COOLFluiD  Release kernel
COOLFluiD is a Collaborative Simulation Environment (CSE) focused on complex MultiPhysics simulations.
utest-log.cpp
Go to the documentation of this file.
1 // Copyright (C) 2010-2013 von Karman Institute for Fluid Dynamics, Belgium
2 //
3 // This software is distributed under the terms of the
4 // GNU Lesser General Public License version 3 (LGPLv3).
5 // See doc/lgpl.txt and doc/gpl.txt for the license text.
6 
7 #define BOOST_TEST_DYN_LINK
8 #define BOOST_TEST_MODULE "Test module for CF log facility"
9 
10 #include <boost/test/unit_test.hpp>
11 
12 #include <boost/iostreams/device/back_inserter.hpp>
13 
14 #include <iostream>
15 
16 #include "common/Log.hpp"
17 
18 using namespace std;
19 using namespace boost;
20 using namespace cf3;
21 using namespace cf3::common;
22 
23 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
24 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
25 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
26 
27 BOOST_AUTO_TEST_SUITE( LogTestSuite )
28 
29 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
30 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
31 
33 {
34  Logger::instance().openFiles();
35 
36  // files are not created if PE is not initializaed
37  if(common::PE::Comm::instance().is_active())
38  {
39  BOOST_CHECK(Logger::instance().getStream(INFO).isFileOpen());
40  BOOST_CHECK(Logger::instance().getStream(ERROR).isFileOpen());
41  BOOST_CHECK(Logger::instance().getStream(WARNING).isFileOpen());
42  BOOST_CHECK(Logger::instance().getStream(DEBUG).isFileOpen());
43  }
44  else
45  {
46  BOOST_CHECK(!Logger::instance().getStream(INFO).isFileOpen());
47  BOOST_CHECK(!Logger::instance().getStream(ERROR).isFileOpen());
48  BOOST_CHECK(!Logger::instance().getStream(WARNING).isFileOpen());
49  BOOST_CHECK(!Logger::instance().getStream(DEBUG).isFileOpen());
50  }
51 }
52 
54 BOOST_AUTO_TEST_CASE( FlushBuffer )
55 {
56  // Output order is not what we expect
57  CFinfo << "1. this is unflused CFlog line 1" << "\n";
58  std::cout << "2. This is flused std::cout" << std::endl;
59  CFinfo << "3. this is flushed CFlog line 2" << CFendl;
60  CFinfo << "---------------------------------" << CFendl;
61  // Output order is correct
62  CFinfo << "1. this is flused CFlog line 1" << CFendl;
63  std::cout << "2. This is flused std::cout" << std::endl;
64  CFinfo << "3. this is flushed CFlog line 2" << CFendl;
65 }
66 
67 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
68 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
69 
70 BOOST_AUTO_TEST_SUITE_END()
#define CFinfo
these are always defined
Definition: Log.hpp:104
external boost library namespace
STL namespace.
#define CFendl
Definition: Log.hpp:109
Top-level namespace for coolfluid.
Definition: Action.cpp:18
BOOST_AUTO_TEST_CASE(openFiles)
Definition: utest-log.cpp:32
Most basic kernel library.
Definition: Action.cpp:19
Send comments to:
COOLFluiD Web Admin