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 //===----------------------------------------------------------------------===//
8 
9 // UNSUPPORTED: c++03, c++11, c++14
10 // UNSUPPORTED: availability-filesystem-missing
11 
12 // <filesystem>
13 
14 // class path
15 
16 // path(path&&) noexcept
17 
18 #include <filesystem>
19 #include <cassert>
20 #include <string>
21 #include <type_traits>
22 
23 #include "test_macros.h"
24 #include "count_new.h"
25 namespace fs = std::filesystem;
26 
main(int,char **)27 int main(int, char**) {
28   using namespace fs;
29   static_assert(std::is_nothrow_move_constructible<path>::value, "");
30   assert(globalMemCounter.checkOutstandingNewEq(0));
31   const std::string s("we really really really really really really really "
32                       "really really long string so that we allocate");
33   ASSERT_WITH_LIBRARY_INTERNAL_ALLOCATIONS(
34       globalMemCounter.checkOutstandingNewLessThanOrEqual(1));
35   const fs::path::string_type ps(s.begin(), s.end());
36   path p(s);
37   {
38     DisableAllocationGuard g;
39     path p2(std::move(p));
40     assert(p2.native() == ps);
41     assert(p.native() != ps); // Testing moved from state
42   }
43 
44   return 0;
45 }
46