mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-03-09 15:15:12 +01:00
Introduce GetUniquePath(base) helper method to replace boost::filesystem::unique_path() which is not available in std::filesystem.
This commit is contained in:
@@ -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()
|
||||
Reference in New Issue
Block a user