clear.pass.cpp 972 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. // UNSUPPORTED: c++98, c++03
  9. // <filesystem>
  10. // class path
  11. // void clear() noexcept
  12. #include "filesystem_include.hpp"
  13. #include <type_traits>
  14. #include <cassert>
  15. #include "test_macros.h"
  16. #include "test_iterators.h"
  17. #include "count_new.hpp"
  18. #include "filesystem_test_helper.hpp"
  19. int main(int, char**) {
  20. using namespace fs;
  21. {
  22. path p;
  23. ASSERT_NOEXCEPT(p.clear());
  24. ASSERT_SAME_TYPE(void, decltype(p.clear()));
  25. p.clear();
  26. assert(p.empty());
  27. }
  28. {
  29. const path p("/foo/bar/baz");
  30. path p2(p);
  31. assert(p == p2);
  32. p2.clear();
  33. assert(p2.empty());
  34. }
  35. return 0;
  36. }