xref: /llvm-project/libcxx/test/std/input.output/filesystems/class.file_status/file_status.mods.pass.cpp (revision f7b43230b844373b421571467864a5fbf644e38d)
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++98, c++03
10 
11 // <filesystem>
12 
13 // class file_status
14 
15 // void type(file_type) noexcept;
16 // void permissions(perms) noexcept;
17 
18 #include "filesystem_include.hpp"
19 #include <type_traits>
20 #include <cassert>
21 
22 
23 int main(int, char**) {
24   using namespace fs;
25 
26   file_status st;
27 
28   // type test
29   {
30     static_assert(noexcept(st.type(file_type::regular)),
31                   "operation must be noexcept");
32     static_assert(std::is_same<decltype(st.type(file_type::regular)), void>::value,
33                  "operation must return void");
34     assert(st.type() != file_type::regular);
35     st.type(file_type::regular);
36     assert(st.type() == file_type::regular);
37   }
38   // permissions test
39   {
40     static_assert(noexcept(st.permissions(perms::owner_read)),
41                   "operation must be noexcept");
42     static_assert(std::is_same<decltype(st.permissions(perms::owner_read)), void>::value,
43                  "operation must return void");
44     assert(st.permissions() != perms::owner_read);
45     st.permissions(perms::owner_read);
46     assert(st.permissions() == perms::owner_read);
47   }
48 
49   return 0;
50 }
51