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++03, c++11, c++14 |
10 | |
11 | // <filesystem> |
12 | |
13 | // enum class copy_options; |
14 | |
15 | #include <filesystem> |
16 | #include <type_traits> |
17 | #include <cassert> |
18 | |
19 | #include "check_bitmask_types.h" |
20 | #include "test_macros.h" |
21 | namespace fs = std::filesystem; |
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 | LIBCPP_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 | // The standard doesn't specify the numeric values of the enum. |
39 | LIBCPP_STATIC_ASSERT( |
40 | E::none == ME(val: 0), |
41 | "Expected enumeration values do not match" ); |
42 | // Option group for copy_file |
43 | LIBCPP_STATIC_ASSERT( |
44 | E::skip_existing == ME(val: 1) && |
45 | E::overwrite_existing == ME(val: 2) && |
46 | E::update_existing == ME(val: 4), |
47 | "Expected enumeration values do not match" ); |
48 | // Option group for copy on directories |
49 | LIBCPP_STATIC_ASSERT( |
50 | E::recursive == ME(val: 8), |
51 | "Expected enumeration values do not match" ); |
52 | // Option group for copy on symlinks |
53 | LIBCPP_STATIC_ASSERT( |
54 | E::copy_symlinks == ME(val: 16) && |
55 | E::skip_symlinks == ME(val: 32), |
56 | "Expected enumeration values do not match" ); |
57 | // Option group for changing form of copy |
58 | LIBCPP_STATIC_ASSERT( |
59 | E::directories_only == ME(val: 64) && |
60 | E::create_symlinks == ME(val: 128) && |
61 | E::create_hard_links == ME(val: 256), |
62 | "Expected enumeration values do not match" ); |
63 | |
64 | return 0; |
65 | } |
66 | |