enum.copy_options.pass.cpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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 copy_options;
  12. #include "filesystem_include.hpp"
  13. #include <type_traits>
  14. #include <cassert>
  15. #include "check_bitmask_types.hpp"
  16. #include "test_macros.h"
  17. constexpr fs::copy_options ME(int val) { return static_cast<fs::copy_options>(val); }
  18. int main() {
  19. typedef fs::copy_options E;
  20. static_assert(std::is_enum<E>::value, "");
  21. // Check that E is a scoped enum by checking for conversions.
  22. typedef std::underlying_type<E>::type UT;
  23. static_assert(!std::is_convertible<E, UT>::value, "");
  24. static_assert(std::is_same<UT, unsigned short>::value, ""); // Implementation detail
  25. typedef check_bitmask_type<E, E::skip_existing, E::update_existing> BitmaskTester;
  26. assert(BitmaskTester::check());
  27. static_assert(
  28. E::none == ME(0),
  29. "Expected enumeration values do not match");
  30. // Option group for copy_file
  31. static_assert(
  32. E::skip_existing == ME(1) &&
  33. E::overwrite_existing == ME(2) &&
  34. E::update_existing == ME(4),
  35. "Expected enumeration values do not match");
  36. // Option group for copy on directories
  37. static_assert(
  38. E::recursive == ME(8),
  39. "Expected enumeration values do not match");
  40. // Option group for copy on symlinks
  41. static_assert(
  42. E::copy_symlinks == ME(16) &&
  43. E::skip_symlinks == ME(32),
  44. "Expected enumeration values do not match");
  45. // Option group for changing form of copy
  46. static_assert(
  47. E::directories_only == ME(64) &&
  48. E::create_symlinks == ME(128) &&
  49. E::create_hard_links == ME(256),
  50. "Expected enumeration values do not match");
  51. }