aboutsummaryrefslogtreecommitdiff
path: root/src/test/fs_tests.cpp
diff options
context:
space:
mode:
authorKiminuo <kiminuo@protonmail.com>2021-02-01 13:35:28 +0100
committerKiminuo <kiminuo@protonmail.com>2021-02-04 11:38:09 +0100
commit1bca2aa694cd85984c09699ae28daec313077462 (patch)
treedd3ea392cf4379cb03e1476736c5e968c759129e /src/test/fs_tests.cpp
parentea5a50f92a6ff81b1d2dd67cdc3663e0e66733ac (diff)
Introduce GetUniquePath(base) helper method to replace boost::filesystem::unique_path() which is not available in std::filesystem.
Diffstat (limited to 'src/test/fs_tests.cpp')
-rw-r--r--src/test/fs_tests.cpp18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/test/fs_tests.cpp b/src/test/fs_tests.cpp
index ec487aa3ff..e52cd5230c 100644
--- a/src/test/fs_tests.cpp
+++ b/src/test/fs_tests.cpp
@@ -5,6 +5,7 @@
#include <fs.h>
#include <test/util/setup_common.h>
#include <util/system.h>
+#include <util/getuniquepath.h>
#include <boost/test/unit_test.hpp>
@@ -69,6 +70,21 @@ BOOST_AUTO_TEST_CASE(fsbridge_fstream)
BOOST_CHECK_EQUAL(tmpfile1, fsbridge::AbsPathJoin(tmpfile1, ""));
BOOST_CHECK_EQUAL(tmpfile1, fsbridge::AbsPathJoin(tmpfile1, {}));
}
+ {
+ fs::path p1 = GetUniquePath(tmpfolder);
+ fs::path p2 = GetUniquePath(tmpfolder);
+ fs::path p3 = GetUniquePath(tmpfolder);
+
+ // Ensure that the parent path is always the same.
+ BOOST_CHECK_EQUAL(tmpfolder, p1.parent_path());
+ BOOST_CHECK_EQUAL(tmpfolder, p2.parent_path());
+ BOOST_CHECK_EQUAL(tmpfolder, p3.parent_path());
+
+ // Ensure that generated paths are actually different.
+ BOOST_CHECK(p1 != p2);
+ BOOST_CHECK(p2 != p3);
+ BOOST_CHECK(p1 != p3);
+ }
}
-BOOST_AUTO_TEST_SUITE_END()
+BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file