summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/input.output/filesystems/fs.enum
diff options
context:
space:
mode:
Diffstat (limited to 'libcxx/test/std/input.output/filesystems/fs.enum')
-rw-r--r--libcxx/test/std/input.output/filesystems/fs.enum/check_bitmask_types.hpp75
-rw-r--r--libcxx/test/std/input.output/filesystems/fs.enum/enum.copy_options.pass.cpp63
-rw-r--r--libcxx/test/std/input.output/filesystems/fs.enum/enum.directory_options.pass.cpp45
-rw-r--r--libcxx/test/std/input.output/filesystems/fs.enum/enum.file_type.pass.cpp47
-rw-r--r--libcxx/test/std/input.output/filesystems/fs.enum/enum.path.format.pass.cpp38
-rw-r--r--libcxx/test/std/input.output/filesystems/fs.enum/enum.perm_options.pass.cpp48
-rw-r--r--libcxx/test/std/input.output/filesystems/fs.enum/enum.perms.pass.cpp64
7 files changed, 380 insertions, 0 deletions
diff --git a/libcxx/test/std/input.output/filesystems/fs.enum/check_bitmask_types.hpp b/libcxx/test/std/input.output/filesystems/fs.enum/check_bitmask_types.hpp
new file mode 100644
index 00000000000..77b136f3fca
--- /dev/null
+++ b/libcxx/test/std/input.output/filesystems/fs.enum/check_bitmask_types.hpp
@@ -0,0 +1,75 @@
+#ifndef TEST_BITMASK_TYPE_HPP
+#define TEST_BITMASK_TYPE_HPP
+
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+
+template <class EnumType, EnumType Val1, EnumType Val2,
+ class UT = typename std::underlying_type<EnumType>::type,
+ UT UVal1 = static_cast<UT>(Val1),
+ UT UVal2 = static_cast<UT>(Val2),
+ UT UZero = static_cast<UT>(0),
+ EnumType Zero = static_cast<EnumType>(0)
+ >
+struct check_bitmask_type {
+
+ static constexpr UT dcast(EnumType e) { return static_cast<UT>(e); }
+ static constexpr UT unpromote(decltype((~UZero)) promoted) { return static_cast<UT>(promoted); }
+ // We need two values that are non-zero and share at least one bit.
+ static_assert(Val1 != Zero && Val2 != Zero, "");
+ static_assert(Val1 != Val2, "");
+ static_assert((UVal1 & UVal2) == 0, "");
+
+
+ static bool check()
+ {
+ {
+ EnumType ValRef = Val1;
+ ASSERT_SAME_TYPE(EnumType, decltype(Val1 & Val2));
+ ASSERT_SAME_TYPE(EnumType, decltype(Val1 | Val2));
+ ASSERT_SAME_TYPE(EnumType, decltype(Val1 ^ Val2));
+ ASSERT_SAME_TYPE(EnumType, decltype((~Val1)));
+ ASSERT_SAME_TYPE(EnumType&, decltype(ValRef &= Val2));
+ ASSERT_SAME_TYPE(EnumType&, decltype(ValRef |= Val2));
+ ASSERT_SAME_TYPE(EnumType&, decltype(ValRef ^= Val2));
+ }
+
+ static_assert((Val1 & Zero) == Zero, "");
+ static_assert((Val1 & Val1) == Val1, "");
+ static_assert(dcast(Val1 & Val2) == (UVal1 & UVal2), "");
+
+ static_assert((Val1 | Zero) == Val1, "");
+ static_assert(dcast(Val1 | Val2) == (UVal1 | UVal2), "");
+
+ static_assert((Val1 ^ Zero) == Val1, "");
+ static_assert(dcast(Val1 ^ Val2) == (UVal1 ^ UVal2), "");
+
+ static_assert(dcast(~Zero) == unpromote(~UZero), "");
+ static_assert(dcast(~Val1) == unpromote(~UVal1), "");
+
+ {
+ EnumType e = Val1;
+ EnumType& eref = (e &= Val2);
+ assert(&eref == &e);
+ assert(dcast(eref) == (UVal1 & UVal2));
+ }
+ {
+ EnumType e = Val1;
+ EnumType& eref = (e |= Val2);
+ assert(&eref == &e);
+ assert(dcast(eref) == (UVal1 | UVal2));
+ }
+ {
+ EnumType e = Val1;
+ EnumType& eref = (e ^= Val2);
+ assert(&eref == &e);
+ assert(dcast(eref) == (UVal1 ^ UVal2));
+ }
+ return true;
+ }
+};
+
+#endif // TEST_BITMASK_TYPE
diff --git a/libcxx/test/std/input.output/filesystems/fs.enum/enum.copy_options.pass.cpp b/libcxx/test/std/input.output/filesystems/fs.enum/enum.copy_options.pass.cpp
new file mode 100644
index 00000000000..75477309fae
--- /dev/null
+++ b/libcxx/test/std/input.output/filesystems/fs.enum/enum.copy_options.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+
+// <filesystem>
+
+// enum class copy_options;
+
+#include "filesystem_include.hpp"
+#include <type_traits>
+#include <cassert>
+
+#include "check_bitmask_types.hpp"
+#include "test_macros.h"
+
+
+constexpr fs::copy_options ME(int val) { return static_cast<fs::copy_options>(val); }
+
+int main() {
+ typedef fs::copy_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 short>::value, ""); // Implementation detail
+
+ typedef check_bitmask_type<E, E::skip_existing, E::update_existing> BitmaskTester;
+ assert(BitmaskTester::check());
+
+ static_assert(
+ E::none == ME(0),
+ "Expected enumeration values do not match");
+ // Option group for copy_file
+ static_assert(
+ E::skip_existing == ME(1) &&
+ E::overwrite_existing == ME(2) &&
+ E::update_existing == ME(4),
+ "Expected enumeration values do not match");
+ // Option group for copy on directories
+ static_assert(
+ E::recursive == ME(8),
+ "Expected enumeration values do not match");
+ // Option group for copy on symlinks
+ static_assert(
+ E::copy_symlinks == ME(16) &&
+ E::skip_symlinks == ME(32),
+ "Expected enumeration values do not match");
+ // Option group for changing form of copy
+ static_assert(
+ E::directories_only == ME(64) &&
+ E::create_symlinks == ME(128) &&
+ E::create_hard_links == ME(256),
+ "Expected enumeration values do not match");
+}
diff --git a/libcxx/test/std/input.output/filesystems/fs.enum/enum.directory_options.pass.cpp b/libcxx/test/std/input.output/filesystems/fs.enum/enum.directory_options.pass.cpp
new file mode 100644
index 00000000000..db40f6de91b
--- /dev/null
+++ b/libcxx/test/std/input.output/filesystems/fs.enum/enum.directory_options.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+
+// <filesystem>
+
+// enum class directory_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::directory_options ME(int val) { return static_cast<fs::directory_options>(val); }
+
+int main() {
+ typedef fs::directory_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, "");
+
+ typedef check_bitmask_type<E, E::follow_directory_symlink, E::skip_permission_denied> BitmaskTester;
+ assert(BitmaskTester::check());
+
+ static_assert(
+ E::none == ME(0) &&
+ E::follow_directory_symlink == ME(1) &&
+ E::skip_permission_denied == ME(2),
+ "Expected enumeration values do not match");
+
+}
diff --git a/libcxx/test/std/input.output/filesystems/fs.enum/enum.file_type.pass.cpp b/libcxx/test/std/input.output/filesystems/fs.enum/enum.file_type.pass.cpp
new file mode 100644
index 00000000000..899ab682042
--- /dev/null
+++ b/libcxx/test/std/input.output/filesystems/fs.enum/enum.file_type.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+
+// <filesystem>
+
+// enum class file_type;
+
+#include "filesystem_include.hpp"
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+
+constexpr fs::file_type ME(int val) { return static_cast<fs::file_type>(val); }
+
+int main() {
+ typedef fs::file_type 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, signed char>::value, ""); // Implementation detail
+
+ static_assert(
+ E::none == ME(0) &&
+ E::not_found == ME(-1) &&
+ E::regular == ME(1) &&
+ E::directory == ME(2) &&
+ E::symlink == ME(3) &&
+ E::block == ME(4) &&
+ E::character == ME(5) &&
+ E::fifo == ME(6) &&
+ E::socket == ME(7) &&
+ E::unknown == ME(8),
+ "Expected enumeration values do not match");
+}
diff --git a/libcxx/test/std/input.output/filesystems/fs.enum/enum.path.format.pass.cpp b/libcxx/test/std/input.output/filesystems/fs.enum/enum.path.format.pass.cpp
new file mode 100644
index 00000000000..d4ec48e8480
--- /dev/null
+++ b/libcxx/test/std/input.output/filesystems/fs.enum/enum.path.format.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+
+// <filesystem>
+
+// class path;
+// enum class format;
+
+#include "filesystem_include.hpp"
+#include <type_traits>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main() {
+ typedef fs::path::format 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, "");
+
+ LIBCPP_ONLY(static_assert(std::is_same<UT, unsigned char>::value, "")); // Implementation detail
+
+ static_assert(
+ E::auto_format != E::native_format &&
+ E::auto_format != E::generic_format &&
+ E::native_format != E::generic_format,
+ "Expected enumeration values are not unique");
+}
diff --git a/libcxx/test/std/input.output/filesystems/fs.enum/enum.perm_options.pass.cpp b/libcxx/test/std/input.output/filesystems/fs.enum/enum.perm_options.pass.cpp
new file mode 100644
index 00000000000..5af504530de
--- /dev/null
+++ b/libcxx/test/std/input.output/filesystems/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
+
+// <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");
+}
diff --git a/libcxx/test/std/input.output/filesystems/fs.enum/enum.perms.pass.cpp b/libcxx/test/std/input.output/filesystems/fs.enum/enum.perms.pass.cpp
new file mode 100644
index 00000000000..9f2e4e214be
--- /dev/null
+++ b/libcxx/test/std/input.output/filesystems/fs.enum/enum.perms.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+
+// <filesystem>
+
+// enum class perms;
+
+#include "filesystem_include.hpp"
+#include <type_traits>
+#include <cassert>
+#include <sys/stat.h>
+
+#include "test_macros.h"
+#include "check_bitmask_types.hpp"
+
+
+constexpr fs::perms ME(int val) { return static_cast<fs::perms>(val); }
+
+int main() {
+ typedef fs::perms 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 >::value, ""); // Implementation detail
+
+ typedef check_bitmask_type<E, E::group_all, E::owner_all> BitmaskTester;
+ assert(BitmaskTester::check());
+
+ static_assert(
+ E::none == ME(0) &&
+
+ E::owner_read == ME(0400) &&
+ E::owner_write == ME(0200) &&
+ E::owner_exec == ME(0100) &&
+ E::owner_all == ME(0700) &&
+
+ E::group_read == ME(040) &&
+ E::group_write == ME(020) &&
+ E::group_exec == ME(010) &&
+ E::group_all == ME(070) &&
+
+ E::others_read == ME(04) &&
+ E::others_write == ME(02) &&
+ E::others_exec == ME(01) &&
+ E::others_all == ME(07) &&
+ E::all == ME(0777) &&
+ E::set_uid == ME(04000) &&
+ E::set_gid == ME(02000) &&
+ E::sticky_bit == ME(01000) &&
+ E::mask == ME(07777) &&
+ E::unknown == ME(0xFFFF),
+ "Expected enumeration values do not match");
+}
OpenPOWER on IntegriCloud