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
10
11 // <filesystem>
12
13 // class directory_entry
14
15 // file_status status() const;
16 // file_status status(error_code const&) const noexcept;
17
18 #include "filesystem_include.h"
19 #include <type_traits>
20 #include <cassert>
21
22 #include "filesystem_test_helper.h"
23 #include "rapid-cxx-test.h"
24
25 #include "test_macros.h"
26
27 TEST_SUITE(directory_entry_status_testsuite)
28
TEST_CASE(test_basic)29 TEST_CASE(test_basic) {
30 using namespace fs;
31 static_test_env static_env;
32 {
33 const fs::directory_entry e("foo");
34 std::error_code ec;
35 static_assert(std::is_same<decltype(e.status()), fs::file_status>::value, "");
36 static_assert(std::is_same<decltype(e.status(ec)), fs::file_status>::value, "");
37 static_assert(noexcept(e.status()) == false, "");
38 static_assert(noexcept(e.status(ec)) == true, "");
39 }
40 path TestCases[] = {static_env.File, static_env.Dir, static_env.SymlinkToFile,
41 static_env.DNE};
42 for (const auto& p : TestCases) {
43 const directory_entry e(p);
44 std::error_code pec = GetTestEC(), eec = GetTestEC(1);
45 file_status ps = fs::status(p, pec);
46 file_status es = e.status(eec);
47 TEST_CHECK(ps.type() == es.type());
48 TEST_CHECK(ps.permissions() == es.permissions());
49 TEST_CHECK(pec == eec);
50 }
51 for (const auto& p : TestCases) {
52 const directory_entry e(p);
53 file_status ps = fs::status(p);
54 file_status es = e.status();
55 TEST_CHECK(ps.type() == es.type());
56 TEST_CHECK(ps.permissions() == es.permissions());
57 }
58 }
59
60 TEST_SUITE_END()
61