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 // directory_entry(directory_entry&&) noexcept = default; 16 17 #include "filesystem_include.h" 18 #include <type_traits> 19 #include <cassert> 20 21 #include "test_macros.h" 22 #include "rapid-cxx-test.h" 23 #include "filesystem_test_helper.h" 24 #include "test_convertible.h" 25 26 TEST_SUITE(directory_entry_path_ctor_suite) 27 TEST_CASE(move_ctor)28TEST_CASE(move_ctor) { 29 using namespace fs; 30 // Move 31 { 32 static_assert(std::is_nothrow_move_constructible<directory_entry>::value, 33 "directory_entry must be nothrow move constructible"); 34 const path p("foo/bar/baz"); 35 directory_entry e(p); 36 assert(e.path() == p); 37 directory_entry e2(std::move(e)); 38 assert(e2.path() == p); 39 assert(e.path() != p); // Testing moved from state. 40 } 41 } 42 TEST_CASE(move_ctor_copies_cache)43TEST_CASE(move_ctor_copies_cache) { 44 using namespace fs; 45 scoped_test_env env; 46 const path dir = env.create_dir("dir"); 47 const path file = env.create_file("dir/file", 42); 48 const path sym = env.create_symlink("dir/file", "sym"); 49 50 { 51 directory_entry ent(sym); 52 53 fs::remove(sym); 54 55 directory_entry ent_cp(std::move(ent)); 56 TEST_CHECK(ent_cp.path() == sym); 57 TEST_CHECK(ent_cp.is_symlink()); 58 } 59 60 { 61 directory_entry ent(file); 62 63 fs::remove(file); 64 65 directory_entry ent_cp(std::move(ent)); 66 TEST_CHECK(ent_cp.path() == file); 67 TEST_CHECK(ent_cp.is_regular_file()); 68 } 69 } 70 71 TEST_SUITE_END() 72