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 / move.pass.cpp
bloba3cb1415dc93eb93f4df697dd41548a687426df1
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_directory_iterator(recursive_directory_iterator&&) noexcept;
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_nothrow_move_constructible<D>::value, "");
35 static void test_move_end_iterator()
37 const recursive_directory_iterator endIt;
38 recursive_directory_iterator endIt2{};
40 recursive_directory_iterator it(std::move(endIt2));
41 assert(it == endIt);
42 assert(endIt2 == endIt);
45 static void test_move_valid_iterator()
47 static_test_env static_env;
48 const path testDir = static_env.Dir;
49 const recursive_directory_iterator endIt{};
51 // build 'it' up with "interesting" non-default state so we can test
52 // that it gets copied. We want to get 'it' into a state such that:
53 // it.options() != directory_options::none
54 // it.depth() != 0
55 // it.recursion_pending() != true
56 const directory_options opts = directory_options::skip_permission_denied;
57 recursive_directory_iterator it(testDir, opts);
58 assert(it != endIt);
59 while (it.depth() == 0) {
60 ++it;
61 assert(it != endIt);
63 it.disable_recursion_pending();
64 assert(it.options() == opts);
65 assert(it.depth() == 1);
66 assert(it.recursion_pending() == false);
67 const path entry = *it;
69 // OPERATION UNDER TEST //
70 const recursive_directory_iterator it2(std::move(it));
71 // ------------------- //
73 assert(it2 != endIt);
74 assert(*it2 == entry);
75 assert(it2.depth() == 1);
76 assert(it2.recursion_pending() == false);
79 int main(int, char**) {
80 test_constructor_signature();
81 test_move_end_iterator();
82 test_move_valid_iterator();
84 return 0;