status.pass.cpp (1811B)
1 //===----------------------------------------------------------------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is dual licensed under the MIT and the University of Illinois Open 6 // Source Licenses. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 // UNSUPPORTED: c++98, c++03 11 12 // <filesystem> 13 14 // class directory_entry 15 16 // file_status status() const; 17 // file_status status(error_code const&) const noexcept; 18 19 #include "filesystem_include.hpp" 20 #include <type_traits> 21 #include <cassert> 22 23 #include "filesystem_test_helper.hpp" 24 #include "rapid-cxx-test.hpp" 25 26 TEST_SUITE(directory_entry_status_testsuite) 27 28 TEST_CASE(test_basic) { 29 using namespace fs; 30 { 31 const fs::directory_entry e("foo"); 32 std::error_code ec; 33 static_assert(std::is_same<decltype(e.status()), fs::file_status>::value, ""); 34 static_assert(std::is_same<decltype(e.status(ec)), fs::file_status>::value, ""); 35 static_assert(noexcept(e.status()) == false, ""); 36 static_assert(noexcept(e.status(ec)) == true, ""); 37 } 38 path TestCases[] = {StaticEnv::File, StaticEnv::Dir, StaticEnv::SymlinkToFile, 39 StaticEnv::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::status(p, pec); 44 file_status es = e.status(eec); 45 TEST_CHECK(ps.type() == es.type()); 46 TEST_CHECK(ps.permissions() == es.permissions()); 47 TEST_CHECK(pec == eec); 48 } 49 for (const auto& p : TestCases) { 50 const directory_entry e(p); 51 file_status ps = fs::status(p); 52 file_status es = e.status(); 53 TEST_CHECK(ps.type() == es.type()); 54 TEST_CHECK(ps.permissions() == es.permissions()); 55 } 56 } 57 58 TEST_SUITE_END()