65 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8 9// UNSUPPORTED: c++03, c++11, c++1410 11// <filesystem>12 13// enum class perms;14 15#include <filesystem>16#include <type_traits>17#include <cassert>18 19#include "test_macros.h"20#include "check_bitmask_types.h"21namespace fs = std::filesystem;22 23constexpr fs::perms ME(int val) { return static_cast<fs::perms>(val); }24 25int main(int, char**) {26 typedef fs::perms 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 >::value, ""); // Implementation detail34 35 typedef check_bitmask_type<E, E::group_all, E::owner_all> BitmaskTester;36 assert(BitmaskTester::check());37 38 static_assert(39 E::none == ME(0) &&40 41 E::owner_read == ME(0400) &&42 E::owner_write == ME(0200) &&43 E::owner_exec == ME(0100) &&44 E::owner_all == ME(0700) &&45 46 E::group_read == ME(040) &&47 E::group_write == ME(020) &&48 E::group_exec == ME(010) &&49 E::group_all == ME(070) &&50 51 E::others_read == ME(04) &&52 E::others_write == ME(02) &&53 E::others_exec == ME(01) &&54 E::others_all == ME(07) &&55 E::all == ME(0777) &&56 E::set_uid == ME(04000) &&57 E::set_gid == ME(02000) &&58 E::sticky_bit == ME(01000) &&59 E::mask == ME(07777) &&60 E::unknown == ME(0xFFFF),61 "Expected enumeration values do not match");62 63 return 0;64}65