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 // <experimental/filesystem> 13 14 // class directory_entry 15 16 // file_status status() const; 17 // file_status status(error_code const&) const noexcept; 18 19 #include <experimental/filesystem> 20 #include <type_traits> 21 #include <cassert> 22 23 #include "filesystem_test_helper.hpp" 24 25 int main() 26 { 27 using namespace fs; 28 { 29 const directory_entry e("foo"); 30 std::error_code ec; 31 static_assert(std::is_same<decltype(e.status()), file_status>::value, ""); 32 static_assert(std::is_same<decltype(e.status(ec)), file_status>::value, ""); 33 static_assert(noexcept(e.status()) == false, ""); 34 static_assert(noexcept(e.status(ec)) == true, ""); 35 } 36 auto TestFn = [](path const& p) { 37 const directory_entry e(p); 38 std::error_code pec, eec; 39 file_status ps = fs::status(p, pec); 40 file_status es = e.status(eec); 41 assert(ps.type() == es.type()); 42 assert(ps.permissions() == es.permissions()); 43 assert(pec == eec); 44 }; 45 { 46 TestFn(StaticEnv::File); 47 TestFn(StaticEnv::Dir); 48 TestFn(StaticEnv::SymlinkToFile); 49 TestFn(StaticEnv::DNE); 50 } 51 } 52