brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.2 KiB · 4ef28ee Raw
66 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 copy_options;14 15#include <filesystem>16#include <type_traits>17#include <cassert>18 19#include "check_bitmask_types.h"20#include "test_macros.h"21namespace fs = std::filesystem;22 23constexpr fs::copy_options ME(int val) { return static_cast<fs::copy_options>(val); }24 25int main(int, char**) {26  typedef fs::copy_options 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 short>::value, ""); // Implementation detail34 35  typedef check_bitmask_type<E, E::skip_existing, E::update_existing> BitmaskTester;36  assert(BitmaskTester::check());37 38  // The standard doesn't specify the numeric values of the enum.39  LIBCPP_STATIC_ASSERT(40          E::none == ME(0),41        "Expected enumeration values do not match");42  // Option group for copy_file43  LIBCPP_STATIC_ASSERT(44          E::skip_existing      == ME(1) &&45          E::overwrite_existing == ME(2) &&46          E::update_existing    == ME(4),47        "Expected enumeration values do not match");48  // Option group for copy on directories49  LIBCPP_STATIC_ASSERT(50          E::recursive == ME(8),51        "Expected enumeration values do not match");52  // Option group for copy on symlinks53  LIBCPP_STATIC_ASSERT(54          E::copy_symlinks == ME(16) &&55          E::skip_symlinks == ME(32),56        "Expected enumeration values do not match");57  // Option group for changing form of copy58  LIBCPP_STATIC_ASSERT(59          E::directories_only    == ME(64) &&60          E::create_symlinks     == ME(128) &&61          E::create_hard_links   == ME(256),62        "Expected enumeration values do not match");63 64  return 0;65}66