libcxx

libcxx mirror with random patches
git clone https://git.neptards.moe/neptards/libcxx.git
Log | Files | Refs

enum.directory_options.pass.cpp (1370B)


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