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 recursive_directory_iterator 15 16 // recursive_recursive_directory_iterator(recursive_recursive_directory_iterator const&); 17 18 #include <experimental/filesystem> 19 #include <type_traits> 20 #include <set> 21 #include <cassert> 22 23 #include "test_macros.h" 24 #include "rapid-cxx-test.hpp" 25 #include "filesystem_test_helper.hpp" 26 27 using namespace std::experimental::filesystem; 28 29 TEST_SUITE(recursive_directory_iterator_copy_construct_tests) 30 TEST_CASE(test_constructor_signature)31TEST_CASE(test_constructor_signature) 32 { 33 using D = recursive_directory_iterator; 34 static_assert(std::is_copy_constructible<D>::value, ""); 35 //static_assert(!std::is_nothrow_copy_constructible<D>::value, ""); 36 } 37 TEST_CASE(test_copy_end_iterator)38TEST_CASE(test_copy_end_iterator) 39 { 40 const recursive_directory_iterator endIt; 41 recursive_directory_iterator it(endIt); 42 TEST_CHECK(it == endIt); 43 } 44 TEST_CASE(test_copy_valid_iterator)45TEST_CASE(test_copy_valid_iterator) 46 { 47 const path testDir = StaticEnv::Dir; 48 const recursive_directory_iterator endIt{}; 49 50 // build 'it' up with "interesting" non-default state so we can test 51 // that it gets copied. We want to get 'it' into a state such that: 52 // it.options() != directory_options::none 53 // it.depth() != 0 54 // it.recursion_pending() != true 55 const directory_options opts = directory_options::skip_permission_denied; 56 recursive_directory_iterator it(testDir, opts); 57 TEST_REQUIRE(it != endIt); 58 while (it.depth() == 0) { 59 ++it; 60 TEST_REQUIRE(it != endIt); 61 } 62 it.disable_recursion_pending(); 63 TEST_CHECK(it.options() == opts); 64 TEST_CHECK(it.depth() == 1); 65 TEST_CHECK(it.recursion_pending() == false); 66 const path entry = *it; 67 68 // OPERATION UNDER TEST // 69 const recursive_directory_iterator it2(it); 70 // ------------------- // 71 72 TEST_REQUIRE(it2 == it); 73 TEST_CHECK(*it2 == entry); 74 TEST_CHECK(it2.depth() == 1); 75 TEST_CHECK(it2.recursion_pending() == false); 76 TEST_CHECK(it != endIt); 77 } 78 79 TEST_SUITE_END() 80