Commit d8f01c3a authored by gabime's avatar gabime

added apply_al()l test to tests

parent 3af247fb
[2016-08-20 13:50:56.499] [logger] [info] Test message 0
[2016-08-20 13:50:56.499] [logger] [info] Test message 1
[2016-08-20 13:50:56.499] [logger] [info] Test message 2
[2016-08-20 13:50:56.499] [logger] [info] Test message 3
[2016-08-20 13:50:56.499] [logger] [info] Test message 4
[2016-08-20 13:50:56.499] [logger] [info] Test message 5
[2016-08-20 13:50:56.500] [logger] [info] Test message 6
[2016-08-20 13:50:56.500] [logger] [info] Test message 7
[2016-08-20 13:50:56.500] [logger] [info] Test message 8
[2016-08-20 13:50:56.500] [logger] [info] Test message 9
#include "includes.h"
static const char *tested_logger_name = "null_logger";
static const char *tested_logger_name2 = "null_logger2";
TEST_CASE("register_drop", "[registry]")
{
......@@ -22,6 +23,30 @@ TEST_CASE("explicit register" "[registry]")
REQUIRE_THROWS_AS(spdlog::create<spdlog::sinks::null_sink_mt>(tested_logger_name), spdlog::spdlog_ex);
}
TEST_CASE("apply_all" "[registry]")
{
spdlog::drop_all();
auto logger = std::make_shared<spdlog::logger>(tested_logger_name, std::make_shared<spdlog::sinks::null_sink_st>());
spdlog::register_logger(logger);
auto logger2 = std::make_shared<spdlog::logger>(tested_logger_name2, std::make_shared<spdlog::sinks::null_sink_st>());
spdlog::register_logger(logger2);
int counter = 0;
spdlog::apply_all([&counter](std::shared_ptr<spdlog::logger> l){counter++;});
REQUIRE(counter == 2);
counter = 0;
spdlog::drop(tested_logger_name2);
spdlog::apply_all([&counter](std::shared_ptr<spdlog::logger> l)
{
REQUIRE(l->name() == tested_logger_name);
counter++; }
);
REQUIRE(counter == 1);
}
TEST_CASE("drop" "[registry]")
{
spdlog::drop_all();
......@@ -34,10 +59,10 @@ TEST_CASE("drop_all" "[registry]")
{
spdlog::drop_all();
spdlog::create<spdlog::sinks::null_sink_mt>(tested_logger_name);
spdlog::create<spdlog::sinks::null_sink_mt>("name2");
spdlog::create<spdlog::sinks::null_sink_mt>(tested_logger_name2);
spdlog::drop_all();
REQUIRE_FALSE(spdlog::get(tested_logger_name));
REQUIRE_FALSE(spdlog::get("name2"));
REQUIRE_FALSE(spdlog::get(tested_logger_name));
}
......@@ -51,3 +76,5 @@ TEST_CASE("drop non existing" "[registry]")
spdlog::drop_all();
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment