ifw-daq 3.1.0
IFW Data Acquisition modules
Loading...
Searching...
No Matches
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
15TEST(TestLogLevel, IstreamParsingOk) {
16 std::stringstream ss;
17 ss << "INFO";
19 ss >> ll;
20 EXPECT_EQ(ll.value, log4cplus::INFO_LOG_LEVEL) << ss.str();
21}
22
23TEST(TestLogLevel, IstreamParsingFails) {
24 std::stringstream ss;
25 ss << "garbage";
27 EXPECT_THROW(ss >> ll, std::invalid_argument);
28}
29
30TEST(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
37TEST(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
44TEST(TestTrim, TrimsNothing) {
45 std::stringstream ss;
46 ss << daq::Trim("");
47 ss << daq::Trim("hello");
48 EXPECT_EQ(ss.str(), "hello");
49}
Trim string from whitespace (' ', ' ')
Definition: log4cplus.hpp:40
Declaration of log4cplus helpers.
log4cplus::LogLevel value
Definition: log4cplus.hpp:24
ly typed log4cplus::LogLevel (which is an alias to int)
Definition: log4cplus.hpp:23
TEST(TestLogLevel, IstreamParsingOk)
EXPECT_EQ(meta.rr_uri, "zpb.rr://meta")