COOLFluiD  Release kernel
COOLFluiD is a Collaborative Simulation Environment (CSE) focused on complex MultiPhysics simulations.
utest-log-level-filter.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 level filter"
9 
10 #include <boost/test/unit_test.hpp>
11 
12 #include <boost/iostreams/device/back_inserter.hpp>
13 
14 #include <iostream>
15 
17 
18 using namespace std;
19 using namespace boost;
20 using namespace cf3;
21 using namespace cf3::common;
22 
24 {
27  m_buffer(),
28  m_sink(iostreams::back_inserter(m_buffer))
29  {
30  m_filter = new LogLevelFilter(INFO);
31  }
32 
34  ~LogLevelFilterFixture() { delete m_filter; }
35 
37 
40 
41  string m_buffer;
42 
43  iostreams::back_insert_device<string> m_sink;
44 };
45 
46 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
47 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
48 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
49 
50 BOOST_FIXTURE_TEST_SUITE(LogLevelFilterTestSuite,LogLevelFilterFixture)
51 
52 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
53 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
54 
55 BOOST_AUTO_TEST_CASE( setLogLevel )
56 {
58 
60 
61  BOOST_CHECK_EQUAL( (int)f.m_filter->get_filter(), (int)SILENT);
62 
63 }
64 
65 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
66 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
67 
69 {
72  string str = "Hello world!";
73 
75 
77  f.m_filter->write(f.m_sink, str.c_str(), str.length());
78  BOOST_CHECK_EQUAL(f.m_buffer, std::string(""));
79 
81  f.m_filter->write(f.m_sink, str.c_str(), str.length());
82  BOOST_CHECK_EQUAL(f.m_buffer, std::string(""));
83 
85  f.m_filter->write(f.m_sink, str.c_str(), str.length());
86  BOOST_CHECK_EQUAL(f.m_buffer, std::string(""));
87 
89  f.m_buffer.clear();
90  f.m_filter->write(f.m_sink, str.c_str(), str.length());
91  BOOST_CHECK_EQUAL(str, f.m_buffer);
92 
94  f.m_buffer.clear();
95  f.m_filter->write(f.m_sink, str.c_str(), str.length());
96  BOOST_CHECK_EQUAL(str, f.m_buffer);
97 
98  f.m_buffer.clear();
99  f.m_filter->write(f.m_sink, str.c_str(), str.length());
100  BOOST_CHECK_EQUAL(str, f.m_buffer);
101 
103  f.m_buffer.clear();
104  f.m_filter->write(f.m_sink, str.c_str(), str.length());
105  BOOST_CHECK_EQUAL(str, f.m_buffer);
106 }
107 
108 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
109 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
110 
111 BOOST_AUTO_TEST_SUITE_END()
external boost library namespace
LogLevelFilterFixture()
common setup for each test case
STL namespace.
iostreams::back_insert_device< string > m_sink
BOOST_AUTO_TEST_CASE(setLogLevel)
LogLevel get_filter() const
Gives the default log level.
void set_log_level(const Uint level)
Sets the current log level.
~LogLevelFilterFixture()
common tear-down for each test case
void set_filter(LogLevel level)
Sets the default log level.
Filters log messages corresponding to their level.
Top-level namespace for coolfluid.
Definition: Action.cpp:18
LogLevelFilter * m_filter
possibly common functions used on the tests below
std::streamsize write(Sink &sink, const char_type *data, std::streamsize size)
Forwards a message.
Most basic kernel library.
Definition: Action.cpp:19
Send comments to:
COOLFluiD Web Admin