mirror of
https://github.com/gabime/spdlog.git
synced 2024-11-15 16:35:45 +08:00
fixed tests warnings
This commit is contained in:
parent
f5bde237dd
commit
01601cef85
2
.gitignore
vendored
2
.gitignore
vendored
@ -56,3 +56,5 @@ CMakeScripts
|
|||||||
Makefile
|
Makefile
|
||||||
cmake_install.cmake
|
cmake_install.cmake
|
||||||
install_manifest.txt
|
install_manifest.txt
|
||||||
|
/tests/tests.VC.VC.opendb
|
||||||
|
/tests/tests.VC.db
|
||||||
|
@ -11,10 +11,9 @@
|
|||||||
</ProjectConfiguration>
|
</ProjectConfiguration>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="..\include\spdlog\details\format.cc">
|
<None Include="..\include\spdlog\fmt\format.cc">
|
||||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
</None>
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="example.cpp" />
|
<ClCompile Include="example.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@ -23,7 +22,6 @@
|
|||||||
<ClInclude Include="..\include\spdlog\details\async_logger_impl.h" />
|
<ClInclude Include="..\include\spdlog\details\async_logger_impl.h" />
|
||||||
<ClInclude Include="..\include\spdlog\details\async_log_helper.h" />
|
<ClInclude Include="..\include\spdlog\details\async_log_helper.h" />
|
||||||
<ClInclude Include="..\include\spdlog\details\file_helper.h" />
|
<ClInclude Include="..\include\spdlog\details\file_helper.h" />
|
||||||
<ClInclude Include="..\include\spdlog\details\format.h" />
|
|
||||||
<ClInclude Include="..\include\spdlog\details\logger_impl.h" />
|
<ClInclude Include="..\include\spdlog\details\logger_impl.h" />
|
||||||
<ClInclude Include="..\include\spdlog\details\log_msg.h" />
|
<ClInclude Include="..\include\spdlog\details\log_msg.h" />
|
||||||
<ClInclude Include="..\include\spdlog\details\mpmc_bounded_q.h" />
|
<ClInclude Include="..\include\spdlog\details\mpmc_bounded_q.h" />
|
||||||
@ -32,6 +30,7 @@
|
|||||||
<ClInclude Include="..\include\spdlog\details\pattern_formatter_impl.h" />
|
<ClInclude Include="..\include\spdlog\details\pattern_formatter_impl.h" />
|
||||||
<ClInclude Include="..\include\spdlog\details\registry.h" />
|
<ClInclude Include="..\include\spdlog\details\registry.h" />
|
||||||
<ClInclude Include="..\include\spdlog\details\spdlog_impl.h" />
|
<ClInclude Include="..\include\spdlog\details\spdlog_impl.h" />
|
||||||
|
<ClInclude Include="..\include\spdlog\fmt\format.h" />
|
||||||
<ClInclude Include="..\include\spdlog\formatter.h" />
|
<ClInclude Include="..\include\spdlog\formatter.h" />
|
||||||
<ClInclude Include="..\include\spdlog\logger.h" />
|
<ClInclude Include="..\include\spdlog\logger.h" />
|
||||||
<ClInclude Include="..\include\spdlog\sinks\android_sink.h" />
|
<ClInclude Include="..\include\spdlog\sinks\android_sink.h" />
|
||||||
|
@ -29,12 +29,12 @@ TEST_CASE("file_helper_filename", "[file_helper::filename()]]")
|
|||||||
TEST_CASE("file_helper_size", "[file_helper::size()]]")
|
TEST_CASE("file_helper_size", "[file_helper::size()]]")
|
||||||
{
|
{
|
||||||
prepare_logdir();
|
prepare_logdir();
|
||||||
auto expected_size = 123;
|
size_t expected_size = 123;
|
||||||
{
|
{
|
||||||
file_helper helper(true);
|
file_helper helper(true);
|
||||||
helper.open(target_filename);
|
helper.open(target_filename);
|
||||||
write_with_helper(helper, expected_size);
|
write_with_helper(helper, expected_size);
|
||||||
REQUIRE(helper.size() == expected_size);
|
REQUIRE(static_cast<size_t>(helper.size()) == expected_size);
|
||||||
}
|
}
|
||||||
REQUIRE(get_filesize(target_filename) == expected_size);
|
REQUIRE(get_filesize(target_filename) == expected_size);
|
||||||
}
|
}
|
||||||
|
10
tests/logs/daily_dateonly20160715.txt
Normal file
10
tests/logs/daily_dateonly20160715.txt
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
[2016-07-15 18:30:57.643] [logger] [info] Test message 0
|
||||||
|
[2016-07-15 18:30:57.643] [logger] [info] Test message 1
|
||||||
|
[2016-07-15 18:30:57.643] [logger] [info] Test message 2
|
||||||
|
[2016-07-15 18:30:57.643] [logger] [info] Test message 3
|
||||||
|
[2016-07-15 18:30:57.643] [logger] [info] Test message 4
|
||||||
|
[2016-07-15 18:30:57.643] [logger] [info] Test message 5
|
||||||
|
[2016-07-15 18:30:57.643] [logger] [info] Test message 6
|
||||||
|
[2016-07-15 18:30:57.643] [logger] [info] Test message 7
|
||||||
|
[2016-07-15 18:30:57.643] [logger] [info] Test message 8
|
||||||
|
[2016-07-15 18:30:57.643] [logger] [info] Test message 9
|
@ -1,42 +1,42 @@
|
|||||||
#include "includes.h"
|
#include "includes.h"
|
||||||
|
|
||||||
static const char *logger_name = "null_logger";
|
static const char *tested_logger_name = "null_logger";
|
||||||
|
|
||||||
TEST_CASE("register_drop", "[registry]")
|
TEST_CASE("register_drop", "[registry]")
|
||||||
{
|
{
|
||||||
spdlog::drop_all();
|
spdlog::drop_all();
|
||||||
spdlog::create<spdlog::sinks::null_sink_mt>(logger_name);
|
spdlog::create<spdlog::sinks::null_sink_mt>(tested_logger_name);
|
||||||
REQUIRE(spdlog::get(logger_name)!=nullptr);
|
REQUIRE(spdlog::get(tested_logger_name)!=nullptr);
|
||||||
//Throw if registring existing name
|
//Throw if registring existing name
|
||||||
REQUIRE_THROWS_AS(spdlog::create<spdlog::sinks::null_sink_mt>(logger_name), spdlog::spdlog_ex);
|
REQUIRE_THROWS_AS(spdlog::create<spdlog::sinks::null_sink_mt>(tested_logger_name), spdlog::spdlog_ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TEST_CASE("explicit register" "[registry]")
|
TEST_CASE("explicit register" "[registry]")
|
||||||
{
|
{
|
||||||
spdlog::drop_all();
|
spdlog::drop_all();
|
||||||
auto logger = std::make_shared<spdlog::logger>(logger_name, std::make_shared<spdlog::sinks::null_sink_st>());
|
auto logger = std::make_shared<spdlog::logger>(tested_logger_name, std::make_shared<spdlog::sinks::null_sink_st>());
|
||||||
spdlog::register_logger(logger);
|
spdlog::register_logger(logger);
|
||||||
REQUIRE(spdlog::get(logger_name) != nullptr);
|
REQUIRE(spdlog::get(tested_logger_name) != nullptr);
|
||||||
//Throw if registring existing name
|
//Throw if registring existing name
|
||||||
REQUIRE_THROWS_AS(spdlog::create<spdlog::sinks::null_sink_mt>(logger_name), spdlog::spdlog_ex);
|
REQUIRE_THROWS_AS(spdlog::create<spdlog::sinks::null_sink_mt>(tested_logger_name), spdlog::spdlog_ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("drop" "[registry]")
|
TEST_CASE("drop" "[registry]")
|
||||||
{
|
{
|
||||||
spdlog::drop_all();
|
spdlog::drop_all();
|
||||||
spdlog::create<spdlog::sinks::null_sink_mt>(logger_name);
|
spdlog::create<spdlog::sinks::null_sink_mt>(tested_logger_name);
|
||||||
spdlog::drop(logger_name);
|
spdlog::drop(tested_logger_name);
|
||||||
REQUIRE_FALSE(spdlog::get(logger_name));
|
REQUIRE_FALSE(spdlog::get(tested_logger_name));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("drop_all" "[registry]")
|
TEST_CASE("drop_all" "[registry]")
|
||||||
{
|
{
|
||||||
spdlog::drop_all();
|
spdlog::drop_all();
|
||||||
spdlog::create<spdlog::sinks::null_sink_mt>(logger_name);
|
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>("name2");
|
||||||
spdlog::drop_all();
|
spdlog::drop_all();
|
||||||
REQUIRE_FALSE(spdlog::get(logger_name));
|
REQUIRE_FALSE(spdlog::get(tested_logger_name));
|
||||||
REQUIRE_FALSE(spdlog::get("name2"));
|
REQUIRE_FALSE(spdlog::get("name2"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,10 +44,10 @@ TEST_CASE("drop_all" "[registry]")
|
|||||||
TEST_CASE("drop non existing" "[registry]")
|
TEST_CASE("drop non existing" "[registry]")
|
||||||
{
|
{
|
||||||
spdlog::drop_all();
|
spdlog::drop_all();
|
||||||
spdlog::create<spdlog::sinks::null_sink_mt>(logger_name);
|
spdlog::create<spdlog::sinks::null_sink_mt>(tested_logger_name);
|
||||||
spdlog::drop("some_name");
|
spdlog::drop("some_name");
|
||||||
REQUIRE_FALSE(spdlog::get("some_name"));
|
REQUIRE_FALSE(spdlog::get("some_name"));
|
||||||
REQUIRE(spdlog::get(logger_name));
|
REQUIRE(spdlog::get(tested_logger_name));
|
||||||
spdlog::drop_all();
|
spdlog::drop_all();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user