tests small update

This commit is contained in:
gabime 2016-04-03 01:25:41 +03:00
parent e9633a5363
commit a96092ac32
2 changed files with 13 additions and 13 deletions

View File

@ -5,7 +5,7 @@
using namespace spdlog::details;
static const std::string filename = "logs/file_helper_test.txt";
static const std::string target_filename = "logs/file_helper_test.txt";
static void write_with_helper(file_helper &helper, size_t howmany)
{
@ -20,8 +20,8 @@ TEST_CASE("file_helper_filename", "[file_helper::filename()]]")
prepare_logdir();
file_helper helper(false);
helper.open(filename);
REQUIRE(helper.filename() == filename);
helper.open(target_filename);
REQUIRE(helper.filename() == target_filename);
}
@ -32,28 +32,28 @@ TEST_CASE("file_helper_size", "[file_helper::size()]]")
auto expected_size = 123;
{
file_helper helper(true);
helper.open(filename);
helper.open(target_filename);
write_with_helper(helper, expected_size);
REQUIRE(helper.size() == expected_size);
}
REQUIRE(get_filesize(filename) == expected_size);
REQUIRE(get_filesize(target_filename) == expected_size);
}
TEST_CASE("file_helper_exists", "[file_helper::file_exists()]]")
{
prepare_logdir();
REQUIRE(!file_helper::file_exists(filename));
REQUIRE(!file_helper::file_exists(target_filename));
file_helper helper(false);
helper.open(filename);
REQUIRE(file_helper::file_exists(filename));
helper.open(target_filename);
REQUIRE(file_helper::file_exists(target_filename));
}
TEST_CASE("file_helper_reopen", "[file_helper::reopen()]]")
{
prepare_logdir();
file_helper helper(true);
helper.open(filename);
helper.open(target_filename);
write_with_helper(helper, 12);
REQUIRE(helper.size() == 12);
helper.reopen(true);
@ -65,7 +65,7 @@ TEST_CASE("file_helper_reopen2", "[file_helper::reopen(false)]]")
prepare_logdir();
auto expected_size = 14;
file_helper helper(true);
helper.open(filename);
helper.open(target_filename);
write_with_helper(helper, expected_size);
REQUIRE(helper.size() == expected_size);
helper.reopen(false);

View File

@ -4,10 +4,11 @@ void prepare_logdir()
{
spdlog::drop_all();
#ifdef _WIN32
system("del /F /Q logs\\*");
auto rv = system("del /F /Q logs\\*");
#else
system("rm -f logs/*");
auto rv = system("rm -f logs/*");
#endif
(void)rv;
}
@ -42,4 +43,3 @@ std::size_t get_filesize(const std::string& filename)
return ifs.tellg();
}