1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
10 // UNSUPPORTED: no-filesystem
11 // UNSUPPORTED: availability-filesystem-missing
15 // class recursive_directory_iterator
17 // recursive_recursive_directory_iterator(recursive_recursive_directory_iterator const&);
19 #include "filesystem_include.h"
20 #include <type_traits>
24 #include "test_macros.h"
25 #include "filesystem_test_helper.h"
29 static void test_constructor_signature()
31 using D
= recursive_directory_iterator
;
32 static_assert(std::is_copy_constructible
<D
>::value
, "");
33 //static_assert(!std::is_nothrow_copy_constructible<D>::value, "");
36 static void test_copy_end_iterator()
38 const recursive_directory_iterator endIt
;
39 recursive_directory_iterator
it(endIt
);
43 static void test_copy_valid_iterator()
45 static_test_env static_env
;
46 const path testDir
= static_env
.Dir
;
47 const recursive_directory_iterator endIt
{};
49 // build 'it' up with "interesting" non-default state so we can test
50 // that it gets copied. We want to get 'it' into a state such that:
51 // it.options() != directory_options::none
53 // it.recursion_pending() != true
54 const directory_options opts
= directory_options::skip_permission_denied
;
55 recursive_directory_iterator
it(testDir
, opts
);
57 while (it
.depth() == 0) {
61 it
.disable_recursion_pending();
62 assert(it
.options() == opts
);
63 assert(it
.depth() == 1);
64 assert(it
.recursion_pending() == false);
65 const path entry
= *it
;
67 // OPERATION UNDER TEST //
68 const recursive_directory_iterator
it2(it
);
69 // ------------------- //
72 assert(*it2
== entry
);
73 assert(it2
.depth() == 1);
74 assert(it2
.recursion_pending() == false);
78 int main(int, char**) {
79 test_constructor_signature();
80 test_copy_end_iterator();
81 test_copy_valid_iterator();