Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/windirstat/llfio.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiall Douglas (s [underscore] sourceforge {at} nedprod [dot] com) <spamtrap@nedprod.com>2017-09-18 03:06:59 +0300
committerNiall Douglas (s [underscore] sourceforge {at} nedprod [dot] com) <spamtrap@nedprod.com>2017-09-18 03:06:59 +0300
commit60965da727d7447b4724e64083e0d939764b1336 (patch)
treed564f89fa73230ddb2b92730c7ea8aab9d43425e /test/tests/current_path.cpp
parenta8fd33814a0e858621940d3f91a82457b73e0a53 (diff)
Added a new free function construct<T>() through which handle implementations register their static constructor functions.
Added a new algorithm adapting any handle implementation to cache its parent handle in a process wide registry.
Diffstat (limited to 'test/tests/current_path.cpp')
-rw-r--r--test/tests/current_path.cpp149
1 files changed, 82 insertions, 67 deletions
diff --git a/test/tests/current_path.cpp b/test/tests/current_path.cpp
index 29c98c16..c5aa9ec7 100644
--- a/test/tests/current_path.cpp
+++ b/test/tests/current_path.cpp
@@ -25,83 +25,98 @@ Distributed under the Boost Software License, Version 1.0.
#include "../../include/afio/afio.hpp"
#include "kerneltest/include/kerneltest.hpp"
-static inline void TestHandleCurrentPath()
+template <class FileHandleType, class DirectoryHandleType> static inline void TestHandleCurrentPath()
{
namespace afio = AFIO_V2_NAMESPACE;
- afio::file_handle h1 = afio::file_handle::file({}, "tempfile", afio::file_handle::mode::write, afio::file_handle::creation::if_needed, afio::file_handle::caching::temporary, afio::file_handle::flag::unlink_on_close).value();
- afio::directory_handle h2 = afio::directory_handle::directory({}, "tempdir", afio::file_handle::mode::write, afio::file_handle::creation::if_needed, afio::file_handle::caching::temporary, afio::file_handle::flag::unlink_on_close).value();
-
- {
- auto h1path=h1.current_path();
- BOOST_CHECK(h1path);
- if(!h1path)
- {
- std::cerr << "Getting the current path of a file FAILED due to " << h1path.error().message() << std::endl;
- }
- else if(h1path.value().empty())
- {
- BOOST_CHECK(!h1path.value().empty());
- std::cerr << "Getting the current path of a file FAILED due to the returned path being empty" << std::endl;
- }
- else
- {
- std::cout << "The path of the file is " << h1path.value() << std::endl;
- }
-
- auto h2path=h2.current_path();
- BOOST_CHECK(h2path);
- if(!h2path)
{
- std::cerr << "Getting the current path of a directory FAILED due to " << h2path.error().message() << std::endl;
+ std::error_code ec;
+ afio::filesystem::remove_all("tempfile", ec);
+ afio::filesystem::remove_all("tempfile2", ec);
+ afio::filesystem::remove_all("tempdir", ec);
+ afio::filesystem::remove_all("tempdir2", ec);
}
- else if(h2path.value().empty())
- {
- BOOST_CHECK(!h2path.value().empty());
- std::cerr << "Getting the current path of a directory FAILED due to the returned path being empty" << std::endl;
- }
- else
+#ifdef __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wmissing-braces"
+#endif
+ FileHandleType h1 = afio::construct<FileHandleType>{afio::path_handle(), "tempfile", afio::file_handle::mode::write, afio::file_handle::creation::if_needed, afio::file_handle::caching::temporary, afio::file_handle::flag::unlink_on_close}().value(); // NOLINT
+ DirectoryHandleType h2 = afio::construct<DirectoryHandleType>{afio::path_handle(), "tempdir", afio::file_handle::mode::write, afio::file_handle::creation::if_needed, afio::file_handle::caching::all, afio::file_handle::flag::unlink_on_close}().value(); // NOLINT
+#ifdef __clang__
+#pragma clang diagnostic pop
+#endif
+
{
- std::cout << "The path of the directory is " << h2path.value() << std::endl;
- }
+ auto h1path = h1.current_path();
+ BOOST_CHECK(h1path);
+ if(!h1path)
+ {
+ std::cerr << "Getting the current path of a file FAILED due to " << h1path.error().message() << std::endl;
+ }
+ else if(h1path.value().empty())
+ {
+ BOOST_CHECK(!h1path.value().empty());
+ std::cerr << "Getting the current path of a file FAILED due to the returned path being empty" << std::endl;
+ }
+ else
+ {
+ std::cout << "The path of the file is " << h1path.value() << std::endl;
+ }
+
+ auto h2path = h2.current_path();
+ BOOST_CHECK(h2path);
+ if(!h2path)
+ {
+ std::cerr << "Getting the current path of a directory FAILED due to " << h2path.error().message() << std::endl;
+ }
+ else if(h2path.value().empty())
+ {
+ BOOST_CHECK(!h2path.value().empty());
+ std::cerr << "Getting the current path of a directory FAILED due to the returned path being empty" << std::endl;
+ }
+ else
+ {
+ std::cout << "The path of the directory is " << h2path.value() << std::endl;
+ }
}
-
+
h1.relink({}, "tempfile2").value();
h2.relink({}, "tempdir2").value();
- {
- auto h1path=h1.current_path();
- BOOST_CHECK(h1path);
- if(!h1path)
{
- std::cerr << "Getting the current path of a file FAILED due to " << h1path.error().message() << std::endl;
- }
- else if(h1path.value().empty())
- {
- BOOST_CHECK(!h1path.value().empty());
- std::cerr << "Getting the current path of a file FAILED due to the returned path being empty" << std::endl;
- }
- else
- {
- std::cout << "The path of the file is " << h1path.value() << std::endl;
- }
-
- auto h2path=h2.current_path();
- BOOST_CHECK(h2path);
- if(!h2path)
- {
- std::cerr << "Getting the current path of a directory FAILED due to " << h2path.error().message() << std::endl;
- }
- else if(h2path.value().empty())
- {
- BOOST_CHECK(!h2path.value().empty());
- std::cerr << "Getting the current path of a directory FAILED due to the returned path being empty" << std::endl;
- }
- else
- {
- std::cout << "The path of the directory is " << h2path.value() << std::endl;
- }
+ auto h1path = h1.current_path();
+ BOOST_CHECK(h1path);
+ if(!h1path)
+ {
+ std::cerr << "Getting the current path of a file FAILED due to " << h1path.error().message() << std::endl;
+ }
+ else if(h1path.value().empty())
+ {
+ BOOST_CHECK(!h1path.value().empty());
+ std::cerr << "Getting the current path of a file FAILED due to the returned path being empty" << std::endl;
+ }
+ else
+ {
+ std::cout << "The path of the file is " << h1path.value() << std::endl;
+ }
+
+ auto h2path = h2.current_path();
+ BOOST_CHECK(h2path);
+ if(!h2path)
+ {
+ std::cerr << "Getting the current path of a directory FAILED due to " << h2path.error().message() << std::endl;
+ }
+ else if(h2path.value().empty())
+ {
+ BOOST_CHECK(!h2path.value().empty());
+ std::cerr << "Getting the current path of a directory FAILED due to the returned path being empty" << std::endl;
+ }
+ else
+ {
+ std::cout << "The path of the directory is " << h2path.value() << std::endl;
+ }
}
-
}
-KERNELTEST_TEST_KERNEL(integration, afio, current_path, handle, "Tests that afio::handle::current_path() works as expected", TestHandleCurrentPath())
+KERNELTEST_TEST_KERNEL(integration, afio, current_path, handle, "Tests that afio::handle::current_path() works as expected", TestHandleCurrentPath<AFIO_V2_NAMESPACE::file_handle, AFIO_V2_NAMESPACE::directory_handle>())
+KERNELTEST_TEST_KERNEL(integration, afio, current_path, cached_parent_handle_adapter, "Tests that afio::cached_parent_handle_adapter::current_path() works as expected",
+ TestHandleCurrentPath<AFIO_V2_NAMESPACE::algorithm::cached_parent_handle_adapter<AFIO_V2_NAMESPACE::file_handle>, AFIO_V2_NAMESPACE::algorithm::cached_parent_handle_adapter<AFIO_V2_NAMESPACE::directory_handle>>())