xref: /llvm-project/libcxx/test/std/input.output/filesystems/fs.enum/enum.directory_options.pass.cpp (revision 57b08b0944046a6a57ee9b7b479181f548a5b9b4)
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 directory_options;
14 
15 #include "filesystem_include.hpp"
16 #include <type_traits>
17 #include <cassert>
18 #include <sys/stat.h>
19 
20 #include "test_macros.h"
21 #include "check_bitmask_types.hpp"
22 
23 
24 constexpr fs::directory_options ME(int val) { return static_cast<fs::directory_options>(val); }
25 
26 int main() {
27   typedef fs::directory_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   static_assert(std::is_same<UT, unsigned char>::value, "");
34 
35   typedef check_bitmask_type<E, E::follow_directory_symlink, E::skip_permission_denied> BitmaskTester;
36   assert(BitmaskTester::check());
37 
38   static_assert(
39         E::none                     == ME(0) &&
40         E::follow_directory_symlink == ME(1) &&
41         E::skip_permission_denied   == ME(2),
42         "Expected enumeration values do not match");
43 
44 }
45