Replace boost::filesystem with std (#6432)
This commit is contained in:
@@ -1,16 +1,39 @@
|
||||
#ifndef UNIT_TESTS_TEMPORARY_FILE_HPP
|
||||
#define UNIT_TESTS_TEMPORARY_FILE_HPP
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <cstdlib>
|
||||
#include <filesystem>
|
||||
#include <random>
|
||||
#include <string>
|
||||
|
||||
inline std::string random_string(std::string::size_type length)
|
||||
{
|
||||
static auto &chrs = "0123456789"
|
||||
"abcdefghijklmnopqrstuvwxyz"
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
|
||||
thread_local static std::mt19937 rg{std::random_device{}()};
|
||||
thread_local static std::uniform_int_distribution<std::string::size_type> pick(
|
||||
0, sizeof(chrs) - 2);
|
||||
|
||||
std::string s;
|
||||
s.reserve(length);
|
||||
|
||||
while (length--)
|
||||
{
|
||||
s += chrs[pick(rg)];
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
struct TemporaryFile
|
||||
{
|
||||
TemporaryFile() : path(boost::filesystem::unique_path()) {}
|
||||
TemporaryFile() : path(std::filesystem::temp_directory_path() / random_string(8)) {}
|
||||
TemporaryFile(const std::string &path) : path(path) {}
|
||||
|
||||
~TemporaryFile() { boost::filesystem::remove(path); }
|
||||
~TemporaryFile() { std::filesystem::remove(path); }
|
||||
|
||||
boost::filesystem::path path;
|
||||
std::filesystem::path path;
|
||||
};
|
||||
|
||||
#endif // UNIT_TESTS_TEMPORARY_FILE_HPP
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
#include "extractor/location_dependent_data.hpp"
|
||||
|
||||
#include "../common/range_tools.hpp"
|
||||
#include "../common/temporary_file.hpp"
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
#include <cstdlib>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <random>
|
||||
#include <vector>
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(location_dependent_data_tests)
|
||||
@@ -16,14 +19,13 @@ using point_t = LocationDependentData::point_t;
|
||||
|
||||
struct LocationDataFixture
|
||||
{
|
||||
LocationDataFixture(const std::string &json) : temporary_file(boost::filesystem::unique_path())
|
||||
LocationDataFixture(const std::string &json)
|
||||
{
|
||||
std::ofstream file(temporary_file.string());
|
||||
std::ofstream file(temporary_file.path.string());
|
||||
file << json;
|
||||
}
|
||||
~LocationDataFixture() { remove(temporary_file); }
|
||||
|
||||
boost::filesystem::path temporary_file;
|
||||
TemporaryFile temporary_file;
|
||||
};
|
||||
|
||||
BOOST_AUTO_TEST_CASE(polygon_tests)
|
||||
@@ -50,7 +52,7 @@ BOOST_AUTO_TEST_CASE(polygon_tests)
|
||||
}
|
||||
]})json");
|
||||
|
||||
LocationDependentData data({fixture.temporary_file});
|
||||
LocationDependentData data({fixture.temporary_file.path});
|
||||
|
||||
BOOST_CHECK(data.GetPropertyIndexes(point_t(0, 0)).empty());
|
||||
CHECK_EQUAL_RANGE(data.GetPropertyIndexes(point_t(1, 1)), 0);
|
||||
@@ -86,7 +88,7 @@ BOOST_AUTO_TEST_CASE(multy_polygon_tests)
|
||||
}
|
||||
]})json");
|
||||
|
||||
LocationDependentData data({fixture.temporary_file});
|
||||
LocationDependentData data({fixture.temporary_file.path});
|
||||
|
||||
BOOST_CHECK(data.GetPropertyIndexes(point_t(0, 2)).empty());
|
||||
BOOST_CHECK(data.GetPropertyIndexes(point_t(0, -3)).empty());
|
||||
@@ -117,7 +119,7 @@ BOOST_AUTO_TEST_CASE(polygon_merging_tests)
|
||||
}
|
||||
]})json");
|
||||
|
||||
LocationDependentData data({fixture.temporary_file});
|
||||
LocationDependentData data({fixture.temporary_file.path});
|
||||
|
||||
CHECK_EQUAL_RANGE(data.GetPropertyIndexes(point_t(-3, 3)), 0);
|
||||
CHECK_EQUAL_RANGE(data.GetPropertyIndexes(point_t(-3, 1)), 0);
|
||||
@@ -153,7 +155,7 @@ BOOST_AUTO_TEST_CASE(staircase_polygon)
|
||||
}
|
||||
]})json");
|
||||
|
||||
LocationDependentData data({fixture.temporary_file});
|
||||
LocationDependentData data({fixture.temporary_file.path});
|
||||
|
||||
// all corners
|
||||
BOOST_CHECK(!data.GetPropertyIndexes(point_t(0, 0)).empty());
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
|
||||
#include "../common/temporary_file.hpp"
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
#include <filesystem>
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
@@ -4,9 +4,10 @@
|
||||
|
||||
#include <osrm/coordinate.hpp>
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
#include <filesystem>
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(raster_source)
|
||||
|
||||
using namespace osrm;
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
#include "../common/range_tools.hpp"
|
||||
#include "../common/temporary_file.hpp"
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
#include <cmath>
|
||||
#include <filesystem>
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(data_layout)
|
||||
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
#include "../common/range_tools.hpp"
|
||||
#include "../common/temporary_file.hpp"
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
#include <filesystem>
|
||||
#include <random>
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(serialization)
|
||||
|
||||
@@ -2,9 +2,10 @@
|
||||
#include "util/geojson_validation.hpp"
|
||||
#include "util/timezones.hpp"
|
||||
|
||||
#include <boost/filesystem/path.hpp>
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
#include <filesystem>
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(timezoner)
|
||||
|
||||
using namespace osrm;
|
||||
@@ -22,7 +23,7 @@ BOOST_AUTO_TEST_CASE(timezoner_test)
|
||||
std::time_t now = time(0);
|
||||
BOOST_CHECK_NO_THROW(Timezoner tz(json, now));
|
||||
|
||||
boost::filesystem::path test_path(TEST_DATA_DIR "/test.geojson");
|
||||
std::filesystem::path test_path(TEST_DATA_DIR "/test.geojson");
|
||||
BOOST_CHECK_NO_THROW(Timezoner tz(test_path, now));
|
||||
|
||||
// missing opening bracket
|
||||
|
||||
@@ -3,9 +3,10 @@
|
||||
#include "../common/range_tools.hpp"
|
||||
#include "../common/temporary_file.hpp"
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
#include <filesystem>
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(serialization)
|
||||
|
||||
using namespace osrm;
|
||||
|
||||
@@ -227,7 +227,7 @@ void sampling_verify_rtree(RTreeT &rtree,
|
||||
}
|
||||
|
||||
template <typename RTreeT, typename FixtureT>
|
||||
auto make_rtree(const boost::filesystem::path &path, FixtureT &fixture)
|
||||
auto make_rtree(const std::filesystem::path &path, FixtureT &fixture)
|
||||
{
|
||||
return RTreeT(fixture.edges, fixture.coords, path);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user