Home | History | Annotate | Download | only in path.nonmember
      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 // <experimental/filesystem>
     13 
     14 // void swap(path& lhs, path& rhs) noexcept;
     15 
     16 #include <experimental/filesystem>
     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 namespace fs = std::experimental::filesystem;
     25 
     26 // NOTE: this is tested in path.members/path.modifiers via the member swap.
     27 int main()
     28 {
     29   using namespace fs;
     30   const char* value1 = "foo/bar/baz";
     31   const char* value2 = "_THIS_IS_LONG_THIS_IS_LONG_THIS_IS_LONG_THIS_IS_LONG_THIS_IS_LONG_THIS_IS_LONG_THIS_IS_LONG";
     32   path p1(value1);
     33   path p2(value2);
     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() == value2);
     45     assert(p2.native() == value1);
     46     swap(p1, p2);
     47     assert(p1.native() == value1);
     48     assert(p2.native() == value2);
     49   }
     50 }
     51