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