xref: /llvm-project/libcxx/test/std/input.output/filesystems/fs.enum/enum.copy_options.pass.cpp (revision cc89063bff0f73ec7049a1dcb5d4688ae6806941)
1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 // UNSUPPORTED: c++98, c++03
10 
11 // <filesystem>
12 
13 // enum class copy_options;
14 
15 #include "filesystem_include.h"
16 #include <type_traits>
17 #include <cassert>
18 
19 #include "check_bitmask_types.hpp"
20 #include "test_macros.h"
21 
22 
23 constexpr fs::copy_options ME(int val) { return static_cast<fs::copy_options>(val); }
24 
25 int main(int, char**) {
26   typedef fs::copy_options E;
27   static_assert(std::is_enum<E>::value, "");
28 
29   // Check that E is a scoped enum by checking for conversions.
30   typedef std::underlying_type<E>::type UT;
31   static_assert(!std::is_convertible<E, UT>::value, "");
32 
33   static_assert(std::is_same<UT, unsigned short>::value, ""); // Implementation detail
34 
35   typedef check_bitmask_type<E, E::skip_existing, E::update_existing> BitmaskTester;
36   assert(BitmaskTester::check());
37 
38   static_assert(
39           E::none == ME(0),
40         "Expected enumeration values do not match");
41   // Option group for copy_file
42   static_assert(
43           E::skip_existing      == ME(1) &&
44           E::overwrite_existing == ME(2) &&
45           E::update_existing    == ME(4),
46         "Expected enumeration values do not match");
47   // Option group for copy on directories
48   static_assert(
49           E::recursive == ME(8),
50         "Expected enumeration values do not match");
51   // Option group for copy on symlinks
52   static_assert(
53           E::copy_symlinks == ME(16) &&
54           E::skip_symlinks == ME(32),
55         "Expected enumeration values do not match");
56   // Option group for changing form of copy
57   static_assert(
58           E::directories_only    == ME(64) &&
59           E::create_symlinks     == ME(128) &&
60           E::create_hard_links   == ME(256),
61         "Expected enumeration values do not match");
62 
63   return 0;
64 }
65