diff options
author | Kiminuo <kiminuo@protonmail.com> | 2021-01-13 15:44:40 +0100 |
---|---|---|
committer | Kiminuo <kiminuo@protonmail.com> | 2021-01-15 22:48:15 +0100 |
commit | da9caa1cedd69702aea44cb44b2fd0a2d6d56916 (patch) | |
tree | fc2198dea8c7c5f0cd91b7df259afd1a4c90efd7 /src/test/fs_tests.cpp | |
parent | 66576c4fd532ac18b8b355ea93d25581a2c15654 (diff) |
Replace fs::absolute calls with AbsPathJoin calls
This adds better test coverage and will make it easier in #20744 to remove our dependency on the two-argument boost::filesystem::absolute() function which does not have a direct equivalent in C++17.
Diffstat (limited to 'src/test/fs_tests.cpp')
-rw-r--r-- | src/test/fs_tests.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/test/fs_tests.cpp b/src/test/fs_tests.cpp index d02c3613ba..ec487aa3ff 100644 --- a/src/test/fs_tests.cpp +++ b/src/test/fs_tests.cpp @@ -52,6 +52,23 @@ BOOST_AUTO_TEST_CASE(fsbridge_fstream) file >> input_buffer; BOOST_CHECK_EQUAL(input_buffer, "bitcoin"); } + { + // Join an absolute path and a relative path. + fs::path p = fsbridge::AbsPathJoin(tmpfolder, "fs_tests_₿_🏃"); + BOOST_CHECK(p.is_absolute()); + BOOST_CHECK_EQUAL(tmpfile1, p); + } + { + // Join two absolute paths. + fs::path p = fsbridge::AbsPathJoin(tmpfile1, tmpfile2); + BOOST_CHECK(p.is_absolute()); + BOOST_CHECK_EQUAL(tmpfile2, p); + } + { + // Ensure joining with empty paths does not add trailing path components. + BOOST_CHECK_EQUAL(tmpfile1, fsbridge::AbsPathJoin(tmpfile1, "")); + BOOST_CHECK_EQUAL(tmpfile1, fsbridge::AbsPathJoin(tmpfile1, {})); + } } BOOST_AUTO_TEST_SUITE_END() |