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   {
33     using namespace std; using namespace fs;
34     ASSERT_NOEXCEPT(swap(p1, p2));
35     ASSERT_SAME_TYPE(void, decltype(swap(p1, p2)));
36   }
37   {
38     DisableAllocationGuard g;
39     using namespace std;
40     using namespace fs;
41     swap(p1, p2);
42     assert(p1.native() == value2);
43     assert(p2.native() == value1);
44     swap(p1, p2);
45     assert(p1.native() == value1);
46     assert(p2.native() == value2);
47   }
48 
49   return 0;
50 }
51