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
path: root/test
diff options
context:
space:
mode:
authorNiall Douglas (s [underscore] sourceforge {at} nedprod [dot] com) <spamtrap@nedprod.com>2020-11-12 00:27:28 +0300
committerNiall Douglas (s [underscore] sourceforge {at} nedprod [dot] com) <spamtrap@nedprod.com>2020-11-12 00:27:28 +0300
commit62317039b79f744f865e3eea04cbf6e6dcc0df38 (patch)
tree8b24cb8e50b80a7456aa3c258fe20493389fdc19 /test
parentf8b690df540b34b83fe3bf9f340c93ae1d77039a (diff)
Rework how path_view::c_str's constructors are implemented to work around this weird bug only seen on clang with libstdc++ where the c_str() constructor never delegates. Now no c_str() constructor delegates to any other, which surely will fix this bug.
Diffstat (limited to 'test')
-rw-r--r--test/tests/path_view.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/test/tests/path_view.cpp b/test/tests/path_view.cpp
index 0f6e18d4..771cf628 100644
--- a/test/tests/path_view.cpp
+++ b/test/tests/path_view.cpp
@@ -284,6 +284,30 @@ static inline void TestPathView()
BOOST_CHECK(zbuff.allocator().deleted == 1);
BOOST_CHECK(zbuff.allocator().sig == 5);
}
+ // Default custom allocator
+ {
+ struct custom_allocator
+ {
+ int sig{0};
+ using value_type = char;
+ int allocated{0}, deleted{0};
+ value_type *allocate(size_t /*unused*/)
+ {
+ allocated++;
+ static char buff[4];
+ return buff;
+ }
+ void deallocate(void * /*unused*/, size_t /*unused*/) { deleted++; }
+ } allocator{5};
+ llfio::path_view v("foo", 3, llfio::path_view::not_zero_terminated);
+ llfio::path_view::c_str<char, custom_allocator, 0> zbuff(v, llfio::path_view::zero_terminated);
+ zbuff.reset();
+ BOOST_CHECK(allocator.allocated == 0); // copy must be taken
+ BOOST_CHECK(allocator.deleted == 0); // copy must be taken
+ BOOST_CHECK(zbuff.allocator().allocated == 1);
+ BOOST_CHECK(zbuff.allocator().deleted == 1);
+ BOOST_CHECK(zbuff.allocator().sig == 0); // default initialised
+ }
}
KERNELTEST_TEST_KERNEL(integration, llfio, path_view, path_view, "Tests that llfio::path_view() works as expected", TestPathView())