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