clear.pass.cpp 993 B

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