Home | History | Annotate | Download | only in fs.enum
      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 // <experimental/filesystem>
     13 
     14 // enum class directory_options;
     15 
     16 #include <experimental/filesystem>
     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 namespace fs = std::experimental::filesystem;
     25 
     26 constexpr fs::directory_options ME(int val) { return static_cast<fs::directory_options>(val); }
     27 
     28 int main() {
     29   typedef fs::directory_options E;
     30   static_assert(std::is_enum<E>::value, "");
     31 
     32   // Check that E is a scoped enum by checking for conversions.
     33   typedef std::underlying_type<E>::type UT;
     34   static_assert(!std::is_convertible<E, UT>::value, "");
     35   static_assert(std::is_same<UT, unsigned char>::value, "");
     36 
     37   typedef check_bitmask_type<E, E::follow_directory_symlink, E::skip_permission_denied> BitmaskTester;
     38   assert(BitmaskTester::check());
     39 
     40   static_assert(
     41         E::none                     == ME(0) &&
     42         E::follow_directory_symlink == ME(1) &&
     43         E::skip_permission_denied   == ME(2),
     44         "Expected enumeration values do not match");
     45 
     46 }
     47