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
10 
11 // <filesystem>
12 
13 // void swap(path& lhs, path& rhs) noexcept;
14 
15 #include "filesystem_include.h"
16 #include <type_traits>
17 #include <cassert>
18 
19 #include "test_macros.h"
20 #include "count_new.h"
21 #include "filesystem_test_helper.h"
22 
23 
24 // NOTE: this is tested in path.members/path.modifiers via the member swap.
25 int main(int, char**)
26 {
27   using namespace fs;
28   const char* value1 = "foo/bar/baz";
29   const char* value2 = "_THIS_IS_LONG_THIS_IS_LONG_THIS_IS_LONG_THIS_IS_LONG_THIS_IS_LONG_THIS_IS_LONG_THIS_IS_LONG";
30   path p1(value1);
31   path p2(value2);
32   fs::path::string_type ps1 = p1.native();
33   fs::path::string_type ps2 = p2.native();
34   {
35     using namespace std; using namespace fs;
36     ASSERT_NOEXCEPT(swap(p1, p2));
37     ASSERT_SAME_TYPE(void, decltype(swap(p1, p2)));
38   }
39   {
40     DisableAllocationGuard g;
41     using namespace std;
42     using namespace fs;
43     swap(p1, p2);
44     assert(p1.native() == ps2);
45     assert(p2.native() == ps1);
46     swap(p1, p2);
47     assert(p1.native() == ps1);
48     assert(p2.native() == ps2);
49   }
50 
51   return 0;
52 }
53