Home | History | Annotate | Download | only in directory_iterator.members
      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 directory_iterator
     15 
     16 // directory_iterator(directory_iterator&&) noexcept;
     17 
     18 #include "filesystem_include.hpp"
     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 fs;
     28 
     29 TEST_SUITE(directory_iterator_move_construct_tests)
     30 
     31 TEST_CASE(test_constructor_signature)
     32 {
     33     using D = directory_iterator;
     34     static_assert(std::is_nothrow_move_constructible<D>::value, "");
     35 }
     36 
     37 TEST_CASE(test_move_end_iterator)
     38 {
     39     const directory_iterator endIt;
     40     directory_iterator endIt2{};
     41 
     42     directory_iterator it(std::move(endIt2));
     43     TEST_CHECK(it == endIt);
     44     TEST_CHECK(endIt2 == endIt);
     45 }
     46 
     47 TEST_CASE(test_move_valid_iterator)
     48 {
     49     const path testDir = StaticEnv::Dir;
     50     const directory_iterator endIt{};
     51 
     52     directory_iterator it(testDir);
     53     TEST_REQUIRE(it != endIt);
     54     const path entry = *it;
     55 
     56     const directory_iterator it2(std::move(it));
     57     TEST_CHECK(*it2 == entry);
     58 
     59     TEST_CHECK(it == it2 || it == endIt);
     60 }
     61 
     62 TEST_SUITE_END()
     63