diff --git a/tests/logs/daily_dateonly20160820.txt b/tests/logs/daily_dateonly20160820.txt new file mode 100644 index 00000000..45a997ed --- /dev/null +++ b/tests/logs/daily_dateonly20160820.txt @@ -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 diff --git a/tests/registry.cpp b/tests/registry.cpp index a0cc04bb..cde61edb 100644 --- a/tests/registry.cpp +++ b/tests/registry.cpp @@ -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(tested_logger_name), spdlog::spdlog_ex); } +TEST_CASE("apply_all" "[registry]") +{ + spdlog::drop_all(); + auto logger = std::make_shared(tested_logger_name, std::make_shared()); + spdlog::register_logger(logger); + auto logger2 = std::make_shared(tested_logger_name2, std::make_shared()); + spdlog::register_logger(logger2); + + int counter = 0; + spdlog::apply_all([&counter](std::shared_ptr l){counter++;}); + REQUIRE(counter == 2); + + counter = 0; + spdlog::drop(tested_logger_name2); + spdlog::apply_all([&counter](std::shared_ptr 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(tested_logger_name); - spdlog::create("name2"); + spdlog::create(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(); } + +