mirror of
https://github.com/gabime/spdlog.git
synced 2024-12-25 01:51:38 +08:00
added apply_al()l test to tests
This commit is contained in:
parent
3af247fbd3
commit
d8f01c3a72
10
tests/logs/daily_dateonly20160820.txt
Normal file
10
tests/logs/daily_dateonly20160820.txt
Normal file
@ -0,0 +1,10 @@
|
||||
[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
|
@ -1,6 +1,7 @@
|
||||
#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();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user