| 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, c++11, c++14 |
| 10 | |
| 11 | // <filesystem> |
| 12 | |
| 13 | // class file_status |
| 14 | |
| 15 | // explicit file_status() noexcept; |
| 16 | // explicit file_status(file_type, perms prms = perms::unknown) noexcept; |
| 17 | |
| 18 | #include <filesystem> |
| 19 | #include <type_traits> |
| 20 | #include <cassert> |
| 21 | |
| 22 | #include "test_convertible.h" |
| 23 | |
| 24 | #include "test_macros.h" |
| 25 | namespace fs = std::filesystem; |
| 26 | |
| 27 | int main(int, char**) { |
| 28 | using namespace fs; |
| 29 | // Default ctor |
| 30 | { |
| 31 | static_assert(std::is_nothrow_default_constructible<file_status>::value, |
| 32 | "The default constructor must be noexcept" ); |
| 33 | static_assert(test_convertible<file_status>(), |
| 34 | "The default constructor must not be explicit" ); |
| 35 | const file_status f; |
| 36 | assert(f.type() == file_type::none); |
| 37 | assert(f.permissions() == perms::unknown); |
| 38 | } |
| 39 | |
| 40 | // Unary ctor |
| 41 | { |
| 42 | static_assert(std::is_nothrow_constructible<file_status, file_type>::value, |
| 43 | "This constructor must be noexcept" ); |
| 44 | static_assert(!test_convertible<file_status, file_type>(), |
| 45 | "This constructor must be explicit" ); |
| 46 | |
| 47 | const file_status f(file_type::not_found); |
| 48 | assert(f.type() == file_type::not_found); |
| 49 | assert(f.permissions() == perms::unknown); |
| 50 | } |
| 51 | // Binary ctor |
| 52 | { |
| 53 | static_assert(std::is_nothrow_constructible<file_status, file_type, perms>::value, |
| 54 | "This constructor must be noexcept" ); |
| 55 | static_assert(!test_convertible<file_status, file_type, perms>(), |
| 56 | "This constructor must b explicit" ); |
| 57 | const file_status f(file_type::regular, perms::owner_read); |
| 58 | assert(f.type() == file_type::regular); |
| 59 | assert(f.permissions() == perms::owner_read); |
| 60 | } |
| 61 | |
| 62 | return 0; |
| 63 | } |
| 64 | |