Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/dosbox-staging/dosbox-staging.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorkcgen <kcgen@users.noreply.github.com>2022-08-22 00:06:02 +0300
committerkcgen <1557255+kcgen@users.noreply.github.com>2022-08-22 08:32:33 +0300
commitf2b967b2ad1d18f6075b93495a5a257c8b3d29f7 (patch)
tree2431c0261a8c2072f39db11c36ba92f65949cf4f /tests
parent76c851f423845bbd6f218b1f4ee80f62bc706c3e (diff)
Add a path-simplifying filesystem utility function
Diffstat (limited to 'tests')
-rw-r--r--tests/fs_utils_tests.cpp21
-rw-r--r--tests/vs/tests.vcxproj1
-rw-r--r--tests/vs/tests.vcxproj.filters1
3 files changed, 23 insertions, 0 deletions
diff --git a/tests/fs_utils_tests.cpp b/tests/fs_utils_tests.cpp
index 71d026d11..50c950546 100644
--- a/tests/fs_utils_tests.cpp
+++ b/tests/fs_utils_tests.cpp
@@ -81,6 +81,27 @@ struct CreateDirTest : public testing::Test {
}
};
+TEST(SimplifyPath, Nominal)
+{
+ const std_fs::path original = "tests/files/paths";
+ const auto simplified = simplify_path(original);
+ EXPECT_EQ(original, simplified);
+}
+
+TEST(SimplifyPath, CanBeSimplifiedEasy)
+{
+ const std_fs::path original = "tests/files/paths/../../";
+ const auto simplified = simplify_path(original);
+ EXPECT_TRUE(simplified.string().length() < original.string().length());
+}
+
+TEST(SimplifyPath, CanBeSimplifiedComplex)
+{
+ const std_fs::path original = "./tests123/../valid/tests456///1/..//2/../3/../..";
+ const std_fs::path expected = "valid/";
+ EXPECT_EQ(simplify_path(original), expected);
+}
+
TEST_F(CreateDirTest, CreateDir)
{
ASSERT_FALSE(path_exists(TEST_DIR));
diff --git a/tests/vs/tests.vcxproj b/tests/vs/tests.vcxproj
index c36c68e50..30a1e85ee 100644
--- a/tests/vs/tests.vcxproj
+++ b/tests/vs/tests.vcxproj
@@ -338,6 +338,7 @@ $(TargetPath)</Command>
<ClCompile Include="..\..\src\libs\whereami\whereami.c" />
<ClCompile Include="..\..\src\misc\ansi_code_markup.cpp" />
<ClCompile Include="..\..\src\misc\cross.cpp" />
+ <ClCompile Include="..\..\src\misc\fs_utils.cpp" />
<ClCompile Include="..\..\src\misc\fs_utils_win32.cpp" />
<ClCompile Include="..\..\src\misc\rwqueue.cpp" />
<ClCompile Include="..\..\src\misc\setup.cpp" />
diff --git a/tests/vs/tests.vcxproj.filters b/tests/vs/tests.vcxproj.filters
index 92738adbd..04352dab8 100644
--- a/tests/vs/tests.vcxproj.filters
+++ b/tests/vs/tests.vcxproj.filters
@@ -6,6 +6,7 @@
<ClCompile Include="..\..\src\libs\whereami\whereami.c" />
<ClCompile Include="..\..\src\misc\ansi_code_markup.cpp" />
<ClCompile Include="..\..\src\misc\cross.cpp" />
+ <ClCompile Include="..\..\src\misc\fs_utils.cpp" />
<ClCompile Include="..\..\src\misc\fs_utils_win32.cpp" />
<ClCompile Include="..\..\src\misc\rwqueue.cpp" />
<ClCompile Include="..\..\src\misc\setup.cpp" />