enum.directory_options.pass.cpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. //===----------------------------------------------------------------------===//
  2. //
  3. // The LLVM Compiler Infrastructure
  4. //
  5. // This file is dual licensed under the MIT and the University of Illinois Open
  6. // Source Licenses. See LICENSE.TXT for details.
  7. //
  8. //===----------------------------------------------------------------------===//
  9. // UNSUPPORTED: c++98, c++03
  10. // <experimental/filesystem>
  11. // enum class directory_options;
  12. #include "filesystem_include.hpp"
  13. #include <type_traits>
  14. #include <cassert>
  15. #include <sys/stat.h>
  16. #include "test_macros.h"
  17. #include "check_bitmask_types.hpp"
  18. constexpr fs::directory_options ME(int val) { return static_cast<fs::directory_options>(val); }
  19. int main() {
  20. typedef fs::directory_options E;
  21. static_assert(std::is_enum<E>::value, "");
  22. // Check that E is a scoped enum by checking for conversions.
  23. typedef std::underlying_type<E>::type UT;
  24. static_assert(!std::is_convertible<E, UT>::value, "");
  25. static_assert(std::is_same<UT, unsigned char>::value, "");
  26. typedef check_bitmask_type<E, E::follow_directory_symlink, E::skip_permission_denied> BitmaskTester;
  27. assert(BitmaskTester::check());
  28. static_assert(
  29. E::none == ME(0) &&
  30. E::follow_directory_symlink == ME(1) &&
  31. E::skip_permission_denied == ME(2),
  32. "Expected enumeration values do not match");
  33. }