enum.copy_options.pass.cpp 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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 <experimental/filesystem>
  13. #include <type_traits>
  14. #include <cassert>
  15. #include "check_bitmask_types.hpp"
  16. #include "test_macros.h"
  17. namespace fs = std::experimental::filesystem;
  18. constexpr fs::copy_options ME(int val) { return static_cast<fs::copy_options>(val); }
  19. int main() {
  20. typedef fs::copy_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 short>::value, ""); // Implementation detail
  26. typedef check_bitmask_type<E, E::skip_existing, E::update_existing> BitmaskTester;
  27. assert(BitmaskTester::check());
  28. static_assert(
  29. E::none == ME(0),
  30. "Expected enumeration values do not match");
  31. // Option group for copy_file
  32. static_assert(
  33. E::skip_existing == ME(1) &&
  34. E::overwrite_existing == ME(2) &&
  35. E::update_existing == ME(4),
  36. "Expected enumeration values do not match");
  37. // Option group for copy on directories
  38. static_assert(
  39. E::recursive == ME(8),
  40. "Expected enumeration values do not match");
  41. // Option group for copy on symlinks
  42. static_assert(
  43. E::copy_symlinks == ME(16) &&
  44. E::skip_symlinks == ME(32),
  45. "Expected enumeration values do not match");
  46. // Option group for changing form of copy
  47. static_assert(
  48. E::directories_only == ME(64) &&
  49. E::create_symlinks == ME(128) &&
  50. E::create_hard_links == ME(256),
  51. "Expected enumeration values do not match");
  52. }