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 // <filesystem> 13 14 // class recursive_directory_iterator 15 16 // recursive_directory_iterator begin(recursive_directory_iterator iter) noexcept; 17 // recursive_directory_iterator end(recursive_directory_iterator iter) noexcept; 18 19 #include "filesystem_include.hpp" 20 #include <type_traits> 21 #include <set> 22 #include <cassert> 23 24 #include "test_macros.h" 25 #include "rapid-cxx-test.hpp" 26 #include "filesystem_test_helper.hpp" 27 #include <iostream> 28 29 using namespace fs; 30 31 TEST_SUITE(recursive_directory_iterator_begin_end_tests) 32 TEST_CASE(test_function_signatures)33TEST_CASE(test_function_signatures) 34 { 35 recursive_directory_iterator d; ((void)d); 36 37 ASSERT_SAME_TYPE(decltype(begin(d)), recursive_directory_iterator); 38 ASSERT_NOEXCEPT(begin(std::move(d))); 39 40 ASSERT_SAME_TYPE(decltype(end(d)), recursive_directory_iterator); 41 ASSERT_NOEXCEPT(end(std::move(d))); 42 } 43 TEST_CASE(test_ranged_for_loop)44TEST_CASE(test_ranged_for_loop) 45 { 46 const path testDir = StaticEnv::Dir; 47 std::set<path> dir_contents(std::begin(StaticEnv::RecDirIterationList), 48 std::end( StaticEnv::RecDirIterationList)); 49 50 std::error_code ec; 51 recursive_directory_iterator it(testDir, ec); 52 TEST_REQUIRE(!ec); 53 54 for (auto& elem : it) { 55 TEST_CHECK(dir_contents.erase(elem) == 1); 56 } 57 TEST_CHECK(dir_contents.empty()); 58 } 59 60 TEST_SUITE_END() 61