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 | // void type(file_type) noexcept; |
16 | // void permissions(perms) noexcept; |
17 | |
18 | #include <filesystem> |
19 | #include <type_traits> |
20 | #include <cassert> |
21 | |
22 | #include "test_macros.h" |
23 | namespace fs = std::filesystem; |
24 | |
25 | int main(int, char**) { |
26 | using namespace fs; |
27 | |
28 | file_status st; |
29 | |
30 | // type test |
31 | { |
32 | static_assert(noexcept(st.type(ft: file_type::regular)), |
33 | "operation must be noexcept" ); |
34 | static_assert(std::is_same<decltype(st.type(file_type::regular)), void>::value, |
35 | "operation must return void" ); |
36 | assert(st.type() != file_type::regular); |
37 | st.type(ft: file_type::regular); |
38 | assert(st.type() == file_type::regular); |
39 | } |
40 | // permissions test |
41 | { |
42 | static_assert(noexcept(st.permissions(prms: perms::owner_read)), |
43 | "operation must be noexcept" ); |
44 | static_assert(std::is_same<decltype(st.permissions(perms::owner_read)), void>::value, |
45 | "operation must return void" ); |
46 | assert(st.permissions() != perms::owner_read); |
47 | st.permissions(prms: perms::owner_read); |
48 | assert(st.permissions() == perms::owner_read); |
49 | } |
50 | |
51 | return 0; |
52 | } |
53 | |