mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 06:58:57 +01:00
refactor: replace boost::filesystem with std::filesystem
Warning: Replacing fs::system_complete calls with fs::absolute calls in this commit may cause minor changes in behaviour because fs::absolute no longer strips trailing slashes; however these changes are believed to be safe. Co-authored-by: Russell Yanofsky <russ@yanofsky.org> Co-authored-by: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com>
This commit is contained in:
@@ -2,14 +2,15 @@
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
#include <fs.h>
|
||||
#include <test/util/setup_common.h>
|
||||
#include <wallet/bdb.h>
|
||||
|
||||
#include <fstream>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
namespace wallet {
|
||||
BOOST_FIXTURE_TEST_SUITE(db_tests, BasicTestingSetup)
|
||||
@@ -26,7 +27,7 @@ BOOST_AUTO_TEST_CASE(getwalletenv_file)
|
||||
std::string test_name = "test_name.dat";
|
||||
const fs::path datadir = gArgs.GetDataDirNet();
|
||||
fs::path file_path = datadir / test_name;
|
||||
fs::ofstream f(file_path);
|
||||
std::ofstream f{file_path};
|
||||
f.close();
|
||||
|
||||
std::string filename;
|
||||
|
||||
@@ -7,6 +7,9 @@
|
||||
#include <util/check.h>
|
||||
#include <util/system.h>
|
||||
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
|
||||
#include <wallet/test/init_test_fixture.h>
|
||||
|
||||
namespace wallet {
|
||||
@@ -24,8 +27,8 @@ InitWalletDirTestingSetup::InitWalletDirTestingSetup(const std::string& chainNam
|
||||
m_walletdir_path_cases["custom"] = m_datadir / "my_wallets";
|
||||
m_walletdir_path_cases["nonexistent"] = m_datadir / "path_does_not_exist";
|
||||
m_walletdir_path_cases["file"] = m_datadir / "not_a_directory.dat";
|
||||
m_walletdir_path_cases["trailing"] = m_datadir / "wallets" / sep;
|
||||
m_walletdir_path_cases["trailing2"] = m_datadir / "wallets" / sep / sep;
|
||||
m_walletdir_path_cases["trailing"] = m_datadir / ("wallets" + sep);
|
||||
m_walletdir_path_cases["trailing2"] = m_datadir / ("wallets" + sep + sep);
|
||||
|
||||
fs::current_path(m_datadir);
|
||||
m_walletdir_path_cases["relative"] = "wallets";
|
||||
@@ -33,7 +36,7 @@ InitWalletDirTestingSetup::InitWalletDirTestingSetup(const std::string& chainNam
|
||||
fs::create_directories(m_walletdir_path_cases["default"]);
|
||||
fs::create_directories(m_walletdir_path_cases["custom"]);
|
||||
fs::create_directories(m_walletdir_path_cases["relative"]);
|
||||
fs::ofstream f(m_walletdir_path_cases["file"]);
|
||||
std::ofstream f{m_walletdir_path_cases["file"]};
|
||||
f.close();
|
||||
}
|
||||
|
||||
|
||||
@@ -73,6 +73,8 @@ BOOST_AUTO_TEST_CASE(walletinit_verify_walletdir_no_trailing)
|
||||
BOOST_CHECK_EQUAL(walletdir, expected_path);
|
||||
}
|
||||
|
||||
#ifndef WIN32
|
||||
// Windows does not consider "datadir/wallets//" to be a valid directory path.
|
||||
BOOST_AUTO_TEST_CASE(walletinit_verify_walletdir_no_trailing2)
|
||||
{
|
||||
SetWalletDir(m_walletdir_path_cases["trailing2"]);
|
||||
@@ -82,6 +84,7 @@ BOOST_AUTO_TEST_CASE(walletinit_verify_walletdir_no_trailing2)
|
||||
fs::path expected_path = fs::canonical(m_walletdir_path_cases["default"]);
|
||||
BOOST_CHECK_EQUAL(walletdir, expected_path);
|
||||
}
|
||||
#endif
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
} // namespace wallet
|
||||
|
||||
Reference in New Issue
Block a user