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 | // REQUIRES: can-create-symlinks |
10 | // UNSUPPORTED: c++03, c++11, c++14 |
11 | |
12 | // <filesystem> |
13 | |
14 | // class directory_entry |
15 | |
16 | // file_status symlink_status() const; |
17 | // file_status symlink_status(error_code&) const noexcept; |
18 | |
19 | #include <filesystem> |
20 | #include <type_traits> |
21 | #include <cassert> |
22 | |
23 | #include "filesystem_test_helper.h" |
24 | #include "test_macros.h" |
25 | namespace fs = std::filesystem; |
26 | |
27 | static void test_signature() { |
28 | using namespace fs; |
29 | static_test_env static_env; |
30 | { |
31 | const directory_entry e("foo" ); |
32 | std::error_code ec; |
33 | static_assert(std::is_same<decltype(e.symlink_status()), file_status>::value, "" ); |
34 | static_assert(std::is_same<decltype(e.symlink_status(ec&: ec)), file_status>::value, "" ); |
35 | static_assert(noexcept(e.symlink_status()) == false, "" ); |
36 | static_assert(noexcept(e.symlink_status(ec&: ec)) == true, "" ); |
37 | } |
38 | path TestCases[] = {static_env.File, static_env.Dir, static_env.SymlinkToFile, |
39 | static_env.DNE}; |
40 | for (const auto& p : TestCases) { |
41 | const directory_entry e(p); |
42 | std::error_code pec = GetTestEC(), eec = GetTestEC(1); |
43 | file_status ps = fs::symlink_status(p, pec); |
44 | file_status es = e.symlink_status(eec); |
45 | assert(ps.type() == es.type()); |
46 | assert(ps.permissions() == es.permissions()); |
47 | assert(pec.default_error_condition() == eec.default_error_condition()); |
48 | } |
49 | for (const auto& p : TestCases) { |
50 | const directory_entry e(p); |
51 | file_status ps = fs::symlink_status(p); |
52 | file_status es = e.symlink_status(); |
53 | assert(ps.type() == es.type()); |
54 | assert(ps.permissions() == es.permissions()); |
55 | } |
56 | } |
57 | |
58 | int main(int, char**) { |
59 | test_signature(); |
60 | return 0; |
61 | } |
62 | |