Switch to std::filesystem
Drop the dependency on Boost.Filesystem
Change-Id: I5d6f6fe38cd0cf1c6996221188fa63db146dc9f9
diff --git a/tests/unit/util/config-file.t.cpp b/tests/unit/util/config-file.t.cpp
index ab8f212..eac5f21 100644
--- a/tests/unit/util/config-file.t.cpp
+++ b/tests/unit/util/config-file.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2023 Regents of the University of California.
+ * Copyright (c) 2013-2024 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -24,7 +24,6 @@
#include "tests/boost-test.hpp"
#include "tests/unit/test-home-env-saver.hpp"
-#include <boost/filesystem/operations.hpp>
#include <cstdlib>
namespace ndn::tests {
@@ -34,15 +33,13 @@
BOOST_AUTO_TEST_CASE(Parse)
{
- namespace fs = boost::filesystem;
-
setenv("TEST_HOME", "tests/unit/util/config-file-home", 1);
- fs::path homePath(fs::absolute(std::getenv("TEST_HOME")));
+ auto homePath = std::filesystem::absolute(std::getenv("TEST_HOME"));
homePath /= ".ndn/client.conf";
ConfigFile config;
- BOOST_REQUIRE_EQUAL(config.getPath(), homePath);
+ BOOST_CHECK_EQUAL(config.getPath(), homePath);
const ConfigFile::Parsed& parsed = config.getParsedConfiguration();
BOOST_CHECK_EQUAL(parsed.get<std::string>("a"), "/path/to/nowhere");
@@ -53,14 +50,14 @@
{
setenv("TEST_HOME", "tests/unit/util/does/not/exist", 1);
- BOOST_CHECK_NO_THROW(ConfigFile config);
+ BOOST_CHECK_NO_THROW(ConfigFile{});
}
BOOST_AUTO_TEST_CASE(ParseMalformed)
{
setenv("TEST_HOME", "tests/unit/util/config-file-malformed-home", 1);
- BOOST_CHECK_THROW(ConfigFile config, ConfigFile::Error);
+ BOOST_CHECK_THROW(ConfigFile{}, ConfigFile::Error);
}
BOOST_AUTO_TEST_SUITE_END() // TestConfigFile
diff --git a/tests/unit/util/io.t.cpp b/tests/unit/util/io.t.cpp
index 2dc303d..350abf6 100644
--- a/tests/unit/util/io.t.cpp
+++ b/tests/unit/util/io.t.cpp
@@ -24,9 +24,11 @@
#include "tests/boost-test.hpp"
#include "tests/key-chain-fixture.hpp"
-#include <boost/filesystem.hpp>
#include <boost/mp11/list.hpp>
+#include <filesystem>
+#include <system_error>
+
namespace ndn::tests {
BOOST_AUTO_TEST_SUITE(Util)
@@ -100,25 +102,23 @@
{
protected:
FileIoFixture()
- : filepath(boost::filesystem::path(UNIT_TESTS_TMPDIR) / "TestIo")
- , filename(filepath.string())
{
- boost::filesystem::create_directories(filepath.parent_path());
+ std::filesystem::create_directories(filename.parent_path());
}
~FileIoFixture()
{
- boost::system::error_code ec;
- boost::filesystem::remove(filepath, ec); // ignore error
+ std::error_code ec;
+ std::filesystem::remove(filename, ec); // ignore error
}
/**
- * \brief Create a directory at `filepath`, so that it's neither readable nor writable as a file.
+ * \brief Create a directory at `filename`, so that it's neither readable nor writable as a file.
*/
void
mkdir() const
{
- boost::filesystem::create_directory(filepath);
+ std::filesystem::create_directory(filename);
}
template<typename Container>
@@ -148,8 +148,7 @@
}
protected:
- const boost::filesystem::path filepath;
- const std::string filename;
+ const std::filesystem::path filename{std::filesystem::path(UNIT_TESTS_TMPDIR) / "TestIo"};
};
BOOST_FIXTURE_TEST_SUITE(FileIo, FileIoFixture)
diff --git a/tests/unit/util/sqlite3-statement.t.cpp b/tests/unit/util/sqlite3-statement.t.cpp
index b3d32d5..fe114c9 100644
--- a/tests/unit/util/sqlite3-statement.t.cpp
+++ b/tests/unit/util/sqlite3-statement.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2023 Regents of the University of California.
+ * Copyright (c) 2013-2024 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -23,8 +23,8 @@
#include "tests/boost-test.hpp"
-#include <boost/filesystem.hpp>
#include <cstring>
+#include <filesystem>
#include <sqlite3.h>
namespace ndn::tests {
@@ -36,9 +36,9 @@
public:
Sqlite3DbFixture()
{
- boost::filesystem::create_directories(m_path);
+ std::filesystem::create_directories(m_path);
- int result = sqlite3_open_v2((m_path / "sqlite3-statement.db").string().c_str(), &db,
+ int result = sqlite3_open_v2((m_path / "sqlite3-statement.db").c_str(), &db,
SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE,
#ifdef NDN_CXX_DISABLE_SQLITE3_FS_LOCKING
"unix-dotfile"
@@ -48,21 +48,21 @@
);
if (result != SQLITE_OK) {
- BOOST_FAIL("Sqlite3 database cannot be opened/created: " + m_path.string());
+ BOOST_FAIL("Sqlite3 database cannot be opened/created: " + m_path.native());
}
}
~Sqlite3DbFixture()
{
sqlite3_close(db);
- boost::filesystem::remove_all(m_path);
+ std::filesystem::remove_all(m_path);
}
protected:
sqlite3* db = nullptr;
private:
- const boost::filesystem::path m_path{UNIT_TESTS_TMPDIR};
+ const std::filesystem::path m_path{UNIT_TESTS_TMPDIR};
};
BOOST_AUTO_TEST_SUITE(Util)