Commit dea6a7c2 authored by gabime's avatar gabime

Tests: Fixed some clang-tidy warnings

parent 887a104d
......@@ -83,7 +83,9 @@ TEST_CASE("async_error_handler", "[errors]]")
logger->set_error_handler([=](const std::string &) {
std::ofstream ofs("logs/custom_err.txt");
if (!ofs)
{
throw std::runtime_error("Failed open logs/custom_err.txt");
}
ofs << err_msg;
});
logger->info("Good message #1");
......
......@@ -62,7 +62,9 @@ TEST_CASE("rotating_file_logger2", "[rotating_logger]]")
std::string basename = "logs/rotating_log";
auto logger = spdlog::rotating_logger_mt("logger", basename, max_size, 1);
for (int i = 0; i < 10; ++i)
{
logger->info("Test message {}", i);
}
logger->flush();
auto filename = basename;
......
......@@ -20,9 +20,6 @@ TEST_CASE("custom eol", "[pattern_formatter]")
{
std::string msg = "Hello custom eol test";
std::string eol = ";)";
// auto formatter = std::make_shared<spdlog::pattern_formatter>("%v", spdlog::pattern_time_type::local, ";)");
std::unique_ptr<spdlog::formatter>(new spdlog::pattern_formatter("%v", spdlog::pattern_time_type::local, ";)"));
REQUIRE(log_to_str(msg, "%v", spdlog::pattern_time_type::local, ";)") == msg + eol);
}
......
......@@ -8,8 +8,15 @@ void prepare_logdir()
system("del /F /Q logs\\*");
#else
auto rv = system("mkdir -p logs");
if(rv != 0)
{
throw std::runtime_error("Failed to mkdir -p logs");
}
rv = system("rm -f logs/*");
(void)rv;
if(rv != 0)
{
throw std::runtime_error("Failed to rm -f logs/*");
}
#endif
}
......@@ -17,7 +24,9 @@ std::string file_contents(const std::string &filename)
{
std::ifstream ifs(filename);
if (!ifs)
{
throw std::runtime_error("Failed open file ");
}
return std::string((std::istreambuf_iterator<char>(ifs)), (std::istreambuf_iterator<char>()));
}
......@@ -25,7 +34,9 @@ std::size_t count_lines(const std::string &filename)
{
std::ifstream ifs(filename);
if (!ifs)
{
throw std::runtime_error("Failed open file ");
}
std::string line;
size_t counter = 0;
......@@ -38,7 +49,9 @@ std::size_t get_filesize(const std::string &filename)
{
std::ifstream ifs(filename, std::ifstream::ate | std::ifstream::binary);
if (!ifs)
{
throw std::runtime_error("Failed open file ");
}
return static_cast<std::size_t>(ifs.tellg());
}
......@@ -47,6 +60,9 @@ std::size_t get_filesize(const std::string &filename)
bool ends_with(std::string const &value, std::string const &ending)
{
if (ending.size() > value.size())
{
return false;
}
return std::equal(ending.rbegin(), ending.rend(), value.rbegin());
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment