mirror of
https://github.com/gabime/spdlog.git
synced 2025-09-28 17:19:34 +08:00
auto create log dir
This commit is contained in:
27
tests/test_create_dir.cpp
Normal file
27
tests/test_create_dir.cpp
Normal file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* This content is released under the MIT License as specified in https://raw.githubusercontent.com/gabime/spdlog/master/LICENSE
|
||||
*/
|
||||
#include "includes.h"
|
||||
|
||||
using spdlog::details::os::create_dir;
|
||||
using spdlog::details::os::file_exists;
|
||||
|
||||
void test_create_dir(const char *path, const char *normalized_path)
|
||||
{
|
||||
auto rv = create_dir(path);
|
||||
REQUIRE(rv == true);
|
||||
REQUIRE(file_exists(normalized_path));
|
||||
}
|
||||
|
||||
#include "spdlog/sinks/stdout_color_sinks.h"
|
||||
|
||||
TEST_CASE("create_dir", "[create_dir]")
|
||||
{
|
||||
prepare_logdir();
|
||||
test_create_dir("test_logs/dir1/dir1", "test_logs/dir1/dir1");
|
||||
test_create_dir("test_logs/dir1///dir2", "test_logs/dir1/dir2");
|
||||
test_create_dir("./test_logs/dir1/dir3", "test_logs/dir1/dir3");
|
||||
test_create_dir("test_logs/../test_logs/dir1/dir4", "test_logs/dir1/dir4");
|
||||
test_create_dir("./test_logs/dir1/dir2/dir99/../dir23", "test_logs/dir1/dir2/dir23");
|
||||
spdlog::drop("test-create-dir");
|
||||
}
|
Reference in New Issue
Block a user