Daily bump.
[official-gcc.git] / libstdc++-v3 / testsuite / 27_io / filesystem / file_status / 1.cc
blobb2687cec4c803cd2841ce74a827019c818cd0b63
1 // Copyright (C) 2017-2024 Free Software Foundation, Inc.
2 //
3 // This file is part of the GNU ISO C++ Library. This library is free
4 // software; you can redistribute it and/or modify it under the
5 // terms of the GNU General Public License as published by the
6 // Free Software Foundation; either version 3, or (at your option)
7 // any later version.
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License along
15 // with this library; see the file COPYING3. If not see
16 // <http://www.gnu.org/licenses/>.
18 // { dg-do run { target c++17 } }
19 // { dg-require-filesystem-ts "" }
21 #include <filesystem>
22 #include <testsuite_hooks.h>
24 namespace fs = std::filesystem;
26 template<typename... Args>
27 constexpr bool nothrow_constructible() {
28 return std::is_nothrow_constructible<fs::file_status, Args...>::value;
31 void
32 test01()
34 fs::file_status st0;
35 VERIFY( st0.type() == fs::file_type::none );
36 VERIFY( st0.permissions() == fs::perms::unknown );
37 static_assert( nothrow_constructible<>(), "" );
39 fs::file_status st1(fs::file_type::regular);
40 VERIFY( st1.type() == fs::file_type::regular );
41 VERIFY( st1.permissions() == fs::perms::unknown );
42 static_assert( nothrow_constructible<fs::file_type>(), "" );
44 fs::file_status st2(fs::file_type::directory, fs::perms::owner_all);
45 VERIFY( st2.type() == fs::file_type::directory );
46 VERIFY( st2.permissions() == fs::perms::owner_all );
47 static_assert( nothrow_constructible<fs::file_type, fs::perms>(), "" );
49 static_assert( nothrow_constructible<const fs::file_status&>(), "" );
50 static_assert( nothrow_constructible<fs::file_status>(), "" );
53 void
54 test02()
56 fs::file_status st;
57 VERIFY( st.type() == fs::file_type::none );
58 VERIFY( st.permissions() == fs::perms::unknown );
60 st.type(fs::file_type::symlink);
61 VERIFY( st.type() == fs::file_type::symlink );
62 VERIFY( st.permissions() == fs::perms::unknown );
64 st.permissions(fs::perms::owner_all);
65 VERIFY( st.type() == fs::file_type::symlink );
66 VERIFY( st.permissions() == fs::perms::owner_all );
69 void check_non_explicit_constructor(fs::file_status) { }
71 void
72 test03()
74 check_non_explicit_constructor( {} ); // LWG 2787
77 int
78 main()
80 test01();
81 test02();
82 test03();