Commit 31ed1339 authored by gabime's avatar gabime

Added dir_name tests

parent 9a68bd8c
...@@ -23,5 +23,36 @@ TEST_CASE("create_dir", "[create_dir]") ...@@ -23,5 +23,36 @@ TEST_CASE("create_dir", "[create_dir]")
test_create_dir("./test_logs/dir1/dir3", "test_logs/dir1/dir3"); 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/../test_logs/dir1/dir4", "test_logs/dir1/dir4");
test_create_dir("./test_logs/dir1/dir2/dir99/../dir23", "test_logs/dir1/dir2/dir23"); test_create_dir("./test_logs/dir1/dir2/dir99/../dir23", "test_logs/dir1/dir2/dir23");
spdlog::drop("test-create-dir"); }
TEST_CASE("dir_name", "[create_dir]")
{
using spdlog::details::os::dir_name;
REQUIRE(dir_name("").empty());
REQUIRE(dir_name("dir").empty());
REQUIRE(dir_name("dir/") == "dir");
REQUIRE(dir_name("dir///") == "dir//");
REQUIRE(dir_name("dir/file") == "dir");
REQUIRE(dir_name("dir/file.txt") == "dir");
REQUIRE(dir_name("dir/file.txt/") == "dir/file.txt");
REQUIRE(dir_name("/dir/file.txt") == "/dir");
REQUIRE(dir_name("//dir/file.txt") == "//dir");
REQUIRE(dir_name("//dir/file.txt") == "//dir");
REQUIRE(dir_name("../file.txt") == "..");
REQUIRE(dir_name("./file.txt") == ".");
#ifdef WIN32
REQUIRE(dir_name(R"(dir\)") == "dir");
REQUIRE(dir_name(R"(dir\\\)") == "dir//");
REQUIRE(dir_name(R"(dir\file)") == "dir");
REQUIRE(dir_name(R"(dir\file.txt)") == "dir");
REQUIRE(dir_name(R"(dir\file.txt\)") == "dir/file.txt");
REQUIRE(dir_name(R"(\dir\file.txt)") == "/dir");
REQUIRE(dir_name(R"(\\dir\file.txt)") == "//dir");
REQUIRE(dir_name(R"(\\dir\file.txt)") == "//dir");
REQUIRE(dir_name(R"(..\file.txt)") == "..");
REQUIRE(dir_name(R"(.\file.txt)") == ".");
REQUIRE(dir_name(R"(c:\\a\b\c\d\file.txt)") == "c://a/b/c/d");
//REQUIRE(dir_name(R"(c:\\a)") == "c://");
#endif
} }
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