summaryrefslogtreecommitdiff
path: root/tests/logger.cpp
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2015-10-31 15:41:05 +0100
committerFlorent Le Coz <louiz@louiz.org>2015-10-31 15:41:05 +0100
commit7e07a17420117758ca319b5beab6440ff1d634f7 (patch)
treeef073ec5976ec633e3ee69e57afbc17a84b24dca /tests/logger.cpp
parent6430479a3a6f15e221f0b9f3e822b44ca37af0f8 (diff)
downloadbiboumi-7e07a17420117758ca319b5beab6440ff1d634f7.tar.gz
biboumi-7e07a17420117758ca319b5beab6440ff1d634f7.tar.bz2
biboumi-7e07a17420117758ca319b5beab6440ff1d634f7.tar.xz
biboumi-7e07a17420117758ca319b5beab6440ff1d634f7.zip
Fix the logger test when built without systemd
Diffstat (limited to 'tests/logger.cpp')
-rw-r--r--tests/logger.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/tests/logger.cpp b/tests/logger.cpp
index d4fb055..2a99374 100644
--- a/tests/logger.cpp
+++ b/tests/logger.cpp
@@ -10,6 +10,13 @@ using namespace std::string_literals;
TEST_CASE("Basic logging")
{
+#ifdef SYSTEMD_FOUND
+ const std::string debug_header = "<7>";
+ const std::string error_header = "<3>";
+#else
+ const std::string debug_header = "[DEBUG]: ";
+ const std::string error_header = "[ERROR]: ";
+#endif
Logger::instance().reset();
GIVEN("A logger with log_level 0")
{
@@ -19,14 +26,14 @@ TEST_CASE("Basic logging")
IoTester<std::ostream> out(std::cout);
log_debug("debug");
THEN("debug logs are written")
- CHECK(out.str() == "<7>tests/logger.cpp:" + std::to_string(__LINE__ - 2) + ":\tdebug\n");
+ CHECK(out.str() == debug_header + "tests/logger.cpp:" + std::to_string(__LINE__ - 2) + ":\tdebug\n");
}
WHEN("we log some errors")
{
IoTester<std::ostream> out(std::cout);
log_error("error");
THEN("error logs are written")
- CHECK(out.str() == "<3>tests/logger.cpp:" + std::to_string(__LINE__ - 2) + ":\terror\n");
+ CHECK(out.str() == error_header + "tests/logger.cpp:" + std::to_string(__LINE__ - 2) + ":\terror\n");
}
}
GIVEN("A logger with log_level 3")
@@ -44,7 +51,7 @@ TEST_CASE("Basic logging")
IoTester<std::ostream> out(std::cout);
log_error("error");
THEN("error logs are still written")
- CHECK(out.str() == "<3>tests/logger.cpp:" + std::to_string(__LINE__ - 2) + ":\terror\n");
+ CHECK(out.str() == error_header + "tests/logger.cpp:" + std::to_string(__LINE__ - 2) + ":\terror\n");
}
}
}