From 32b6f1619fdf16b875fa34f2f20386c822c4e3df Mon Sep 17 00:00:00 2001 From: gabime Date: Fri, 25 Sep 2020 14:44:01 +0300 Subject: [PATCH] Added tests for issue #1680 --- tests/test_cfg.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/test_cfg.cpp b/tests/test_cfg.cpp index 436036d3..2e86210e 100644 --- a/tests/test_cfg.cpp +++ b/tests/test_cfg.cpp @@ -91,3 +91,28 @@ TEST_CASE("argv7", "[cfg]") REQUIRE(spdlog::default_logger()->level() == spdlog::level::err); spdlog::set_level(spdlog::level::info); } + +TEST_CASE("level-not-found-test1", "[cfg]") +{ + spdlog::drop("l1"); + const char *argv[] = {"ignore", ""}; + load_argv_levels(2, argv); + auto l1 = spdlog::create("l1"); + l1->set_level(spdlog::level::trace); + REQUIRE(l1->level() == spdlog::level::trace); + REQUIRE(spdlog::default_logger()->level() == spdlog::level::info); +} + +TEST_CASE("level-not-found-test2", "[cfg]") +{ + spdlog::drop("l1"); + const char *argv[] = {"ignore", "SPDLOG_LEVEL=l1=trace"}; + load_argv_levels(2, argv); + + auto l1 = spdlog::create("l1"); + auto l2 = spdlog::create("l2"); + + REQUIRE(l1->level() == spdlog::level::trace); + REQUIRE(l2->level() == spdlog::level::info); + REQUIRE(spdlog::default_logger()->level() == spdlog::level::info); +}