mirror of
https://github.com/gabime/spdlog.git
synced 2025-09-30 02:19:35 +08:00
tests refactoring
This commit is contained in:
@@ -3,39 +3,6 @@
|
||||
*/
|
||||
#include "includes.h"
|
||||
|
||||
static 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>()));
|
||||
|
||||
}
|
||||
|
||||
static 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;
|
||||
while(std::getline(ifs, line))
|
||||
counter++;
|
||||
return counter;
|
||||
}
|
||||
|
||||
std::ifstream::pos_type 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 ifs.tellg();
|
||||
}
|
||||
|
||||
|
||||
|
||||
TEST_CASE("simple_file_logger", "[simple_logger]]")
|
||||
{
|
||||
|
Reference in New Issue
Block a user