mirror of
https://github.com/gabime/spdlog.git
synced 2024-11-15 08:25:43 +08:00
Fixed cfg tests
This commit is contained in:
parent
0243882238
commit
284e6a80ac
@ -6,11 +6,12 @@
|
||||
|
||||
using spdlog::cfg::load_argv;
|
||||
using spdlog::cfg::load_env;
|
||||
using spdlog::sinks::test_sink_st;
|
||||
|
||||
TEST_CASE("env", "[cfg]")
|
||||
{
|
||||
spdlog::drop("l1");
|
||||
auto l1 = spdlog::create<spdlog::sinks::test_sink_st>("l1");
|
||||
auto l1 = spdlog::create<test_sink_st>("l1");
|
||||
#ifdef _MSC_VER
|
||||
_putenv_s("SPDLOG_LEVEL", "l1=warn");
|
||||
#else
|
||||
@ -18,6 +19,7 @@ TEST_CASE("env", "[cfg]")
|
||||
#endif
|
||||
load_env();
|
||||
REQUIRE(l1->level() == spdlog::level::warn);
|
||||
spdlog::set_default_logger(spdlog::create<test_sink_st>("cfg-default"));
|
||||
REQUIRE(spdlog::default_logger()->level() == spdlog::level::info);
|
||||
}
|
||||
|
||||
@ -36,9 +38,10 @@ TEST_CASE("argv2", "[cfg]")
|
||||
spdlog::drop("l1");
|
||||
const char *argv[] = {"ignore", "SPDLOG_LEVEL=l1=warn,trace"};
|
||||
load_argv(2, const_cast<char**>(argv));
|
||||
auto l1 = spdlog::create<spdlog::sinks::test_sink_st>("l1");
|
||||
auto l1 = spdlog::create<test_sink_st>("l1");
|
||||
REQUIRE(l1->level() == spdlog::level::warn);
|
||||
REQUIRE(spdlog::default_logger()->level() == spdlog::level::trace);
|
||||
spdlog::set_level(spdlog::level::info);
|
||||
}
|
||||
|
||||
TEST_CASE("argv3", "[cfg]")
|
||||
@ -46,7 +49,7 @@ TEST_CASE("argv3", "[cfg]")
|
||||
spdlog::drop("l1");
|
||||
const char *argv[] = {"ignore", "SPDLOG_LEVEL="};
|
||||
load_argv(2, const_cast<char**>(argv));
|
||||
auto l1 = spdlog::create<spdlog::sinks::test_sink_st>("l1");
|
||||
auto l1 = spdlog::create<test_sink_st>("l1");
|
||||
REQUIRE(l1->level() == spdlog::level::info);
|
||||
REQUIRE(spdlog::default_logger()->level() == spdlog::level::info);
|
||||
}
|
||||
@ -56,7 +59,7 @@ TEST_CASE("argv4", "[cfg]")
|
||||
spdlog::drop("l1");
|
||||
const char *argv[] = {"ignore", "SPDLOG_LEVEL=junk"};
|
||||
load_argv(2, const_cast<char**>(argv));
|
||||
auto l1 = spdlog::create<spdlog::sinks::test_sink_st>("l1");
|
||||
auto l1 = spdlog::create<test_sink_st>("l1");
|
||||
REQUIRE(l1->level() == spdlog::level::info);
|
||||
}
|
||||
|
||||
@ -65,9 +68,10 @@ TEST_CASE("argv5", "[cfg]")
|
||||
spdlog::drop("l1");
|
||||
const char *argv[] = {"ignore", "ignore", "SPDLOG_LEVEL=l1=warn,trace"};
|
||||
load_argv(3, const_cast<char**>(argv));
|
||||
auto l1 = spdlog::create<spdlog::sinks::test_sink_st>("l1");
|
||||
auto l1 = spdlog::create<test_sink_st>("l1");
|
||||
REQUIRE(l1->level() == spdlog::level::warn);
|
||||
REQUIRE(spdlog::default_logger()->level() == spdlog::level::trace);
|
||||
spdlog::set_level(spdlog::level::info);
|
||||
}
|
||||
|
||||
TEST_CASE("argv6", "[cfg]")
|
||||
@ -76,7 +80,7 @@ TEST_CASE("argv6", "[cfg]")
|
||||
const char *argv[] = {""};
|
||||
load_argv(1, const_cast<char**>(argv));
|
||||
REQUIRE(spdlog::default_logger()->level() == spdlog::level::err);
|
||||
|
||||
spdlog::set_level(spdlog::level::info);
|
||||
}
|
||||
|
||||
TEST_CASE("argv7", "[cfg]")
|
||||
@ -85,4 +89,5 @@ TEST_CASE("argv7", "[cfg]")
|
||||
const char *argv[] = {""};
|
||||
load_argv(0, const_cast<char**>(argv));
|
||||
REQUIRE(spdlog::default_logger()->level() == spdlog::level::err);
|
||||
spdlog::set_level(spdlog::level::info);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user