This commit is contained in:
2024-08-02 20:59:41 -05:00
parent bba7f10703
commit 6718eb374d
6 changed files with 91 additions and 38 deletions

View File

@@ -120,43 +120,43 @@ TEST(utils_path, combine) {
}
TEST(utils_path, format_path) {
std::string path{"\\"};
utils::path::format_path(path, utils::path::directory_seperator,
utils::path::not_directory_seperator);
std::string path{"./"};
utils::path::format_path(path, utils::path::slash, utils::path::backslash);
EXPECT_STREQ(".", path.c_str());
path = "~/.test";
utils::path::format_path(path, utils::path::slash, utils::path::backslash);
EXPECT_STREQ("~/.test", path.c_str());
path = "\\";
utils::path::format_path(path, utils::path::slash, utils::path::backslash);
EXPECT_STREQ("/", path.c_str());
path = "\\\\";
utils::path::format_path(path, utils::path::directory_seperator,
utils::path::not_directory_seperator);
utils::path::format_path(path, utils::path::slash, utils::path::backslash);
EXPECT_STREQ("/", path.c_str());
path = "\\\\\\";
utils::path::format_path(path, utils::path::directory_seperator,
utils::path::not_directory_seperator);
utils::path::format_path(path, utils::path::slash, utils::path::backslash);
EXPECT_STREQ("/", path.c_str());
path = "\\\\\\\\";
utils::path::format_path(path, utils::path::directory_seperator,
utils::path::not_directory_seperator);
utils::path::format_path(path, utils::path::slash, utils::path::backslash);
EXPECT_STREQ("/", path.c_str());
path = "/";
utils::path::format_path(path, utils::path::directory_seperator,
utils::path::not_directory_seperator);
utils::path::format_path(path, utils::path::slash, utils::path::backslash);
EXPECT_STREQ("/", path.c_str());
path = "//";
utils::path::format_path(path, utils::path::directory_seperator,
utils::path::not_directory_seperator);
utils::path::format_path(path, utils::path::slash, utils::path::backslash);
EXPECT_STREQ("/", path.c_str());
path = "///";
utils::path::format_path(path, utils::path::directory_seperator,
utils::path::not_directory_seperator);
utils::path::format_path(path, utils::path::slash, utils::path::backslash);
EXPECT_STREQ("/", path.c_str());
path = "////";
utils::path::format_path(path, utils::path::directory_seperator,
utils::path::not_directory_seperator);
utils::path::format_path(path, utils::path::slash, utils::path::backslash);
EXPECT_STREQ("/", path.c_str());
}
@@ -245,4 +245,20 @@ TEST(utils_path, finalize) {
EXPECT_STREQ("/cow/moose/dog/chicken", s.c_str());
#endif
}
#if !defined(_WIN32)
TEST(utils_path, resolve) {
std::cout << utils::path::resolve("~") << std::endl;
std::cout << utils::path::combine("~",
{
".local",
})
<< std::endl;
std::cout << utils::path::resolve(utils::path::combine("~",
{
".local",
}))
<< std::endl;
}
#endif // !defined(_WIN32)
} // namespace repertory