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