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
10 
11 // <filesystem>
12 
13 // enum class file_type;
14 
15 #include "filesystem_include.h"
16 #include <type_traits>
17 #include <cassert>
18 
19 #include "test_macros.h"
20 
21 
ME(int val)22 constexpr fs::file_type ME(int val) { return static_cast<fs::file_type>(val); }
23 
main(int,char **)24 int main(int, char**) {
25   typedef fs::file_type E;
26   static_assert(std::is_enum<E>::value, "");
27 
28   // Check that E is a scoped enum by checking for conversions.
29   typedef std::underlying_type<E>::type UT;
30   static_assert(!std::is_convertible<E, UT>::value, "");
31 
32   LIBCPP_ONLY(static_assert(std::is_same<UT, signed char>::value, "")); // Implementation detail
33 
34   // The standard doesn't specify the numeric values of the enum.
35   LIBCPP_STATIC_ASSERT(
36           E::none == ME(0) &&
37           E::not_found == ME(-1) &&
38           E::regular == ME(1) &&
39           E::directory == ME(2) &&
40           E::symlink == ME(3) &&
41           E::block == ME(4) &&
42           E::character == ME(5) &&
43           E::fifo == ME(6) &&
44           E::socket == ME(7) &&
45           E::unknown == ME(8),
46         "Expected enumeration values do not match");
47 
48   return 0;
49 }
50