Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / libcxx / test / std / input.output / filesystems / class.rec.dir.itr / rec.dir.itr.members / copy.pass.cpp
blobb52e1a63fe988970a66de69010c064a70f8e9b2b
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 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: c++03
10 // UNSUPPORTED: no-filesystem
11 // UNSUPPORTED: availability-filesystem-missing
13 // <filesystem>
15 // class recursive_directory_iterator
17 // recursive_recursive_directory_iterator(recursive_recursive_directory_iterator const&);
19 #include "filesystem_include.h"
20 #include <type_traits>
21 #include <set>
22 #include <cassert>
24 #include "test_macros.h"
25 #include "filesystem_test_helper.h"
27 using namespace fs;
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);
40 assert(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
52 // it.depth() != 0
53 // it.recursion_pending() != true
54 const directory_options opts = directory_options::skip_permission_denied;
55 recursive_directory_iterator it(testDir, opts);
56 assert(it != endIt);
57 while (it.depth() == 0) {
58 ++it;
59 assert(it != endIt);
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 // ------------------- //
71 assert(it2 == it);
72 assert(*it2 == entry);
73 assert(it2.depth() == 1);
74 assert(it2.recursion_pending() == false);
75 assert(it != endIt);
78 int main(int, char**) {
79 test_constructor_signature();
80 test_copy_end_iterator();
81 test_copy_valid_iterator();
83 return 0;