]> git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/experimental/filesystem/file_status/1.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / experimental / filesystem / file_status / 1.cc
1 // Copyright (C) 2017-2019 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.
8
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.
13
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/>.
17
18 // { dg-options "-DUSE_FILESYSTEM_TS -lstdc++fs" }
19 // { dg-do run { target c++11 } }
20 // { dg-require-filesystem-ts "" }
21
22 #include <experimental/filesystem>
23 #include <testsuite_hooks.h>
24
25 namespace fs = std::experimental::filesystem;
26
27 template<typename... Args>
28 constexpr bool nothrow_constructible() {
29 return std::is_nothrow_constructible<fs::file_status, Args...>::value;
30 }
31
32 void
33 test01()
34 {
35 fs::file_status st0;
36 VERIFY( st0.type() == fs::file_type::none );
37 VERIFY( st0.permissions() == fs::perms::unknown );
38 static_assert( nothrow_constructible<>(), "" );
39
40 fs::file_status st1(fs::file_type::regular);
41 VERIFY( st1.type() == fs::file_type::regular );
42 VERIFY( st1.permissions() == fs::perms::unknown );
43 static_assert( nothrow_constructible<fs::file_type>(), "" );
44
45 fs::file_status st2(fs::file_type::directory, fs::perms::owner_all);
46 VERIFY( st2.type() == fs::file_type::directory );
47 VERIFY( st2.permissions() == fs::perms::owner_all );
48 static_assert( nothrow_constructible<fs::file_type, fs::perms>(), "" );
49
50 static_assert( nothrow_constructible<const fs::file_status&>(), "" );
51 static_assert( nothrow_constructible<fs::file_status>(), "" );
52 }
53
54 void
55 test02()
56 {
57 fs::file_status st;
58 VERIFY( st.type() == fs::file_type::none );
59 VERIFY( st.permissions() == fs::perms::unknown );
60
61 st.type(fs::file_type::symlink);
62 VERIFY( st.type() == fs::file_type::symlink );
63 VERIFY( st.permissions() == fs::perms::unknown );
64
65 st.permissions(fs::perms::owner_all);
66 VERIFY( st.type() == fs::file_type::symlink );
67 VERIFY( st.permissions() == fs::perms::owner_all );
68 }
69
70 int
71 main()
72 {
73 test01();
74 test02();
75 }