diff --git a/include/bitcoin/database/boost.hpp b/include/bitcoin/database/boost.hpp index 4f854b55..5ffff596 100644 --- a/include/bitcoin/database/boost.hpp +++ b/include/bitcoin/database/boost.hpp @@ -48,15 +48,11 @@ inline file_handle_t open_existing_file( const std::filesystem::path& file) NOEXCEPT { constexpr auto mode = interprocess::read_write; -#if defined(HAVE_MSC) - const auto filename = system::to_extended_path(file); -#else - const auto filename = file; -#endif + const auto filename = system::extended_path(file); // Does not throw (unannotated). BC_PUSH_WARNING(NO_THROW_IN_NOEXCEPT) - return ipcdetail::open_existing_file(file.string().c_str(), mode); + return ipcdetail::open_existing_file(filename.c_str(), mode); BC_POP_WARNING() } diff --git a/include/bitcoin/database/tables/names.hpp b/include/bitcoin/database/tables/names.hpp index f3d6ddef..a12ed75d 100644 --- a/include/bitcoin/database/tables/names.hpp +++ b/include/bitcoin/database/tables/names.hpp @@ -26,6 +26,8 @@ namespace libbitcoin { namespace database { namespace schema { +/// These should be ASCII only. + namespace dir { constexpr auto heads = "heads"; diff --git a/src/file/utilities.cpp b/src/file/utilities.cpp index 793b328f..f9595ebe 100644 --- a/src/file/utilities.cpp +++ b/src/file/utilities.cpp @@ -44,8 +44,10 @@ BC_PUSH_WARNING(NO_THROW_IN_NOEXCEPT) inline path trim(const path& value) NOEXCEPT { + static const string_list trims{ "/", "\\", "\x20" }; + // Trailing slash may cause successful create_directories returning false. - return system::trim_right_copy(value.string(), { "/", "\\", "\x20" }); + return to_path(trim_right_copy(from_path(value), trims)); } // We don't use ec because it gets set (not found) when false, but no way to @@ -53,7 +55,7 @@ inline path trim(const path& value) NOEXCEPT bool is_directory(const path& directory) NOEXCEPT { code ec{ system::error::errorno_t::no_error }; - return std::filesystem::is_directory(system::to_extended_path(directory), ec); + return std::filesystem::is_directory(system::extended_path(directory), ec); } bool clear_directory(const path& directory) NOEXCEPT @@ -64,7 +66,7 @@ bool clear_directory(const path& directory) NOEXCEPT code clear_directory_ex(const path& directory) NOEXCEPT { code ec{ system::error::errorno_t::no_error }; - const auto path = system::to_extended_path(directory); + const auto path = system::extended_path(directory); std::filesystem::remove_all(path, ec); if (ec) return ec; std::filesystem::create_directories(path, ec); @@ -79,7 +81,7 @@ bool create_directory(const path& directory) NOEXCEPT code create_directory_ex(const path& directory) NOEXCEPT { code ec{ system::error::errorno_t::no_error }; - const auto path = system::to_extended_path(trim(directory)); + const auto path = system::extended_path(trim(directory)); const auto created = std::filesystem::create_directories(path, ec); if (ec || created) return ec; return system::error::errorno_t::is_a_directory; @@ -182,7 +184,7 @@ bool remove(const path& name) NOEXCEPT code remove_ex(const path& name) NOEXCEPT { code ec{ system::error::errorno_t::no_error }; - std::filesystem::remove(system::to_extended_path(name), ec); + std::filesystem::remove(system::extended_path(name), ec); return ec; } @@ -196,8 +198,8 @@ bool rename(const path& from, const path& to) NOEXCEPT code rename_ex(const path& from, const path& to) NOEXCEPT { code ec{ system::error::errorno_t::no_error }; - std::filesystem::rename(system::to_extended_path(from), - system::to_extended_path(to), ec); + std::filesystem::rename(system::extended_path(from), + system::extended_path(to), ec); return ec; } @@ -212,8 +214,8 @@ bool copy(const path& from, const path& to) NOEXCEPT code copy_ex(const path& from, const path& to) NOEXCEPT { code ec{ system::error::errorno_t::no_error }; - std::filesystem::copy_file(system::to_extended_path(from), - system::to_extended_path(to), ec); + std::filesystem::copy_file(system::extended_path(from), + system::extended_path(to), ec); return ec; } @@ -234,8 +236,8 @@ code copy_directory_ex(const path& from, const path& to) NOEXCEPT return system::error::errorno_t::not_a_directory; code ec{ system::error::errorno_t::no_error }; - std::filesystem::copy(system::to_extended_path(from), - system::to_extended_path(to), ec); + std::filesystem::copy(system::extended_path(from), + system::extended_path(to), ec); return ec; } @@ -250,7 +252,7 @@ code copy_directory_ex(const path& from, const path& to) NOEXCEPT int open(const path& filename, bool MSC_OR_NOAPPLE(random)) NOEXCEPT { - const auto path = system::to_extended_path(filename); + const auto path = system::extended_path(filename); int file_descriptor{}; #if defined(HAVE_MSC) @@ -371,7 +373,7 @@ code size_ex(size_t& out, const std::filesystem::path& filename) NOEXCEPT { code ec{ system::error::errorno_t::no_error }; const auto size = std::filesystem::file_size( - to_extended_path(filename), ec); + system::extended_path(filename), ec); if (ec) return ec; if (is_limited(size)) @@ -389,7 +391,8 @@ bool space(size_t& out, const path& filename) NOEXCEPT code space_ex(size_t& out, const path& filename) NOEXCEPT { code ec{ system::error::errorno_t::no_error }; - const auto space = std::filesystem::space(to_extended_path(filename), ec); + const auto space = std::filesystem::space( + system::extended_path(filename), ec); if (ec) return ec; if (is_limited(space.available)) return system::error::errorno_t::value_too_large; diff --git a/src/locks/file_lock.cpp b/src/locks/file_lock.cpp index 7a54ee64..5c56c0fb 100644 --- a/src/locks/file_lock.cpp +++ b/src/locks/file_lock.cpp @@ -57,7 +57,7 @@ bool file_lock::destroy() NOEXCEPT // remove returns false if file did not exist though error_code is false if // file did not exist. use of error_code overload also precludes exception. std::error_code ec; - std::filesystem::remove(system::to_extended_path(file_), ec); + std::filesystem::remove(system::extended_path(file_), ec); return !ec; } diff --git a/test/file/rotator.cpp b/test/file/rotator.cpp index 04e676bd..d3e0876b 100644 --- a/test/file/rotator.cpp +++ b/test/file/rotator.cpp @@ -18,25 +18,7 @@ */ #include "../test.hpp" -struct rotator_setup_fixture -{ - DELETE_COPY_MOVE(rotator_setup_fixture); - BC_PUSH_WARNING(NO_THROW_IN_NOEXCEPT) - - rotator_setup_fixture() NOEXCEPT - { - BOOST_REQUIRE(test::clear(test::directory)); - } - - ~rotator_setup_fixture() NOEXCEPT - { - BOOST_REQUIRE(test::clear(test::directory)); - } - - BC_POP_WARNING() -}; - -BOOST_FIXTURE_TEST_SUITE(rotator_tests, rotator_setup_fixture) +BOOST_FIXTURE_TEST_SUITE(rotator_tests, test::directory_setup_fixture) // ostream instance. using rotate = file::stream::out::rotator; diff --git a/test/file/utilities.cpp b/test/file/utilities.cpp index 3306f7d1..32dbbd7e 100644 --- a/test/file/utilities.cpp +++ b/test/file/utilities.cpp @@ -18,25 +18,7 @@ */ #include "../test.hpp" -struct file_utilities_setup_fixture -{ - DELETE_COPY_MOVE(file_utilities_setup_fixture); - BC_PUSH_WARNING(NO_THROW_IN_NOEXCEPT) - - file_utilities_setup_fixture() NOEXCEPT - { - BOOST_REQUIRE(test::clear(test::directory)); - } - - ~file_utilities_setup_fixture() NOEXCEPT - { - BOOST_REQUIRE(test::clear(test::directory)); - } - - BC_POP_WARNING() -}; - -BOOST_FIXTURE_TEST_SUITE(file_utilities_tests, file_utilities_setup_fixture) +BOOST_FIXTURE_TEST_SUITE(file_utilities_tests, test::directory_setup_fixture) using namespace system; static_assert(file::invalid == -1); diff --git a/test/locks/file_lock.cpp b/test/locks/file_lock.cpp index 29267840..eba7da2c 100644 --- a/test/locks/file_lock.cpp +++ b/test/locks/file_lock.cpp @@ -18,20 +18,7 @@ */ #include "../test.hpp" -struct file_lock_setup_fixture -{ - file_lock_setup_fixture() noexcept - { - BOOST_REQUIRE(test::clear(test::directory)); - } - - ~file_lock_setup_fixture() noexcept - { - BOOST_REQUIRE(test::clear(test::directory)); - } -}; - -BOOST_FIXTURE_TEST_SUITE(file_lock_tests, file_lock_setup_fixture) +BOOST_FIXTURE_TEST_SUITE(file_lock_tests, test::directory_setup_fixture) class access final : public file_lock diff --git a/test/locks/flush_lock.cpp b/test/locks/flush_lock.cpp index b091602f..3d821fbe 100644 --- a/test/locks/flush_lock.cpp +++ b/test/locks/flush_lock.cpp @@ -18,20 +18,7 @@ */ #include "../test.hpp" -struct flush_lock_setup_fixture -{ - flush_lock_setup_fixture() noexcept - { - BOOST_REQUIRE(test::clear(test::directory)); - } - - ~flush_lock_setup_fixture() noexcept - { - BOOST_REQUIRE(test::clear(test::directory)); - } -}; - -BOOST_FIXTURE_TEST_SUITE(flush_lock_tests, flush_lock_setup_fixture) +BOOST_FIXTURE_TEST_SUITE(flush_lock_tests, test::directory_setup_fixture) BOOST_AUTO_TEST_CASE(flush_lock__construct__file__expected) { diff --git a/test/locks/interprocess_lock.cpp b/test/locks/interprocess_lock.cpp index 5c25de21..e63cbb53 100644 --- a/test/locks/interprocess_lock.cpp +++ b/test/locks/interprocess_lock.cpp @@ -18,20 +18,7 @@ */ #include "../test.hpp" -struct interprocess_lock_setup_fixture -{ - interprocess_lock_setup_fixture() noexcept - { - BOOST_REQUIRE(test::clear(test::directory)); - } - - ~interprocess_lock_setup_fixture() noexcept - { - BOOST_REQUIRE(test::clear(test::directory)); - } -}; - -BOOST_FIXTURE_TEST_SUITE(interprocess_lock_tests, interprocess_lock_setup_fixture) +BOOST_FIXTURE_TEST_SUITE(interprocess_lock_tests, test::directory_setup_fixture) BOOST_AUTO_TEST_CASE(interprocess_lock__construct__file__expected) { diff --git a/test/memory/map.cpp b/test/memory/map.cpp index 074a9a66..08e62411 100644 --- a/test/memory/map.cpp +++ b/test/memory/map.cpp @@ -22,25 +22,7 @@ // error::load_failure, error::flush_failure, error::unload_failure codes, but // don't want to make this class virtual. -struct map_setup_fixture -{ - DELETE_COPY_MOVE(map_setup_fixture); - BC_PUSH_WARNING(NO_THROW_IN_NOEXCEPT) - - map_setup_fixture() NOEXCEPT - { - BOOST_REQUIRE(test::clear(test::directory)); - } - - ~map_setup_fixture() NOEXCEPT - { - BOOST_REQUIRE(test::clear(test::directory)); - } - - BC_POP_WARNING() -}; - -BOOST_FIXTURE_TEST_SUITE(map_tests, map_setup_fixture) +BOOST_FIXTURE_TEST_SUITE(map_tests, test::directory_setup_fixture) BOOST_AUTO_TEST_CASE(map__file__always__expected) { diff --git a/test/query/archive_read.cpp b/test/query/archive_read.cpp index cb46e8de..f2223410 100644 --- a/test/query/archive_read.cpp +++ b/test/query/archive_read.cpp @@ -20,25 +20,7 @@ #include "../mocks/blocks.hpp" #include "../mocks/chunk_store.hpp" -struct query_archive_read_setup_fixture -{ - DELETE_COPY_MOVE(query_archive_read_setup_fixture); - BC_PUSH_WARNING(NO_THROW_IN_NOEXCEPT) - - query_archive_read_setup_fixture() NOEXCEPT - { - BOOST_REQUIRE(test::clear(test::directory)); - } - - ~query_archive_read_setup_fixture() NOEXCEPT - { - BOOST_REQUIRE(test::clear(test::directory)); - } - - BC_POP_WARNING() -}; - -BOOST_FIXTURE_TEST_SUITE(query_archive_read_tests, query_archive_read_setup_fixture) +BOOST_FIXTURE_TEST_SUITE(query_archive_read_tests, test::directory_setup_fixture) ////const auto events_handler = [](auto, auto) {}; diff --git a/test/query/archive_write.cpp b/test/query/archive_write.cpp index ed132f8f..bc100321 100644 --- a/test/query/archive_write.cpp +++ b/test/query/archive_write.cpp @@ -20,25 +20,7 @@ #include "../mocks/blocks.hpp" #include "../mocks/chunk_store.hpp" -struct query_archive_write_setup_fixture -{ - DELETE_COPY_MOVE(query_archive_write_setup_fixture); - BC_PUSH_WARNING(NO_THROW_IN_NOEXCEPT) - - query_archive_write_setup_fixture() NOEXCEPT - { - BOOST_REQUIRE(test::clear(test::directory)); - } - - ~query_archive_write_setup_fixture() NOEXCEPT - { - BOOST_REQUIRE(test::clear(test::directory)); - } - - BC_POP_WARNING() -}; - -BOOST_FIXTURE_TEST_SUITE(query_archive_write_tests, query_archive_write_setup_fixture) +BOOST_FIXTURE_TEST_SUITE(query_archive_write_tests, test::directory_setup_fixture) // ensure context::flags is same size as chain_context::flags. static_assert(is_same_type); diff --git a/test/query/confirm.cpp b/test/query/confirm.cpp index 0e1f2bb9..9c8b2c8b 100644 --- a/test/query/confirm.cpp +++ b/test/query/confirm.cpp @@ -20,25 +20,7 @@ #include "../mocks/blocks.hpp" #include "../mocks/chunk_store.hpp" -struct query_confirm_setup_fixture -{ - DELETE_COPY_MOVE(query_confirm_setup_fixture); - BC_PUSH_WARNING(NO_THROW_IN_NOEXCEPT) - - query_confirm_setup_fixture() NOEXCEPT - { - BOOST_REQUIRE(test::clear(test::directory)); - } - - ~query_confirm_setup_fixture() NOEXCEPT - { - BOOST_REQUIRE(test::clear(test::directory)); - } - - BC_POP_WARNING() -}; - -BOOST_FIXTURE_TEST_SUITE(query_confirm_tests, query_confirm_setup_fixture) +BOOST_FIXTURE_TEST_SUITE(query_confirm_tests, test::directory_setup_fixture) // nop event handler. const auto events_handler = [](auto, auto) {}; diff --git a/test/query/consensus.cpp b/test/query/consensus.cpp index 67647720..5d2d212b 100644 --- a/test/query/consensus.cpp +++ b/test/query/consensus.cpp @@ -20,25 +20,7 @@ #include "../mocks/blocks.hpp" #include "../mocks/chunk_store.hpp" -struct query_consensus_setup_fixture -{ - DELETE_COPY_MOVE(query_consensus_setup_fixture); - BC_PUSH_WARNING(NO_THROW_IN_NOEXCEPT) - - query_consensus_setup_fixture() NOEXCEPT - { - BOOST_REQUIRE(test::clear(test::directory)); - } - - ~query_consensus_setup_fixture() NOEXCEPT - { - BOOST_REQUIRE(test::clear(test::directory)); - } - - BC_POP_WARNING() -}; - -BOOST_FIXTURE_TEST_SUITE(query_consensus_tests, query_consensus_setup_fixture) +BOOST_FIXTURE_TEST_SUITE(query_consensus_tests, test::directory_setup_fixture) ////const auto events_handler = [](auto, auto) {}; diff --git a/test/query/context.cpp b/test/query/context.cpp index cfad5c79..fcf3f6df 100644 --- a/test/query/context.cpp +++ b/test/query/context.cpp @@ -20,25 +20,7 @@ #include "../mocks/blocks.hpp" #include "../mocks/chunk_store.hpp" -struct query_context_setup_fixture -{ - DELETE_COPY_MOVE(query_context_setup_fixture); - BC_PUSH_WARNING(NO_THROW_IN_NOEXCEPT) - - query_context_setup_fixture() NOEXCEPT - { - BOOST_REQUIRE(test::clear(test::directory)); - } - - ~query_context_setup_fixture() NOEXCEPT - { - BOOST_REQUIRE(test::clear(test::directory)); - } - - BC_POP_WARNING() -}; - -BOOST_FIXTURE_TEST_SUITE(query_context_tests, query_context_setup_fixture) +BOOST_FIXTURE_TEST_SUITE(query_context_tests, test::directory_setup_fixture) const auto events_handler = [](auto, auto) {}; diff --git a/test/query/extent.cpp b/test/query/extent.cpp index 16340aed..36418b65 100644 --- a/test/query/extent.cpp +++ b/test/query/extent.cpp @@ -20,25 +20,7 @@ #include "../mocks/blocks.hpp" #include "../mocks/chunk_store.hpp" -struct query_extent_setup_fixture -{ - DELETE_COPY_MOVE(query_extent_setup_fixture); - BC_PUSH_WARNING(NO_THROW_IN_NOEXCEPT) - - query_extent_setup_fixture() NOEXCEPT - { - BOOST_REQUIRE(test::clear(test::directory)); - } - - ~query_extent_setup_fixture() NOEXCEPT - { - BOOST_REQUIRE(test::clear(test::directory)); - } - - BC_POP_WARNING() -}; - -BOOST_FIXTURE_TEST_SUITE(query_extent_tests, query_extent_setup_fixture) +BOOST_FIXTURE_TEST_SUITE(query_extent_tests, test::directory_setup_fixture) // nop event handler. const auto events_handler = [](auto, auto) {}; diff --git a/test/query/height.cpp b/test/query/height.cpp index 3b0352bf..7c0c2a24 100644 --- a/test/query/height.cpp +++ b/test/query/height.cpp @@ -20,25 +20,7 @@ #include "../mocks/blocks.hpp" #include "../mocks/chunk_store.hpp" -struct query_height_setup_fixture -{ - DELETE_COPY_MOVE(query_height_setup_fixture); - BC_PUSH_WARNING(NO_THROW_IN_NOEXCEPT) - - query_height_setup_fixture() NOEXCEPT - { - BOOST_REQUIRE(test::clear(test::directory)); - } - - ~query_height_setup_fixture() NOEXCEPT - { - BOOST_REQUIRE(test::clear(test::directory)); - } - - BC_POP_WARNING() -}; - -BOOST_FIXTURE_TEST_SUITE(query_height_tests, query_height_setup_fixture) +BOOST_FIXTURE_TEST_SUITE(query_height_tests, test::directory_setup_fixture) ////const auto events_handler = [](auto, auto) {}; diff --git a/test/query/initialize.cpp b/test/query/initialize.cpp index 40b7c8aa..b1f19fd7 100644 --- a/test/query/initialize.cpp +++ b/test/query/initialize.cpp @@ -20,25 +20,7 @@ #include "../mocks/blocks.hpp" #include "../mocks/chunk_store.hpp" -struct query_initialize_setup_fixture -{ - DELETE_COPY_MOVE(query_initialize_setup_fixture); - BC_PUSH_WARNING(NO_THROW_IN_NOEXCEPT) - - query_initialize_setup_fixture() NOEXCEPT - { - BOOST_REQUIRE(test::clear(test::directory)); - } - - ~query_initialize_setup_fixture() NOEXCEPT - { - BOOST_REQUIRE(test::clear(test::directory)); - } - - BC_POP_WARNING() -}; - -BOOST_FIXTURE_TEST_SUITE(query_initialize_tests, query_initialize_setup_fixture) +BOOST_FIXTURE_TEST_SUITE(query_initialize_tests, test::directory_setup_fixture) // nop event handler. const auto events_handler = [](auto, auto) {}; diff --git a/test/query/network.cpp b/test/query/network.cpp index 99026d28..3e895630 100644 --- a/test/query/network.cpp +++ b/test/query/network.cpp @@ -20,25 +20,7 @@ #include "../mocks/blocks.hpp" #include "../mocks/chunk_store.hpp" -struct query_network_setup_fixture -{ - DELETE_COPY_MOVE(query_network_setup_fixture); - BC_PUSH_WARNING(NO_THROW_IN_NOEXCEPT) - - query_network_setup_fixture() NOEXCEPT - { - BOOST_REQUIRE(test::clear(test::directory)); - } - - ~query_network_setup_fixture() NOEXCEPT - { - BOOST_REQUIRE(test::clear(test::directory)); - } - - BC_POP_WARNING() -}; - -BOOST_FIXTURE_TEST_SUITE(query_network_tests, query_network_setup_fixture) +BOOST_FIXTURE_TEST_SUITE(query_network_tests, test::directory_setup_fixture) ////const auto events_handler = [](auto, auto) {}; diff --git a/test/query/objects.cpp b/test/query/objects.cpp index c98dd1a4..9f265690 100644 --- a/test/query/objects.cpp +++ b/test/query/objects.cpp @@ -20,25 +20,7 @@ #include "../mocks/blocks.hpp" #include "../mocks/chunk_store.hpp" -struct query_objects_setup_fixture -{ - DELETE_COPY_MOVE(query_objects_setup_fixture); - BC_PUSH_WARNING(NO_THROW_IN_NOEXCEPT) - - query_objects_setup_fixture() NOEXCEPT - { - BOOST_REQUIRE(test::clear(test::directory)); - } - - ~query_objects_setup_fixture() NOEXCEPT - { - BOOST_REQUIRE(test::clear(test::directory)); - } - - BC_POP_WARNING() -}; - -BOOST_FIXTURE_TEST_SUITE(query_objects_tests, query_objects_setup_fixture) +BOOST_FIXTURE_TEST_SUITE(query_objects_tests, test::directory_setup_fixture) ////const auto events_handler = [](auto, auto) {}; diff --git a/test/query/optional.cpp b/test/query/optional.cpp index c1177557..13ff316e 100644 --- a/test/query/optional.cpp +++ b/test/query/optional.cpp @@ -20,25 +20,7 @@ #include "../mocks/blocks.hpp" #include "../mocks/chunk_store.hpp" -struct query_optional_setup_fixture -{ - DELETE_COPY_MOVE(query_optional_setup_fixture); - BC_PUSH_WARNING(NO_THROW_IN_NOEXCEPT) - - query_optional_setup_fixture() NOEXCEPT - { - BOOST_REQUIRE(test::clear(test::directory)); - } - - ~query_optional_setup_fixture() NOEXCEPT - { - BOOST_REQUIRE(test::clear(test::directory)); - } - - BC_POP_WARNING() -}; - -BOOST_FIXTURE_TEST_SUITE(query_optional_tests, query_optional_setup_fixture) +BOOST_FIXTURE_TEST_SUITE(query_optional_tests, test::directory_setup_fixture) // nop event handler. const auto events_handler = [](auto, auto) {}; diff --git a/test/query/translate.cpp b/test/query/translate.cpp index a379871a..11b3c22b 100644 --- a/test/query/translate.cpp +++ b/test/query/translate.cpp @@ -20,25 +20,7 @@ ////#include "../mocks/blocks.hpp" ////#include "../mocks/chunk_store.hpp" //// -////struct query_translate_setup_fixture -////{ -//// DELETE_COPY_MOVE(query_translate_setup_fixture); -//// BC_PUSH_WARNING(NO_THROW_IN_NOEXCEPT) -//// -//// query_translate_setup_fixture() NOEXCEPT -//// { -//// BOOST_REQUIRE(test::clear(test::directory)); -//// } -//// -//// ~query_translate_setup_fixture() NOEXCEPT -//// { -//// BOOST_REQUIRE(test::clear(test::directory)); -//// } -//// -//// BC_POP_WARNING() -////}; -//// -////BOOST_FIXTURE_TEST_SUITE(query_translate_tests, query_translate_setup_fixture) +////BOOST_FIXTURE_TEST_SUITE(query_translate_tests, test::directory_setup_fixture) //// ////// nop event handler. ////const auto events_handler = [](auto, auto) {}; diff --git a/test/query/validate.cpp b/test/query/validate.cpp index 45eb373e..de68e838 100644 --- a/test/query/validate.cpp +++ b/test/query/validate.cpp @@ -20,25 +20,7 @@ #include "../mocks/blocks.hpp" #include "../mocks/chunk_store.hpp" -struct query_validate_setup_fixture -{ - DELETE_COPY_MOVE(query_validate_setup_fixture); - BC_PUSH_WARNING(NO_THROW_IN_NOEXCEPT) - - query_validate_setup_fixture() NOEXCEPT - { - BOOST_REQUIRE(test::clear(test::directory)); - } - - ~query_validate_setup_fixture() NOEXCEPT - { - BOOST_REQUIRE(test::clear(test::directory)); - } - - BC_POP_WARNING() -}; - -BOOST_FIXTURE_TEST_SUITE(query_validate_tests, query_validate_setup_fixture) +BOOST_FIXTURE_TEST_SUITE(query_validate_tests, test::directory_setup_fixture) // nop event handler. const auto events_handler = [](auto, auto) {}; diff --git a/test/store.cpp b/test/store.cpp index 4522f138..f4fd5e06 100644 --- a/test/store.cpp +++ b/test/store.cpp @@ -20,27 +20,9 @@ #include "mocks/blocks.hpp" #include "mocks/map_store.hpp" - // these are the slow tests (mmap) +// these are the slow tests (mmap) -struct store_setup_fixture -{ - DELETE_COPY_MOVE(store_setup_fixture); - BC_PUSH_WARNING(NO_THROW_IN_NOEXCEPT) - - store_setup_fixture() NOEXCEPT - { - BOOST_REQUIRE(test::clear(test::directory)); - } - - ~store_setup_fixture() NOEXCEPT - { - BOOST_REQUIRE(test::clear(test::directory)); - } - - BC_POP_WARNING() -}; - -BOOST_FIXTURE_TEST_SUITE(store_tests, store_setup_fixture) +BOOST_FIXTURE_TEST_SUITE(store_tests, test::directory_setup_fixture) // nop event handler. const auto events = [](auto, auto){}; diff --git a/test/test.cpp b/test/test.cpp index dc7f1fb5..e9a7aab1 100644 --- a/test/test.cpp +++ b/test/test.cpp @@ -42,14 +42,14 @@ size_t size(const std::filesystem::path& file_path) NOEXCEPT // returns max_size_t on error. code ec; return system::possible_narrow_and_sign_cast( - std::filesystem::file_size(system::to_extended_path(file_path), ec)); + std::filesystem::file_size(system::extended_path(file_path), ec)); } bool exists(const std::filesystem::path& file_path) NOEXCEPT { // Returns true only if file existed. BC_PUSH_WARNING(NO_THROW_IN_NOEXCEPT) - std::ifstream file(system::to_extended_path(file_path)); + std::ifstream file(system::extended_path(file_path)); const auto good = file.good(); file.close(); BC_POP_WARNING() @@ -60,7 +60,7 @@ bool remove(const std::filesystem::path& file_path) NOEXCEPT { // Deletes and returns false if file did not exist (or error). code ec; - return std::filesystem::remove(system::to_extended_path(file_path), ec); + return std::filesystem::remove(system::extended_path(file_path), ec); } bool clear(const std::filesystem::path& directory) NOEXCEPT @@ -68,7 +68,7 @@ bool clear(const std::filesystem::path& directory) NOEXCEPT // remove_all returns count removed, and error code if fails. // create_directories returns true if path exists or created. // used for setup, with no expectations of file/directory existence. - const auto path = system::to_extended_path(directory); + const auto path = system::extended_path(directory); code ec; BC_PUSH_WARNING(NO_THROW_IN_NOEXCEPT) std::filesystem::remove_all(path, ec); @@ -78,7 +78,7 @@ bool clear(const std::filesystem::path& directory) NOEXCEPT bool folder(const std::filesystem::path& directory) NOEXCEPT { - const auto path = system::to_extended_path(directory); + const auto path = system::extended_path(directory); code ec; BC_PUSH_WARNING(NO_THROW_IN_NOEXCEPT) return !ec && std::filesystem::is_directory(path, ec); @@ -89,7 +89,7 @@ bool create(const std::filesystem::path& file_path) NOEXCEPT { // Creates and returns true if file existed or not (and no error). BC_PUSH_WARNING(NO_THROW_IN_NOEXCEPT) - std::ofstream file(system::to_extended_path(file_path)); + std::ofstream file(system::extended_path(file_path)); const auto good = file.good(); file.close(); BC_POP_WARNING() @@ -112,7 +112,7 @@ std::string read_line(const std::filesystem::path& file_path, size_t line) NOEXCEPT { std::string out{}; - std::ifstream file(system::to_extended_path(file_path)); + std::ifstream file(system::extended_path(file_path)); do { out.clear(); std::getline(file, out); } while (is_nonzero(line--)); return out; } diff --git a/test/test.hpp b/test/test.hpp index b204df16..aca5b40d 100644 --- a/test/test.hpp +++ b/test/test.hpp @@ -108,6 +108,20 @@ bool create(const std::filesystem::path& file_path, std::string read_line(const std::filesystem::path& file_path, size_t line = zero) NOEXCEPT; +struct directory_setup_fixture +{ + DELETE_COPY_MOVE(directory_setup_fixture); + + directory_setup_fixture() NOEXCEPT + { + BOOST_REQUIRE(clear(directory)); + } + ~directory_setup_fixture() NOEXCEPT + { + BOOST_REQUIRE(clear(directory)); + } +}; + } // namespace test #endif