ifw-daq  2.1.0-pre1
IFW Data Acquisition modules
testLog4cplus.cpp
Go to the documentation of this file.
1 /**
2  * @file
3  * @ingroup daq_ocm_libdaq_test
4  * @copyright (c) Copyright ESO 2022
5  * All Rights Reserved
6  * ESO (eso.org) is an Intergovernmental Organisation, and therefore special legal conditions apply.
7  *
8  * @brief Test log4cplus helpers
9  */
10 #include <gtest/gtest.h>
11 
12 #include <daq/log4cplus.hpp>
13 #include <sstream>
14 
15 TEST(TestLogLevel, IstreamParsingOk) {
16  std::stringstream ss;
17  ss << "INFO";
18  daq::LogLevel ll;
19  ss >> ll;
20  EXPECT_EQ(ll.value, log4cplus::INFO_LOG_LEVEL) << ss.str();
21 }
22 
23 TEST(TestLogLevel, IstreamParsingFails) {
24  std::stringstream ss;
25  ss << "garbage";
26  daq::LogLevel ll;
27  EXPECT_THROW(ss >> ll, std::invalid_argument);
28 }
29 
30 TEST(TestLogLevel, OstreamFormatting) {
31  std::stringstream ss;
32  daq::LogLevel ll{log4cplus::INFO_LOG_LEVEL};
33  ss << ll;
34  EXPECT_EQ(ss.str(), "INFO");
35 }
36 
37 TEST(TestTrim, TrimsRight) {
38  std::stringstream ss;
39  ss << daq::Trim(" hello \n\t"); // keeps " hello"
40  ss << daq::Trim("\n\t "); // trimmed out completely
41  EXPECT_EQ(ss.str(), " hello");
42 }
43 
44 TEST(TestTrim, TrimsNothing) {
45  std::stringstream ss;
46  ss << daq::Trim("");
47  ss << daq::Trim("hello");
48  EXPECT_EQ(ss.str(), "hello");
49 }
log4cplus.hpp
Declaration of log4cplus helpers.
TEST
TEST(TestLogLevel, IstreamParsingOk)
Definition: testLog4cplus.cpp:15
daq::Trim
Trim string from whitespace (' ', ' ')
Definition: log4cplus.hpp:39
daq::LogLevel
ly typed log4cplus::LogLevel (which is an alias to int)
Definition: log4cplus.hpp:22