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