summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/experimental/filesystem/fs.enum/enum.perm_options.pass.cpp
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2018-04-02 23:03:41 +0000
committerEric Fiselier <eric@efcs.ca>2018-04-02 23:03:41 +0000
commitd7fae181c3954886257fb33d0a57b954b26da745 (patch)
tree841df55a810bc7446cf7afdd6811b3f1d79a3fc8 /libcxx/test/std/experimental/filesystem/fs.enum/enum.perm_options.pass.cpp
parent298ffc609bf5c67079dbeb77e3f75e5bc18fde7a (diff)
downloadbcm5719-llvm-d7fae181c3954886257fb33d0a57b954b26da745.tar.gz
bcm5719-llvm-d7fae181c3954886257fb33d0a57b954b26da745.zip
Implement filesystem NB comments, relative paths, and related issues.
This is a fairly large patch that implements all of the filesystem NB comments and the relative paths changes (ex. adding weakly_canonical). These issues and papers are all interrelated so their implementation couldn't be split up nicely. This patch upgrades <experimental/filesystem> to match the C++17 spec and not the published experimental TS spec. Some of the changes in this patch are both API and ABI breaking, however libc++ makes no guarantee about stability for experimental implementations. The major changes in this patch are: * Implement NB comments for filesystem (P0492R2), including: * Implement `perm_options` enum as part of NB comments, and update the `permissions` function to match. * Implement changes to `remove_filename` and `replace_filename` * Implement changes to `path::stem()` and `path::extension()` which support splitting examples like `.profile`. * Change path iteration to return an empty path instead of '.' for trailing separators. * Change `operator/=` to handle absolute paths on the RHS. * Change `absolute` to no longer accept a current path argument. * Implement relative paths according to NB comments (P0219r1) * Combine `path.cpp` and `operations.cpp` since some path functions require access to the operations internals, and some fs operations require access to the path parser. llvm-svn: 329028
Diffstat (limited to 'libcxx/test/std/experimental/filesystem/fs.enum/enum.perm_options.pass.cpp')
-rw-r--r--libcxx/test/std/experimental/filesystem/fs.enum/enum.perm_options.pass.cpp48
1 files changed, 48 insertions, 0 deletions
diff --git a/libcxx/test/std/experimental/filesystem/fs.enum/enum.perm_options.pass.cpp b/libcxx/test/std/experimental/filesystem/fs.enum/enum.perm_options.pass.cpp
new file mode 100644
index 00000000000..c1066b63ba3
--- /dev/null
+++ b/libcxx/test/std/experimental/filesystem/fs.enum/enum.perm_options.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03
+
+// <experimental/filesystem>
+
+// enum class perm_options;
+
+#include "filesystem_include.hpp"
+#include <type_traits>
+#include <cassert>
+#include <sys/stat.h>
+
+#include "test_macros.h"
+#include "check_bitmask_types.hpp"
+
+
+constexpr fs::perm_options ME(int val) {
+ return static_cast<fs::perm_options>(val);
+}
+
+int main() {
+ typedef fs::perm_options E;
+ static_assert(std::is_enum<E>::value, "");
+
+ // Check that E is a scoped enum by checking for conversions.
+ typedef std::underlying_type<E>::type UT;
+ static_assert(!std::is_convertible<E, UT>::value, "");
+
+ static_assert(std::is_same<UT, unsigned char >::value, ""); // Implementation detail
+
+ typedef check_bitmask_type<E, E::replace, E::nofollow> BitmaskTester;
+ assert(BitmaskTester::check());
+
+ static_assert(
+ E::replace == ME(1) &&
+ E::add == ME(2) &&
+ E::remove == ME(4) &&
+ E::nofollow == ME(8),
+ "Expected enumeration values do not match");
+}
OpenPOWER on IntegriCloud