enum.directory_options.pass.cpp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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 <experimental/filesystem>
  13. #include <type_traits>
  14. #include <cassert>
  15. #include <sys/stat.h>
  16. #include "test_macros.h"
  17. #include "check_bitmask_types.hpp"
  18. namespace fs = std::experimental::filesystem;
  19. constexpr fs::directory_options ME(int val) { return static_cast<fs::directory_options>(val); }
  20. int main() {
  21. typedef fs::directory_options E;
  22. static_assert(std::is_enum<E>::value, "");
  23. // Check that E is a scoped enum by checking for conversions.
  24. typedef std::underlying_type<E>::type UT;
  25. static_assert(!std::is_convertible<E, UT>::value, "");
  26. static_assert(std::is_same<UT, unsigned char>::value, "");
  27. typedef check_bitmask_type<E, E::follow_directory_symlink, E::skip_permission_denied> BitmaskTester;
  28. assert(BitmaskTester::check());
  29. static_assert(
  30. E::none == ME(0) &&
  31. E::follow_directory_symlink == ME(1) &&
  32. E::skip_permission_denied == ME(2),
  33. "Expected enumeration values do not match");
  34. }